[llvm-commits] [llvm] r40746 - in /llvm/trunk/lib: Analysis/MemoryDependenceAnalysis.cpp Transforms/Scalar/GVN.cpp
Owen Anderson
resistor at mac.com
Thu Aug 2 10:56:05 PDT 2007
Author: resistor
Date: Thu Aug 2 12:56:05 2007
New Revision: 40746
URL: http://llvm.org/viewvc/llvm-project?rev=40746&view=rev
Log:
Fix a bug that was causing several miscompilations on SPEC.
Modified:
llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Modified: llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp?rev=40746&r1=40745&r2=40746&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryDependenceAnalysis.cpp Thu Aug 2 12:56:05 2007
@@ -111,19 +111,31 @@
while (!stack.empty()) {
BasicBlock* BB = stack.back();
- visited.insert(BB);
-
- if (resp.count(BB)) {
+ if (visited.count(BB)) {
stack.pop_back();
continue;
}
if (BB != block) {
+ visited.insert(BB);
+
Instruction* localDep = getDependency(query, 0, BB);
if (localDep != NonLocal) {
resp.insert(std::make_pair(BB, localDep));
+ stack.pop_back();
+
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;
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=40746&r1=40745&r2=40746&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Thu Aug 2 12:56:05 2007
@@ -658,7 +658,8 @@
SmallVector<Instruction*, 4>& toErase);
bool processNonLocalLoad(LoadInst* L, SmallVector<Instruction*, 4>& toErase);
Value *GetValueForBlock(BasicBlock *BB, LoadInst* orig,
- DenseMap<BasicBlock*, Value*> &Phis);
+ DenseMap<BasicBlock*, Value*> &Phis,
+ bool top_level = false);
void dump(DenseMap<BasicBlock*, Value*>& d);
};
@@ -715,11 +716,12 @@
/// GetValueForBlock - Get the value to use within the specified basic block.
/// available values are in Phis.
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.
Value *&V = Phis[BB];
- if (V) return V;
+ if (V && ! top_level) return V;
BasicBlock* singlePred = BB->getSinglePredecessor();
if (singlePred)
@@ -799,7 +801,7 @@
}
SmallPtrSet<BasicBlock*, 4> visited;
- Value* v = GetValueForBlock(L->getParent(), L, repl);
+ Value* v = GetValueForBlock(L->getParent(), L, repl, true);
MD.removeInstruction(L);
L->replaceAllUsesWith(v);
More information about the llvm-commits
mailing list