fix some bugs (found by inspection) where LICM would not update
authorChris Lattner <sabre@nondot.org>
Sun, 29 Aug 2010 18:00:00 +0000 (18:00 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 29 Aug 2010 18:00:00 +0000 (18:00 +0000)
LICM correctly.  When sinking an instruction, it should not add
entries for the sunk instruction to the AST, it should remove
the entry for the sunk instruction.  The blocks being sunk to
are not in the loop, so their instructions shouldn't be in the
AST (yet)!

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

lib/Transforms/Scalar/LICM.cpp

index 44dfed8ed4ec1f74a3c4641425ea7b9648406b86..e6a8b2d572ea554f8be51d76fb9264303ed11409 100644 (file)
@@ -530,7 +530,6 @@ void LICM::sink(Instruction &I) {
       New = &I;
     } else {
       New = I.clone();
-      CurAST->copyValue(&I, New);
       if (!I.getName().empty())
         New->setName(I.getName()+".le");
       ExitBlock->getInstList().insert(InsertPt, New);
@@ -563,6 +562,9 @@ void LICM::sink(Instruction &I) {
   if (I.getType()->isPointerTy())
     for (unsigned i = 0, e = NewPHIs.size(); i != e; ++i)
       CurAST->copyValue(NewPHIs[i], &I);
+  
+  // Finally, remove the instruction from CurAST.  It is no longer in the loop.
+  CurAST->deleteValue(&I);
 }
 
 /// hoist - When an instruction is found to only use loop invariant operands