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