summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO/LowerSetJmp.cpp
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
commit3987abdfe3d31b411b4e7eb7dd3724888a27b4ab (patch)
treecbfa263e07354c94e874ea46b2c1afd0f65ef9e0 /lib/Transforms/IPO/LowerSetJmp.cpp
parentac0630ff75c8bbcea3be24d945c37177f2403202 (diff)
downloadllvm-3987abdfe3d31b411b4e7eb7dd3724888a27b4ab.tar.gz
llvm-3987abdfe3d31b411b4e7eb7dd3724888a27b4ab.tar.bz2
llvm-3987abdfe3d31b411b4e7eb7dd3724888a27b4ab.tar.xz
Fix a bug compimling Ruby, fixing this testcase:
LowerSetJmp/2005-05-05-OldUses.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21696 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO/LowerSetJmp.cpp')
-rw-r--r--lib/Transforms/IPO/LowerSetJmp.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp
index 266729d6ca..3a86cb763b 100644
--- a/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/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;
}