From 52d83e66ee881f85d8a2ccac0183766a6386bfc9 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 3 Aug 2005 21:36:09 +0000 Subject: [PATCH] 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 :( git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22632 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LoopStrengthReduce.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 33714a2ad20..7b1168e0b48 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -149,7 +149,8 @@ DeleteTriviallyDeadInstructions(std::set &Insts) { for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) if (Instruction *U = dyn_cast(I->getOperand(i))) Insts.insert(U); - I->getParent()->getInstList().erase(I); + SE->deleteInstructionFromRecords(I); + I->eraseFromParent(); Changed = true; } } @@ -661,6 +662,7 @@ void LoopStrengthReduce::runOnLoop(Loop *L) { DeadInsts.insert(BO); // Break the cycle, then delete the PHI. PN->replaceAllUsesWith(UndefValue::get(PN->getType())); + SE->deleteInstructionFromRecords(PN); PN->eraseFromParent(); } } -- 2.34.1