Skip to content

Commit 1331728

Browse files
committed
[NewPM] Use the default AA pipeline by default
We almost always want to use the default AA pipeline. It's very easy for users of PassBuilder to forget to customize the AAManager to use the default AA pipeline (for example, the NewPM C API forgets to do this). If somebody wants a custom AA pipeline, similar to what is being done now with the default AA pipeline registration, they can FAM.registerPass([&] { return std::move(MyAA); }); before calling PB.registerFunctionAnalyses(FAM); For example, LTOBackend.cpp and NewPMDriver.cpp do this. Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D113210
1 parent a2639dc commit 1331728

File tree

5 files changed

+8
-14
lines changed

5 files changed

+8
-14
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,9 +1312,6 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
13121312
get##Ext##PluginInfo().RegisterPassBuilderCallbacks(PB);
13131313
#include "llvm/Support/Extension.def"
13141314

1315-
// Register the AA manager first so that our version is the one used.
1316-
FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); });
1317-
13181315
// Register the target library analysis directly and give it a customized
13191316
// preset TLI.
13201317
Triple TargetTriple(TheModule->getTargetTriple());

llvm/lib/LTO/LTOBackend.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,16 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM,
251251
TLII->disableAllFunctions();
252252
FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); });
253253

254-
AAManager AA;
255254
// Parse a custom AA pipeline if asked to.
256255
if (!Conf.AAPipeline.empty()) {
256+
AAManager AA;
257257
if (auto Err = PB.parseAAPipeline(AA, Conf.AAPipeline)) {
258258
report_fatal_error(Twine("unable to parse AA pipeline description '") +
259259
Conf.AAPipeline + "': " + toString(std::move(Err)));
260260
}
261-
} else {
262-
AA = PB.buildDefaultAAPipeline();
261+
// Register the AA manager first so that our version is the one used.
262+
FAM.registerPass([&] { return std::move(AA); });
263263
}
264-
// Register the AA manager first so that our version is the one used.
265-
FAM.registerPass([&] { return std::move(AA); });
266264

267265
// Register all the basic analyses with the managers.
268266
PB.registerModuleAnalyses(MAM);

llvm/lib/LTO/ThinLTOCodeGenerator.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,6 @@ static void optimizeModuleNewPM(Module &TheModule, TargetMachine &TM,
291291
TLII->disableAllFunctions();
292292
FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); });
293293

294-
AAManager AA = PB.buildDefaultAAPipeline();
295-
296-
// Register the AA manager first so that our version is the one used.
297-
FAM.registerPass([&] { return std::move(AA); });
298-
299294
// Register all the basic analyses with the managers.
300295
PB.registerModuleAnalyses(MAM);
301296
PB.registerCGSCCAnalyses(CGAM);

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ void PassBuilder::registerCGSCCAnalyses(CGSCCAnalysisManager &CGAM) {
413413
}
414414

415415
void PassBuilder::registerFunctionAnalyses(FunctionAnalysisManager &FAM) {
416+
// We almost always want the default alias analysis pipeline.
417+
// If a user wants a different one, they can register their own before calling
418+
// registerFunctionAnalyses().
419+
FAM.registerPass([&] { return buildDefaultAAPipeline(); });
420+
416421
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
417422
FAM.registerPass([&] { return CREATE_PASS; });
418423
#include "PassRegistry.def"

llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
144144
ModulePassManager MPM;
145145
ModuleAnalysisManager MAM;
146146

147-
FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); });
148147
PB.registerModuleAnalyses(MAM);
149148
PB.registerCGSCCAnalyses(CGAM);
150149
PB.registerFunctionAnalyses(FAM);

0 commit comments

Comments
 (0)