diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h index e2d22031dd5e..5a13df5b0c86 100644 --- a/llvm/include/llvm/Passes/PassBuilder.h +++ b/llvm/include/llvm/Passes/PassBuilder.h @@ -460,6 +460,9 @@ class PassBuilder { /// Build the default `AAManager` with the default alias analysis pipeline /// registered. + /// + /// This also adds target-specific alias analyses registered via + /// TargetMachine::registerAliasAnalyses(). AAManager buildDefaultAAPipeline(); /// Parse a textual pass pipeline description into a \c diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index d4fc2d8f0887..55b35d9c0d07 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -23,6 +23,7 @@ namespace llvm { +class AAManager; class Function; class GlobalValue; class MachineModuleInfoWrapperPass; @@ -322,6 +323,10 @@ class TargetMachine { virtual void registerPassBuilderCallbacks(PassBuilder &, bool DebugPassManager) {} + /// Allow the target to register alias analyses with the AAManager for use + /// with the new pass manager. Only affects the "default" AAManager. + virtual void registerAliasAnalyses(AAManager &) {} + /// Add passes to the specified pass manager to get the specified file /// emitted. Typically this will involve several steps of code generation. /// This method should return true if emission of this file type is not diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 4e8062c6a789..635e7bab1a7a 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -1882,6 +1882,10 @@ AAManager PassBuilder::buildDefaultAAPipeline() { // results from `GlobalsAA` through a readonly proxy. AA.registerModuleAnalysis(); + // Add target-specific alias analyses. + if (TM) + TM->registerAliasAnalyses(AA); + return AA; }