[llvm-branch-commits] [llvm-branch] r113823 - in /llvm/branches/release_28: ./ lib/Transforms/Scalar/LICM.cpp test/Transforms/LICM/crash.ll

Bill Wendling isanbard at gmail.com
Mon Sep 13 17:43:35 PDT 2010


Author: void
Date: Mon Sep 13 19:43:35 2010
New Revision: 113823

URL: http://llvm.org/viewvc/llvm-project?rev=113823&view=rev
Log:
Approved by Chris:

$ svn merge -c 113820 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r113820 into '.':
U    test/Transforms/LICM/crash.ll
U    lib/Transforms/Scalar/LICM.cpp

Log:
fix PR8102, a case where we'd copyValue from a value that we already
deleted.  Fix this by doing the copyValue's before we delete stuff!


Modified:
    llvm/branches/release_28/   (props changed)
    llvm/branches/release_28/lib/Transforms/Scalar/LICM.cpp
    llvm/branches/release_28/test/Transforms/LICM/crash.ll

Propchange: llvm/branches/release_28/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Sep 13 19:43:35 2010
@@ -1,2 +1,2 @@
 /llvm/branches/Apple/Pertwee:110850,110961
-/llvm/trunk:113109,113123,113146,113158,113255,113257,113260,113297,113299,113303,113322,113345,113365-113366,113394,113483-113485,113576,113637
+/llvm/trunk:113109,113123,113146,113158,113255,113257,113260,113297,113299,113303,113322,113345,113365-113366,113394,113483-113485,113576,113637,113820

Modified: llvm/branches/release_28/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_28/lib/Transforms/Scalar/LICM.cpp?rev=113823&r1=113822&r2=113823&view=diff
==============================================================================
--- llvm/branches/release_28/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/branches/release_28/lib/Transforms/Scalar/LICM.cpp Mon Sep 13 19:43:35 2010
@@ -852,6 +852,17 @@
     ReplacedLoads[ALoad] = NewVal;
   }
   
+  // If the preheader load is itself a pointer, we need to tell alias analysis
+  // about the new pointer we created in the preheader block and about any PHI
+  // nodes that just got inserted.
+  if (PreheaderLoad->getType()->isPointerTy()) {
+    // Copy any value stored to or loaded from a must-alias of the pointer.
+    CurAST->copyValue(SomeValue, PreheaderLoad);
+    
+    for (unsigned i = 0, e = NewPHIs.size(); i != e; ++i)
+      CurAST->copyValue(SomeValue, NewPHIs[i]);
+  }
+  
   // Now that everything is rewritten, delete the old instructions from the body
   // of the loop.  They should all be dead now.
   for (unsigned i = 0, e = LoopUses.size(); i != e; ++i) {
@@ -882,17 +893,6 @@
     User->eraseFromParent();
   }
   
-  // If the preheader load is itself a pointer, we need to tell alias analysis
-  // about the new pointer we created in the preheader block and about any PHI
-  // nodes that just got inserted.
-  if (PreheaderLoad->getType()->isPointerTy()) {
-    // Copy any value stored to or loaded from a must-alias of the pointer.
-    CurAST->copyValue(SomeValue, PreheaderLoad);
-
-    for (unsigned i = 0, e = NewPHIs.size(); i != e; ++i)
-      CurAST->copyValue(SomeValue, NewPHIs[i]);
-  }
-  
   // fwew, we're done!
 }
 

Modified: llvm/branches/release_28/test/Transforms/LICM/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_28/test/Transforms/LICM/crash.ll?rev=113823&r1=113822&r2=113823&view=diff
==============================================================================
--- llvm/branches/release_28/test/Transforms/LICM/crash.ll (original)
+++ llvm/branches/release_28/test/Transforms/LICM/crash.ll Mon Sep 13 19:43:35 2010
@@ -39,3 +39,23 @@
   store i32 undef, i32* @g_8, align 4
   br label %for.body
 }
+
+; PR8102
+define void @test3() {
+entry:
+  %__first = alloca { i32* }
+  br i1 undef, label %for.cond, label %for.end
+
+for.cond:                                         ; preds = %for.cond, %entry
+  %tmp1 = getelementptr { i32*}* %__first, i32 0, i32 0
+  %tmp2 = load i32** %tmp1, align 4
+  %call = tail call i32* @test3helper(i32* %tmp2)
+  %tmp3 = getelementptr { i32*}* %__first, i32 0, i32 0
+  store i32* %call, i32** %tmp3, align 4
+  br i1 false, label %for.cond, label %for.end
+
+for.end:                                          ; preds = %for.cond, %entry
+  ret void
+}
+
+declare i32* @test3helper(i32*)





More information about the llvm-branch-commits mailing list