summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-02-11 05:11:54 +0000
committerChris Lattner <sabre@nondot.org>2010-02-11 05:11:54 +0000
commitc053cbbc4d4123060b1142538f2cdd658d26bbc8 (patch)
tree5dd3170a12671f3996c81ba0874ca5d88371ddcc
parentf492ece81ea1719fd035bd0054eefd9739a8feba (diff)
downloadbcm5719-llvm-c053cbbc4d4123060b1142538f2cdd658d26bbc8.tar.gz
bcm5719-llvm-c053cbbc4d4123060b1142538f2cdd658d26bbc8.zip
Make DSE only scan blocks that are reachable from the entry
block. Other blocks may have pointer cycles that will crash basicaa and other alias analyses. In any case, there is no point wasting cycles optimizing dead blocks. This fixes rdar://7635088 llvm-svn: 95852
-rw-r--r--llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp8
-rw-r--r--llvm/test/Transforms/DeadStoreElimination/crash.ll14
2 files changed, 21 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 320afa19d5f..09c01d31412 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -44,8 +44,14 @@ namespace {
virtual bool runOnFunction(Function &F) {
bool Changed = false;
+
+ DominatorTree &DT = getAnalysis<DominatorTree>();
+
for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
- Changed |= runOnBasicBlock(*I);
+ // Only check non-dead blocks. Dead blocks may have strange pointer
+ // cycles that will confuse alias analysis.
+ if (DT.isReachableFromEntry(I))
+ Changed |= runOnBasicBlock(*I);
return Changed;
}
diff --git a/llvm/test/Transforms/DeadStoreElimination/crash.ll b/llvm/test/Transforms/DeadStoreElimination/crash.ll
index f89f8f5185c..6d8ba71b209 100644
--- a/llvm/test/Transforms/DeadStoreElimination/crash.ll
+++ b/llvm/test/Transforms/DeadStoreElimination/crash.ll
@@ -41,3 +41,17 @@ bb14: ; preds = %bb4
}
declare void @llvm.memcpy.i64(i8* nocapture, i8* nocapture, i64, i32) nounwind
+
+
+; rdar://7635088
+define i32 @test3() {
+entry:
+ ret i32 0
+
+dead:
+ %P2 = getelementptr i32 *%P2, i32 52
+ %Q2 = getelementptr i32 *%Q2, i32 52
+ store i32 4, i32* %P2
+ store i32 4, i32* %Q2
+ br label %dead
+} \ No newline at end of file
OpenPOWER on IntegriCloud