[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Aug 3 14:36:20 PDT 2005



Changes in directory llvm/lib/Transforms/Scalar:

LoopStrengthReduce.cpp updated: 1.22 -> 1.23
---
Log message:

Fix a nasty dangling pointer issue.  The ScalarEvolution pass would keep a
map from instruction* to SCEVHandles.  When we delete instructions, we have
to tell it about it.  We would run into nasty cases where new instructions
were reallocated at old instruction addresses and get the old map values.
Bad bad bad :(


---
Diffs of the changes:  (+3 -1)

 LoopStrengthReduce.cpp |    4 +++-
 1 files changed, 3 insertions(+), 1 deletion(-)


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.22 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.23
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.22	Mon Aug  1 22:31:14 2005
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Wed Aug  3 16:36:09 2005
@@ -149,7 +149,8 @@
       for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
         if (Instruction *U = dyn_cast<Instruction>(I->getOperand(i)))
           Insts.insert(U);
-      I->getParent()->getInstList().erase(I);
+      SE->deleteInstructionFromRecords(I);
+      I->eraseFromParent();
       Changed = true;
     }
   }
@@ -661,6 +662,7 @@
             DeadInsts.insert(BO);
             // Break the cycle, then delete the PHI.
             PN->replaceAllUsesWith(UndefValue::get(PN->getType()));
+            SE->deleteInstructionFromRecords(PN);
             PN->eraseFromParent();
           }
         }






More information about the llvm-commits mailing list