summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-05-22 07:03:34 +0000
committerChris Lattner <sabre@nondot.org>2011-05-22 07:03:34 +0000
commitf0d59072de69bcfd472827bcc687707ade3c960b (patch)
tree538de341f0c3eeca2ac844bbb0fa437bf39ddcec /llvm
parenta10327f5313601179c0ec599449fe1985f3277b1 (diff)
downloadbcm5719-llvm-f0d59072de69bcfd472827bcc687707ade3c960b.tar.gz
bcm5719-llvm-f0d59072de69bcfd472827bcc687707ade3c960b.zip
fix PR9841 by having GVN not process dead loads. This was
causing it to get into infinite loops when it would widen a load (which can necessarily leave around dead loads). llvm-svn: 131847
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Transforms/Scalar/GVN.cpp5
-rw-r--r--llvm/test/Transforms/GVN/crash.ll12
2 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 1da5238bbb6..2515fd112c1 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -1607,6 +1607,11 @@ bool GVN::processLoad(LoadInst *L) {
if (L->isVolatile())
return false;
+ if (L->use_empty()) {
+ markInstructionForDeletion(L);
+ return true;
+ }
+
// ... to a pointer that has been loaded from before...
MemDepResult Dep = MD->getDependency(L);
diff --git a/llvm/test/Transforms/GVN/crash.ll b/llvm/test/Transforms/GVN/crash.ll
index 4a3aa1c55a8..31eae256c6e 100644
--- a/llvm/test/Transforms/GVN/crash.ll
+++ b/llvm/test/Transforms/GVN/crash.ll
@@ -151,3 +151,15 @@ dead:
dead2:
ret i32 %A
}
+
+
+; PR9841
+define fastcc i8 @test5(i8* %P) nounwind {
+entry:
+ %0 = load i8* %P, align 2
+
+ %Q = getelementptr i8* %P, i32 1
+ %1 = load i8* %Q, align 1
+ ret i8 %1
+}
+
OpenPOWER on IntegriCloud