Inform ScalarEvolutions that we're deleting Values.
authorNick Lewycky <nicholas@mxc.ca>
Wed, 6 Jun 2007 03:51:56 +0000 (03:51 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Wed, 6 Jun 2007 03:51:56 +0000 (03:51 +0000)
This is the obviously correct part of the fix for PR1487.

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

lib/Transforms/Scalar/IndVarSimplify.cpp

index 20eb3a85215dfb52afcd0fba2bef67628e3e39ea..8042d62581bfc1151e3847e5a2e6254c38bae343 100644 (file)
@@ -181,6 +181,7 @@ void IndVarSimplify::EliminatePointerRecurrence(PHINode *PN,
               GetElementPtrInst *NGEPI = new GetElementPtrInst(
                   NCE, Constant::getNullValue(Type::Int32Ty), NewAdd, 
                   GEPI->getName(), GEPI);
+              SE->deleteInstructionFromRecords(GEPI);
               GEPI->replaceAllUsesWith(NGEPI);
               GEPI->eraseFromParent();
               GEPI = NGEPI;
@@ -398,6 +399,7 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L) {
         // the PHI entirely.  This is safe, because the NewVal won't be variant
         // in the loop, so we don't need an LCSSA phi node anymore.
         if (NumPreds == 1) {
+          SE->deleteInstructionFromRecords(PN);
           PN->replaceAllUsesWith(ExitVal);
           PN->eraseFromParent();
           break;