fix PR9841 by having GVN not process dead loads. This was
authorChris Lattner <sabre@nondot.org>
Sun, 22 May 2011 07:03:34 +0000 (07:03 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 22 May 2011 07:03:34 +0000 (07:03 +0000)
causing it to get into infinite loops when it would widen a
load (which can necessarily leave around dead loads).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131847 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/GVN.cpp
test/Transforms/GVN/crash.ll

index 1da5238bbb6db1e8d8cb92fbdca9a586381bf893..2515fd112c1b98a157d452fc65d42862396d3cc2 100644 (file)
@@ -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);
 
index 4a3aa1c55a8350660eed26a7cdef9d51d055a425..31eae256c6efc56d922e015c533f0986710268dd 100644 (file)
@@ -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
+}
+