Skip to content

Commit 682a976

Browse files
authored
[AA] Change RunEarly to be a Boolean Flag in ExternalAAWrapper (#139158)
Change the previous runEarly virtual function in ExternalAAWrapper to be a boolean flag.
1 parent 81d48e0 commit 682a976

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

llvm/include/llvm/Analysis/AliasAnalysis.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,19 +1011,24 @@ struct ExternalAAWrapperPass : ImmutablePass {
10111011

10121012
ExternalAAWrapperPass();
10131013

1014-
explicit ExternalAAWrapperPass(CallbackT CB);
1014+
explicit ExternalAAWrapperPass(CallbackT CB, bool RunEarly = false);
10151015

1016-
/// Returns whether this external AA should run before Basic AA.
1016+
/// Flag indicating whether this external AA should run before Basic AA.
10171017
///
1018-
/// By default, external AA passes are run after Basic AA. If this returns
1019-
/// true, the external AA will be run before Basic AA during alias analysis.
1018+
/// This flag is for LegacyPassManager only. To run an external AA early
1019+
/// with the NewPassManager, override the registerEarlyDefaultAliasAnalyses
1020+
/// method on the target machine.
1021+
///
1022+
/// By default, external AA passes are run after Basic AA. If this flag is
1023+
/// set to true, the external AA will be run before Basic AA during alias
1024+
/// analysis.
10201025
///
10211026
/// For some targets, we prefer to run the external AA early to improve
10221027
/// compile time as it has more target-specific information. This is
10231028
/// particularly useful when the external AA can provide more precise results
10241029
/// than Basic AA so that Basic AA does not need to spend time recomputing
10251030
/// them.
1026-
virtual bool runEarly() { return false; }
1031+
bool RunEarly = false;
10271032

10281033
void getAnalysisUsage(AnalysisUsage &AU) const override {
10291034
AU.setPreservesAll();

llvm/lib/Analysis/AliasAnalysis.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,8 @@ AnalysisKey AAManager::Key;
693693

694694
ExternalAAWrapperPass::ExternalAAWrapperPass() : ImmutablePass(ID) {}
695695

696-
ExternalAAWrapperPass::ExternalAAWrapperPass(CallbackT CB)
697-
: ImmutablePass(ID), CB(std::move(CB)) {}
696+
ExternalAAWrapperPass::ExternalAAWrapperPass(CallbackT CB, bool RunEarly)
697+
: ImmutablePass(ID), CB(std::move(CB)), RunEarly(RunEarly) {}
698698

699699
char ExternalAAWrapperPass::ID = 0;
700700

@@ -741,7 +741,7 @@ bool AAResultsWrapperPass::runOnFunction(Function &F) {
741741

742742
// Add any target-specific alias analyses that should be run early.
743743
auto *ExtWrapperPass = getAnalysisIfAvailable<ExternalAAWrapperPass>();
744-
if (ExtWrapperPass && ExtWrapperPass->runEarly() && ExtWrapperPass->CB) {
744+
if (ExtWrapperPass && ExtWrapperPass->RunEarly && ExtWrapperPass->CB) {
745745
LLVM_DEBUG(dbgs() << "AAResults register Early ExternalAA: "
746746
<< ExtWrapperPass->getPassName() << "\n");
747747
ExtWrapperPass->CB(*this, F, *AAR);
@@ -777,7 +777,7 @@ bool AAResultsWrapperPass::runOnFunction(Function &F) {
777777

778778
// If available, run an external AA providing callback over the results as
779779
// well.
780-
if (ExtWrapperPass && !ExtWrapperPass->runEarly() && ExtWrapperPass->CB) {
780+
if (ExtWrapperPass && !ExtWrapperPass->RunEarly && ExtWrapperPass->CB) {
781781
LLVM_DEBUG(dbgs() << "AAResults register Late ExternalAA: "
782782
<< ExtWrapperPass->getPassName() << "\n");
783783
ExtWrapperPass->CB(*this, F, *AAR);

llvm/lib/Target/NVPTX/NVPTXAliasAnalysis.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ class NVPTXExternalAAWrapper : public ExternalAAWrapperPass {
9090
public:
9191
static char ID;
9292

93-
bool runEarly() override { return true; }
94-
9593
NVPTXExternalAAWrapper()
96-
: ExternalAAWrapperPass([](Pass &P, Function &, AAResults &AAR) {
97-
if (auto *WrapperPass =
98-
P.getAnalysisIfAvailable<NVPTXAAWrapperPass>())
99-
AAR.addAAResult(WrapperPass->getResult());
100-
}) {}
94+
: ExternalAAWrapperPass(
95+
[](Pass &P, Function &, AAResults &AAR) {
96+
if (auto *WrapperPass =
97+
P.getAnalysisIfAvailable<NVPTXAAWrapperPass>())
98+
AAR.addAAResult(WrapperPass->getResult());
99+
},
100+
/*RunEarly=*/true) {}
101101

102102
StringRef getPassName() const override {
103103
return "NVPTX Address space based Alias Analysis Wrapper";

0 commit comments

Comments
 (0)