@@ -728,9 +728,8 @@ void GVNPass::ValueTable::erase(Value *V) {
728728// / verifyRemoved - Verify that the value is removed from all internal data
729729// / structures.
730730void GVNPass::ValueTable::verifyRemoved (const Value *V) const {
731- if (V != nullptr )
732- assert (!ValueNumbering.contains (V) &&
733- " Inst still occurs in value numbering map!" );
731+ assert (!ValueNumbering.contains (V) &&
732+ " Inst still occurs in value numbering map!" );
734733}
735734
736735// ===----------------------------------------------------------------------===//
@@ -877,6 +876,12 @@ void GVNPass::printPipeline(
877876 OS << ' >' ;
878877}
879878
879+ void GVNPass::doInstructionDeletion (Instruction *I) {
880+ salvageKnowledge (I, AC);
881+ salvageDebugInfo (*I);
882+ removeInstruction (I);
883+ }
884+
880885#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
881886LLVM_DUMP_METHOD void GVNPass::dump (DenseMap<uint32_t , Value *> &Map) const {
882887 errs () << " {\n " ;
@@ -1556,7 +1561,6 @@ void GVNPass::eliminatePartiallyRedundantLoad(
15561561 replaceValuesPerBlockEntry (ValuesPerBlock, OldLoad, NewLoad);
15571562 if (uint32_t ValNo = VN.lookup (OldLoad, false ))
15581563 LeaderTable.erase (ValNo, OldLoad, OldLoad->getParent ());
1559- VN.erase (OldLoad);
15601564 removeInstruction (OldLoad);
15611565 }
15621566 }
@@ -1995,9 +1999,9 @@ bool GVNPass::processNonLocalLoad(LoadInst *Load) {
19951999 I->setDebugLoc (Load->getDebugLoc ());
19962000 if (V->getType ()->isPtrOrPtrVectorTy ())
19972001 MD->invalidateCachedPointerInfo (V);
1998- doInstructionDeletion (Load);
19992002 ++NumGVNLoad;
20002003 reportLoadElim (Load, V, ORE);
2004+ doInstructionDeletion (Load);
20012005 return true ;
20022006 }
20032007
@@ -2809,7 +2813,6 @@ bool GVNPass::processBlock(BasicBlock *BB) {
28092813 SmallPtrSet<PHINode *, 8 > PHINodesToRemove;
28102814 ChangedFunction |= EliminateDuplicatePHINodes (BB, PHINodesToRemove);
28112815 for (PHINode *PN : PHINodesToRemove) {
2812- VN.erase (PN);
28132816 removeInstruction (PN);
28142817 }
28152818 for (Instruction &Inst : make_early_inc_range (*BB)) {
@@ -3022,7 +3025,6 @@ bool GVNPass::performScalarPRE(Instruction *CurInst) {
30223025 CurInst->replaceAllUsesWith (Phi);
30233026 if (MD && Phi->getType ()->isPtrOrPtrVectorTy ())
30243027 MD->invalidateCachedPointerInfo (Phi);
3025- VN.erase (CurInst);
30263028 LeaderTable.erase (ValNo, CurInst, CurrentBlock);
30273029
30283030 LLVM_DEBUG (dbgs () << " GVN PRE removed: " << *CurInst << ' \n ' );
@@ -3122,6 +3124,7 @@ void GVNPass::cleanupGlobalSets() {
31223124}
31233125
31243126void GVNPass::removeInstruction (Instruction *I) {
3127+ VN.erase (I);
31253128 if (MD) MD->removeInstruction (I);
31263129 if (MSSAU)
31273130 MSSAU->removeMemoryAccess (I);
0 commit comments