summaryrefslogtreecommitdiff
path: root/tools/bugpoint
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-22 02:10:38 +0000
committerChris Lattner <sabre@nondot.org>2003-11-22 02:10:38 +0000
commit8bc098be0cce48dcc08fea746d28011cac79eef6 (patch)
treecc53a1c476689a87d0dc7f1c7f67d063f6e1a08d /tools/bugpoint
parent89eca9097dfdae6296d4f32b6b74e2362e5de686 (diff)
downloadllvm-8bc098be0cce48dcc08fea746d28011cac79eef6.tar.gz
llvm-8bc098be0cce48dcc08fea746d28011cac79eef6.tar.bz2
llvm-8bc098be0cce48dcc08fea746d28011cac79eef6.tar.xz
Do not crash when dealing with invoke and unwind instructions!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10160 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/bugpoint')
-rw-r--r--tools/bugpoint/CrashDebugger.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index 8c29ea226a..af64d7a9af 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -195,20 +195,23 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<BasicBlock*> &BBs) {
// 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