@@ -727,9 +727,8 @@ void GVNPass::ValueTable::erase(Value *V) {
727
727
// / verifyRemoved - Verify that the value is removed from all internal data
728
728
// / structures.
729
729
void GVNPass::ValueTable::verifyRemoved (const Value *V) const {
730
- if (V != nullptr )
731
- assert (!ValueNumbering.contains (V) &&
732
- " Inst still occurs in value numbering map!" );
730
+ assert (!ValueNumbering.contains (V) &&
731
+ " Inst still occurs in value numbering map!" );
733
732
}
734
733
735
734
// ===----------------------------------------------------------------------===//
@@ -876,6 +875,12 @@ void GVNPass::printPipeline(
876
875
OS << ' >' ;
877
876
}
878
877
878
+ void GVNPass::doInstructionDeletion (Instruction *I) {
879
+ salvageKnowledge (I, AC);
880
+ salvageDebugInfo (*I);
881
+ removeInstruction (I);
882
+ }
883
+
879
884
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
880
885
LLVM_DUMP_METHOD void GVNPass::dump (DenseMap<uint32_t , Value *> &Map) const {
881
886
errs () << " {\n " ;
@@ -1555,7 +1560,6 @@ void GVNPass::eliminatePartiallyRedundantLoad(
1555
1560
replaceValuesPerBlockEntry (ValuesPerBlock, OldLoad, NewLoad);
1556
1561
if (uint32_t ValNo = VN.lookup (OldLoad, false ))
1557
1562
LeaderTable.erase (ValNo, OldLoad, OldLoad->getParent ());
1558
- VN.erase (OldLoad);
1559
1563
removeInstruction (OldLoad);
1560
1564
}
1561
1565
}
@@ -1994,9 +1998,9 @@ bool GVNPass::processNonLocalLoad(LoadInst *Load) {
1994
1998
I->setDebugLoc (Load->getDebugLoc ());
1995
1999
if (V->getType ()->isPtrOrPtrVectorTy ())
1996
2000
MD->invalidateCachedPointerInfo (V);
1997
- doInstructionDeletion (Load);
1998
2001
++NumGVNLoad;
1999
2002
reportLoadElim (Load, V, ORE);
2003
+ doInstructionDeletion (Load);
2000
2004
return true ;
2001
2005
}
2002
2006
@@ -2808,7 +2812,6 @@ bool GVNPass::processBlock(BasicBlock *BB) {
2808
2812
SmallPtrSet<PHINode *, 8 > PHINodesToRemove;
2809
2813
ChangedFunction |= EliminateDuplicatePHINodes (BB, PHINodesToRemove);
2810
2814
for (PHINode *PN : PHINodesToRemove) {
2811
- VN.erase (PN);
2812
2815
removeInstruction (PN);
2813
2816
}
2814
2817
for (Instruction &Inst : make_early_inc_range (*BB)) {
@@ -3021,7 +3024,6 @@ bool GVNPass::performScalarPRE(Instruction *CurInst) {
3021
3024
CurInst->replaceAllUsesWith (Phi);
3022
3025
if (MD && Phi->getType ()->isPtrOrPtrVectorTy ())
3023
3026
MD->invalidateCachedPointerInfo (Phi);
3024
- VN.erase (CurInst);
3025
3027
LeaderTable.erase (ValNo, CurInst, CurrentBlock);
3026
3028
3027
3029
LLVM_DEBUG (dbgs () << " GVN PRE removed: " << *CurInst << ' \n ' );
@@ -3121,6 +3123,7 @@ void GVNPass::cleanupGlobalSets() {
3121
3123
}
3122
3124
3123
3125
void GVNPass::removeInstruction (Instruction *I) {
3126
+ VN.erase (I);
3124
3127
if (MD) MD->removeInstruction (I);
3125
3128
if (MSSAU)
3126
3129
MSSAU->removeMemoryAccess (I);
0 commit comments