[llvm-commits] CVS: llvm/lib/Transforms/IPO/LowerSetJmp.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu May 5 08:47:55 PDT 2005



Changes in directory llvm/lib/Transforms/IPO:

LowerSetJmp.cpp updated: 1.24 -> 1.25
---
Log message:

Fix a bug compimling Ruby, fixing this testcase:
LowerSetJmp/2005-05-05-OldUses.ll


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

 LowerSetJmp.cpp |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)


Index: llvm/lib/Transforms/IPO/LowerSetJmp.cpp
diff -u llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.24 llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.25
--- llvm/lib/Transforms/IPO/LowerSetJmp.cpp:1.24	Thu Apr 21 18:39:37 2005
+++ llvm/lib/Transforms/IPO/LowerSetJmp.cpp	Thu May  5 10:47:43 2005
@@ -272,9 +272,17 @@
   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;
 }






More information about the llvm-commits mailing list