diff --git a/llvm/include/llvm/Passes/PassBuilder.h b/llvm/include/llvm/Passes/PassBuilder.h --- a/llvm/include/llvm/Passes/PassBuilder.h +++ b/llvm/include/llvm/Passes/PassBuilder.h @@ -460,6 +460,9 @@ /// 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 --- 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 @@ 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 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -1882,6 +1882,10 @@ // results from `GlobalsAA` through a readonly proxy. AA.registerModuleAnalysis(); + // Add target-specific alias analyses. + if (TM) + TM->registerAliasAnalyses(AA); + return AA; }