From c8ecd22037d4e72ca8e3757c09095b830502cc5a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 22 Nov 2003 02:13:08 +0000 Subject: [PATCH] Do not crash when deleing a region with a dead invoke instruction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10161 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/ADCE.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 4d7efd8ae4d..a06e746b0e0 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -430,6 +430,10 @@ bool ADCE::doADCE() { } // Delete the old terminator instruction... + const Type *TermTy = BB->getTerminator()->getType(); + if (TermTy != Type::VoidTy) + BB->getTerminator()->replaceAllUsesWith( + Constant::getNullValue(TermTy)); BB->getInstList().pop_back(); const Type *RetTy = Func->getReturnType(); new ReturnInst(RetTy != Type::VoidTy ?