Index: llvm/lib/Transforms/IPO/SCCP.cpp =================================================================== --- llvm/lib/Transforms/IPO/SCCP.cpp +++ llvm/lib/Transforms/IPO/SCCP.cpp @@ -212,10 +212,10 @@ LLVM_DEBUG(dbgs() << " BasicBlock Dead:" << BB); ++NumDeadBlocks; - MadeChanges = true; - - if (&BB != &F.front()) + if (&BB != &F.front()) { + MadeChanges = true; BlocksToErase.push_back(&BB); + } continue; } Index: llvm/lib/Transforms/Utils/SCCPSolver.cpp =================================================================== --- llvm/lib/Transforms/Utils/SCCPSolver.cpp +++ llvm/lib/Transforms/Utils/SCCPSolver.cpp @@ -235,10 +235,8 @@ for (Instruction &Inst : make_early_inc_range(BB)) { if (Inst.getType()->isVoidTy()) continue; - if (tryToReplaceWithConstant(&Inst)) { - if (canRemoveInstruction(&Inst)) - Inst.eraseFromParent(); - + if (tryToReplaceWithConstant(&Inst) && canRemoveInstruction(&Inst)) { + Inst.eraseFromParent(); MadeChanges = true; ++InstRemovedStat; } else if (replaceSignedInst(*this, InsertedValues, Inst)) {