diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1312,9 +1312,6 @@ get##Ext##PluginInfo().RegisterPassBuilderCallbacks(PB); #include "llvm/Support/Extension.def" - // Register the AA manager first so that our version is the one used. - FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); }); - // Register the target library analysis directly and give it a customized // preset TLI. Triple TargetTriple(TheModule->getTargetTriple()); diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -251,18 +251,16 @@ TLII->disableAllFunctions(); FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); }); - AAManager AA; // Parse a custom AA pipeline if asked to. if (!Conf.AAPipeline.empty()) { + AAManager AA; if (auto Err = PB.parseAAPipeline(AA, Conf.AAPipeline)) { report_fatal_error(Twine("unable to parse AA pipeline description '") + Conf.AAPipeline + "': " + toString(std::move(Err))); } - } else { - AA = PB.buildDefaultAAPipeline(); + // Register the AA manager first so that our version is the one used. + FAM.registerPass([&] { return std::move(AA); }); } - // Register the AA manager first so that our version is the one used. - FAM.registerPass([&] { return std::move(AA); }); // Register all the basic analyses with the managers. PB.registerModuleAnalyses(MAM); diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -291,11 +291,6 @@ TLII->disableAllFunctions(); FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); }); - AAManager AA = PB.buildDefaultAAPipeline(); - - // Register the AA manager first so that our version is the one used. - FAM.registerPass([&] { return std::move(AA); }); - // Register all the basic analyses with the managers. PB.registerModuleAnalyses(MAM); PB.registerCGSCCAnalyses(CGAM); diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -413,6 +413,11 @@ } void PassBuilder::registerFunctionAnalyses(FunctionAnalysisManager &FAM) { + // We almost always want the default alias analysis pipeline. + // If a user wants a different one, they can register their own before calling + // registerFunctionAnalyses(). + FAM.registerPass([&] { return buildDefaultAAPipeline(); }); + #define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \ FAM.registerPass([&] { return CREATE_PASS; }); #include "PassRegistry.def" diff --git a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp --- a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp +++ b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp @@ -144,7 +144,6 @@ ModulePassManager MPM; ModuleAnalysisManager MAM; - FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); }); PB.registerModuleAnalyses(MAM); PB.registerCGSCCAnalyses(CGAM); PB.registerFunctionAnalyses(FAM);