Skip to content

Commit 9a437c7

Browse files
committed
Address review comments
1 parent 352f36d commit 9a437c7

File tree

2 files changed

+9
-11
lines changed
  • llvm
    • include/llvm/Transforms/Scalar
    • lib/Transforms/Scalar

2 files changed

+9
-11
lines changed

llvm/include/llvm/Transforms/Scalar/GVN.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,7 @@ class GVNPass : public PassInfoMixin<GVNPass> {
139139

140140
/// This removes the specified instruction from
141141
/// our various maps and marks it for deletion.
142-
void doInstructionDeletion(Instruction *I) {
143-
salvageKnowledge(I, AC);
144-
salvageDebugInfo(*I);
145-
VN.erase(I);
146-
removeInstruction(I);
147-
}
142+
void doInstructionDeletion(Instruction *I);
148143

149144
DominatorTree &getDominatorTree() const { return *DT; }
150145
AAResults *getAliasAnalysis() const { return VN.getAliasAnalysis(); }

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,6 @@ void GVNPass::ValueTable::erase(Value *V) {
728728
/// verifyRemoved - Verify that the value is removed from all internal data
729729
/// structures.
730730
void GVNPass::ValueTable::verifyRemoved(const Value *V) const {
731-
if (V != nullptr)
732731
assert(!ValueNumbering.contains(V) &&
733732
"Inst still occurs in value numbering map!");
734733
}
@@ -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)
881886
LLVM_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

31243126
void GVNPass::removeInstruction(Instruction *I) {
3127+
VN.erase(I);
31253128
if (MD) MD->removeInstruction(I);
31263129
if (MSSAU)
31273130
MSSAU->removeMemoryAccess(I);

0 commit comments

Comments
 (0)