Skip to content

Commit 9ad0eaf

Browse files
committed
Address review comments
1 parent 7b358ed commit 9ad0eaf

File tree

2 files changed

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

2 files changed

+11
-12
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
#include "llvm/IR/ValueHandle.h"
2626
#include "llvm/Support/Allocator.h"
2727
#include "llvm/Support/Compiler.h"
28-
#include "llvm/Transforms/Utils/AssumeBundleBuilder.h"
29-
#include "llvm/Transforms/Utils/Local.h"
3028
#include <cstdint>
3129
#include <optional>
3230
#include <utility>
@@ -139,7 +137,7 @@ class GVNPass : public PassInfoMixin<GVNPass> {
139137

140138
/// This removes the specified instruction from
141139
/// our various maps and marks it for deletion.
142-
void doInstructionDeletion(Instruction *I);
140+
void salvageAndRemoveInstruction(Instruction *I);
143141

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

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#include "llvm/Support/Compiler.h"
7070
#include "llvm/Support/Debug.h"
7171
#include "llvm/Support/raw_ostream.h"
72+
#include "llvm/Transforms/Utils/AssumeBundleBuilder.h"
7273
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
7374
#include "llvm/Transforms/Utils/Local.h"
7475
#include "llvm/Transforms/Utils/SSAUpdater.h"
@@ -875,7 +876,7 @@ void GVNPass::printPipeline(
875876
OS << '>';
876877
}
877878

878-
void GVNPass::doInstructionDeletion(Instruction *I) {
879+
void GVNPass::salvageAndRemoveInstruction(Instruction *I) {
879880
salvageKnowledge(I, AC);
880881
salvageDebugInfo(*I);
881882
removeInstruction(I);
@@ -1580,7 +1581,7 @@ void GVNPass::eliminatePartiallyRedundantLoad(
15801581
return OptimizationRemark(DEBUG_TYPE, "LoadPRE", Load)
15811582
<< "load eliminated by PRE";
15821583
});
1583-
doInstructionDeletion(Load);
1584+
salvageAndRemoveInstruction(Load);
15841585
}
15851586

15861587
bool GVNPass::PerformLoadPRE(LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
@@ -1799,7 +1800,7 @@ bool GVNPass::PerformLoadPRE(LoadInst *Load, AvailValInBlkVect &ValuesPerBlock,
17991800
// Erase instructions generated by the failed PHI translation before
18001801
// trying to number them. PHI translation might insert instructions
18011802
// in basic blocks other than the current one, and we delete them
1802-
// directly, as doInstructionDeletion only allows removing from the
1803+
// directly, as salvageAndRemoveInstruction only allows removing from the
18031804
// current basic block.
18041805
NewInsts.pop_back_val()->eraseFromParent();
18051806
}
@@ -2000,7 +2001,7 @@ bool GVNPass::processNonLocalLoad(LoadInst *Load) {
20002001
MD->invalidateCachedPointerInfo(V);
20012002
++NumGVNLoad;
20022003
reportLoadElim(Load, V, ORE);
2003-
doInstructionDeletion(Load);
2004+
salvageAndRemoveInstruction(Load);
20042005
return true;
20052006
}
20062007

@@ -2068,7 +2069,7 @@ bool GVNPass::processAssumeIntrinsic(AssumeInst *IntrinsicI) {
20682069
}
20692070
}
20702071
if (isAssumeWithEmptyBundle(*IntrinsicI)) {
2071-
doInstructionDeletion(IntrinsicI);
2072+
salvageAndRemoveInstruction(IntrinsicI);
20722073
return true;
20732074
}
20742075
return false;
@@ -2179,7 +2180,7 @@ bool GVNPass::processLoad(LoadInst *L) {
21792180
return false;
21802181

21812182
if (L->use_empty()) {
2182-
doInstructionDeletion(L);
2183+
salvageAndRemoveInstruction(L);
21832184
return true;
21842185
}
21852186

@@ -2213,9 +2214,9 @@ bool GVNPass::processLoad(LoadInst *L) {
22132214
MSSAU->removeMemoryAccess(L);
22142215
++NumGVNLoad;
22152216
reportLoadElim(L, AvailableValue, ORE);
2217+
salvageAndRemoveInstruction(L);
22162218
// Tell MDA to reexamine the reused pointer since we might have more
22172219
// information after forwarding it.
2218-
doInstructionDeletion(L);
22192220
if (MD && AvailableValue->getType()->isPtrOrPtrVectorTy())
22202221
MD->invalidateCachedPointerInfo(AvailableValue);
22212222
return true;
@@ -2605,7 +2606,7 @@ bool GVNPass::processInstruction(Instruction *I) {
26052606
Changed = true;
26062607
}
26072608
if (isInstructionTriviallyDead(I, TLI)) {
2608-
doInstructionDeletion(I);
2609+
salvageAndRemoveInstruction(I);
26092610
Changed = true;
26102611
}
26112612
if (Changed) {
@@ -2722,7 +2723,7 @@ bool GVNPass::processInstruction(Instruction *I) {
27222723
patchAndReplaceAllUsesWith(I, Repl);
27232724
if (MD && Repl->getType()->isPtrOrPtrVectorTy())
27242725
MD->invalidateCachedPointerInfo(Repl);
2725-
doInstructionDeletion(I);
2726+
salvageAndRemoveInstruction(I);
27262727
return true;
27272728
}
27282729

0 commit comments

Comments
 (0)