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 ?