summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-05-05 15:47:43 +0000
committerChris Lattner <sabre@nondot.org>2005-05-05 15:47:43 +0000
commit807aa20f675882d250efc4cf10710c734a4fe31d (patch)
tree4d6d0b074d02af648ceb84a4da2d45b40bb8048e /llvm/lib/Transforms
parentfa58898845111a2ac6ad842e2970550249d8d076 (diff)
downloadbcm5719-llvm-807aa20f675882d250efc4cf10710c734a4fe31d.tar.gz
bcm5719-llvm-807aa20f675882d250efc4cf10710c734a4fe31d.zip
Fix a bug compimling Ruby, fixing this testcase:
LowerSetJmp/2005-05-05-OldUses.ll llvm-svn: 21696
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/LowerSetJmp.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/LowerSetJmp.cpp b/llvm/lib/Transforms/IPO/LowerSetJmp.cpp
index 266729d6ca5..3a86cb763ba 100644
--- a/llvm/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/llvm/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -272,9 +272,17 @@ void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
else
new UnwindInst(Inst);
- // Remove all insts after the branch/unwind inst.
- Inst->getParent()->getInstList().erase(Inst,
- Inst->getParent()->getInstList().end());
+ // Remove all insts after the branch/unwind inst. Go from back to front to
+ // avoid replaceAllUsesWith if possible.
+ BasicBlock *BB = Inst->getParent();
+ Instruction *Removed;
+ do {
+ Removed = &BB->back();
+ // If the removed instructions have any users, replace them now.
+ if (!Removed->use_empty())
+ Removed->replaceAllUsesWith(UndefValue::get(Removed->getType()));
+ Removed->eraseFromParent();
+ } while (Removed != Inst);
++LongJmpsTransformed;
}
OpenPOWER on IntegriCloud