mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-30 16:17:05 +00:00 
			
		
		
		
	Fix a bug that was causing several miscompilations on SPEC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40746 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -111,19 +111,31 @@ void MemoryDependenceAnalysis::nonLocalHelper(Instruction* query, | |||||||
|   while (!stack.empty()) { |   while (!stack.empty()) { | ||||||
|     BasicBlock* BB = stack.back(); |     BasicBlock* BB = stack.back(); | ||||||
|      |      | ||||||
|     visited.insert(BB); |     if (visited.count(BB)) { | ||||||
|      |  | ||||||
|     if (resp.count(BB)) { |  | ||||||
|       stack.pop_back(); |       stack.pop_back(); | ||||||
|       continue; |       continue; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     if (BB != block) { |     if (BB != block) { | ||||||
|  |       visited.insert(BB); | ||||||
|  |        | ||||||
|       Instruction* localDep = getDependency(query, 0, BB); |       Instruction* localDep = getDependency(query, 0, BB); | ||||||
|       if (localDep != NonLocal) { |       if (localDep != NonLocal) { | ||||||
|         resp.insert(std::make_pair(BB, localDep)); |         resp.insert(std::make_pair(BB, localDep)); | ||||||
|  |         stack.pop_back(); | ||||||
|  |          | ||||||
|         continue; |         continue; | ||||||
|       } |       } | ||||||
|  |     } else if (BB == block && stack.size() > 1) { | ||||||
|  |       visited.insert(BB); | ||||||
|  |        | ||||||
|  |       Instruction* localDep = getDependency(query, 0, BB); | ||||||
|  |       if (localDep != query) | ||||||
|  |         resp.insert(std::make_pair(BB, localDep)); | ||||||
|  |        | ||||||
|  |       stack.pop_back(); | ||||||
|  |        | ||||||
|  |       continue; | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     bool predOnStack = false; |     bool predOnStack = false; | ||||||
|   | |||||||
| @@ -658,7 +658,8 @@ namespace { | |||||||
|                             SmallVector<Instruction*, 4>& toErase); |                             SmallVector<Instruction*, 4>& toErase); | ||||||
|     bool processNonLocalLoad(LoadInst* L, SmallVector<Instruction*, 4>& toErase); |     bool processNonLocalLoad(LoadInst* L, SmallVector<Instruction*, 4>& toErase); | ||||||
|     Value *GetValueForBlock(BasicBlock *BB, LoadInst* orig, |     Value *GetValueForBlock(BasicBlock *BB, LoadInst* orig, | ||||||
|                                   DenseMap<BasicBlock*, Value*> &Phis); |                             DenseMap<BasicBlock*, Value*> &Phis, | ||||||
|  |                             bool top_level = false); | ||||||
|     void dump(DenseMap<BasicBlock*, Value*>& d); |     void dump(DenseMap<BasicBlock*, Value*>& d); | ||||||
|   }; |   }; | ||||||
|    |    | ||||||
| @@ -715,11 +716,12 @@ void GVN::dump(DenseMap<BasicBlock*, Value*>& d) { | |||||||
| /// GetValueForBlock - Get the value to use within the specified basic block. | /// GetValueForBlock - Get the value to use within the specified basic block. | ||||||
| /// available values are in Phis. | /// available values are in Phis. | ||||||
| Value *GVN::GetValueForBlock(BasicBlock *BB, LoadInst* orig, | Value *GVN::GetValueForBlock(BasicBlock *BB, LoadInst* orig, | ||||||
|                                DenseMap<BasicBlock*, Value*> &Phis) {  |                                DenseMap<BasicBlock*, Value*> &Phis, | ||||||
|  |                                bool top_level) {  | ||||||
|                                   |                                   | ||||||
|   // If we have already computed this value, return the previously computed val. |   // If we have already computed this value, return the previously computed val. | ||||||
|   Value *&V = Phis[BB]; |   Value *&V = Phis[BB]; | ||||||
|   if (V) return V; |   if (V && ! top_level) return V; | ||||||
|    |    | ||||||
|   BasicBlock* singlePred = BB->getSinglePredecessor(); |   BasicBlock* singlePred = BB->getSinglePredecessor(); | ||||||
|   if (singlePred) |   if (singlePred) | ||||||
| @@ -799,7 +801,7 @@ bool GVN::processNonLocalLoad(LoadInst* L, SmallVector<Instruction*, 4>& toErase | |||||||
|     } |     } | ||||||
|    |    | ||||||
|   SmallPtrSet<BasicBlock*, 4> visited; |   SmallPtrSet<BasicBlock*, 4> visited; | ||||||
|   Value* v = GetValueForBlock(L->getParent(), L, repl); |   Value* v = GetValueForBlock(L->getParent(), L, repl, true); | ||||||
|    |    | ||||||
|   MD.removeInstruction(L); |   MD.removeInstruction(L); | ||||||
|   L->replaceAllUsesWith(v); |   L->replaceAllUsesWith(v); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user