[llvm-commits] CVS: llvm/tools/bugpoint/CrashDebugger.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Nov 21 20:11:01 PST 2003


Changes in directory llvm/tools/bugpoint:

CrashDebugger.cpp updated: 1.25 -> 1.26

---
Log message:

Do not crash when dealing with invoke and unwind instructions!


---
Diffs of the changes:  (+7 -4)

Index: llvm/tools/bugpoint/CrashDebugger.cpp
diff -u llvm/tools/bugpoint/CrashDebugger.cpp:1.25 llvm/tools/bugpoint/CrashDebugger.cpp:1.26
--- llvm/tools/bugpoint/CrashDebugger.cpp:1.25	Tue Nov 11 16:41:34 2003
+++ llvm/tools/bugpoint/CrashDebugger.cpp	Fri Nov 21 20:10:38 2003
@@ -195,20 +195,23 @@
   // Loop over and delete any hack up any blocks that are not listed...
   for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
     for (Function::iterator BB = I->begin(), E = I->end(); BB != E; ++BB)
-      if (!Blocks.count(BB) && !isa<ReturnInst>(BB->getTerminator())) {
+      if (!Blocks.count(BB) && BB->getTerminator()->getNumSuccessors()) {
         // Loop over all of the successors of this block, deleting any PHI nodes
         // that might include it.
         for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E; ++SI)
           (*SI)->removePredecessor(BB);
 
+        if (BB->getTerminator()->getType() != Type::VoidTy)
+          BB->getTerminator()->replaceAllUsesWith(
+                      Constant::getNullValue(BB->getTerminator()->getType()));
+
         // Delete the old terminator instruction...
         BB->getInstList().pop_back();
         
         // Add a new return instruction of the appropriate type...
         const Type *RetTy = BB->getParent()->getReturnType();
-        ReturnInst *RI = new ReturnInst(RetTy == Type::VoidTy ? 0 :
-                                        Constant::getNullValue(RetTy));
-        BB->getInstList().push_back(RI);
+        new ReturnInst(RetTy == Type::VoidTy ? 0 :
+                       Constant::getNullValue(RetTy), BB);
       }
 
   // The CFG Simplifier pass may delete one of the basic blocks we are





More information about the llvm-commits mailing list