Do not crash when deleing a region with a dead invoke instruction
authorChris Lattner <sabre@nondot.org>
Sat, 22 Nov 2003 02:13:08 +0000 (02:13 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 22 Nov 2003 02:13:08 +0000 (02:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10161 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/ADCE.cpp

index 4d7efd8ae4de0b0895079f3fa257d51fbac51770..a06e746b0e0ea24a5d096f7138a08402bb1f824b 100644 (file)
@@ -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 ?