aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2007-08-02 17:56:05 +0000
committerOwen Anderson <resistor@mac.com>2007-08-02 17:56:05 +0000
commit1c2763d3fe8b70d9b85cb84bbce311ee4b86c9e1 (patch)
tree7cc0dca43746b27fa18cfc0e04a2506ecaef56c1
parenta326b5da4bdab865ba440b57ae4487fbb16a0b7d (diff)
downloadexternal_llvm-1c2763d3fe8b70d9b85cb84bbce311ee4b86c9e1.zip
external_llvm-1c2763d3fe8b70d9b85cb84bbce311ee4b86c9e1.tar.gz
external_llvm-1c2763d3fe8b70d9b85cb84bbce311ee4b86c9e1.tar.bz2
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
-rw-r--r--lib/Analysis/MemoryDependenceAnalysis.cpp18
-rw-r--r--lib/Transforms/Scalar/GVN.cpp10
2 files changed, 21 insertions, 7 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp
index a280fff..47e47e5 100644
--- a/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -111,19 +111,31 @@ void MemoryDependenceAnalysis::nonLocalHelper(Instruction* query,
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;
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index e39e2eb..dfe0dff 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -658,7 +658,8 @@ namespace {
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 @@ void GVN::dump(DenseMap<BasicBlock*, Value*>& d) {
/// 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 @@ bool GVN::processNonLocalLoad(LoadInst* L, SmallVector<Instruction*, 4>& toErase
}
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);