Index: lib/Transforms/Scalar/GVN.cpp =================================================================== --- lib/Transforms/Scalar/GVN.cpp +++ lib/Transforms/Scalar/GVN.cpp @@ -2077,12 +2077,12 @@ assert(I->getParent() == BB && "Removing instruction from wrong block?"); LLVM_DEBUG(dbgs() << "GVN removed: " << *I << '\n'); salvageDebugInfo(*I); + ICF->invalidateInstruction(I); if (MD) MD->removeInstruction(I); LLVM_DEBUG(verifyRemoved(I)); I->eraseFromParent(); } - ICF->invalidateBlock(BB); InstrsToErase.clear(); if (AtStart) @@ -2291,7 +2291,7 @@ LLVM_DEBUG(verifyRemoved(CurInst)); // FIXME: Intended to be markInstructionForDeletion(CurInst), but it causes // some assertion failures. - ICF->invalidateBlock(CurrentBlock); + ICF->invalidateInstruction(CurInst); CurInst->eraseFromParent(); ++NumGVNInstr;