Skip to content

Commit 7b358ed

Browse files
committed
Address review comments
1 parent a54e0a5 commit 7b358ed

File tree

2 files changed

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

2 files changed

+11
-13
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: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,8 @@ void GVNPass::ValueTable::erase(Value *V) {
727727
/// verifyRemoved - Verify that the value is removed from all internal data
728728
/// structures.
729729
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!");
733732
}
734733

735734
//===----------------------------------------------------------------------===//
@@ -876,6 +875,12 @@ void GVNPass::printPipeline(
876875
OS << '>';
877876
}
878877

878+
void GVNPass::doInstructionDeletion(Instruction *I) {
879+
salvageKnowledge(I, AC);
880+
salvageDebugInfo(*I);
881+
removeInstruction(I);
882+
}
883+
879884
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
880885
LLVM_DUMP_METHOD void GVNPass::dump(DenseMap<uint32_t, Value *> &Map) const {
881886
errs() << "{\n";
@@ -1555,7 +1560,6 @@ void GVNPass::eliminatePartiallyRedundantLoad(
15551560
replaceValuesPerBlockEntry(ValuesPerBlock, OldLoad, NewLoad);
15561561
if (uint32_t ValNo = VN.lookup(OldLoad, false))
15571562
LeaderTable.erase(ValNo, OldLoad, OldLoad->getParent());
1558-
VN.erase(OldLoad);
15591563
removeInstruction(OldLoad);
15601564
}
15611565
}
@@ -1994,9 +1998,9 @@ bool GVNPass::processNonLocalLoad(LoadInst *Load) {
19941998
I->setDebugLoc(Load->getDebugLoc());
19951999
if (V->getType()->isPtrOrPtrVectorTy())
19962000
MD->invalidateCachedPointerInfo(V);
1997-
doInstructionDeletion(Load);
19982001
++NumGVNLoad;
19992002
reportLoadElim(Load, V, ORE);
2003+
doInstructionDeletion(Load);
20002004
return true;
20012005
}
20022006

@@ -2808,7 +2812,6 @@ bool GVNPass::processBlock(BasicBlock *BB) {
28082812
SmallPtrSet<PHINode *, 8> PHINodesToRemove;
28092813
ChangedFunction |= EliminateDuplicatePHINodes(BB, PHINodesToRemove);
28102814
for (PHINode *PN : PHINodesToRemove) {
2811-
VN.erase(PN);
28122815
removeInstruction(PN);
28132816
}
28142817
for (Instruction &Inst : make_early_inc_range(*BB)) {
@@ -3021,7 +3024,6 @@ bool GVNPass::performScalarPRE(Instruction *CurInst) {
30213024
CurInst->replaceAllUsesWith(Phi);
30223025
if (MD && Phi->getType()->isPtrOrPtrVectorTy())
30233026
MD->invalidateCachedPointerInfo(Phi);
3024-
VN.erase(CurInst);
30253027
LeaderTable.erase(ValNo, CurInst, CurrentBlock);
30263028

30273029
LLVM_DEBUG(dbgs() << "GVN PRE removed: " << *CurInst << '\n');
@@ -3121,6 +3123,7 @@ void GVNPass::cleanupGlobalSets() {
31213123
}
31223124

31233125
void GVNPass::removeInstruction(Instruction *I) {
3126+
VN.erase(I);
31243127
if (MD) MD->removeInstruction(I);
31253128
if (MSSAU)
31263129
MSSAU->removeMemoryAccess(I);

0 commit comments

Comments
 (0)