[llvm-branch-commits] [llvm] 76f4f42 - [NewPM] Add TargetMachine method to add alias analyses
Arthur Eubanks via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Dec 21 13:50:52 PST 2020
Author: Arthur Eubanks
Date: 2020-12-21T13:46:07-08:00
New Revision: 76f4f42ebaf9146da3603943bea7c52ca58ae692
URL: https://github.com/llvm/llvm-project/commit/76f4f42ebaf9146da3603943bea7c52ca58ae692
DIFF: https://github.com/llvm/llvm-project/commit/76f4f42ebaf9146da3603943bea7c52ca58ae692.diff
LOG: [NewPM] Add TargetMachine method to add alias analyses
AMDGPUTargetMachine::adjustPassManager() adds some alias analyses to the
legacy PM. We need a way to do the same for the new PM in order to port
AMDGPUTargetMachine::adjustPassManager() to the new PM.
Currently the new PM adds alias analyses by creating an AAManager via
PassBuilder and overriding the AAManager a PassManager uses via
FunctionAnalysisManager::registerPass().
We will continue to respect a custom AA pipeline that specifies an exact
AA pipeline to use, but for "default" we will now add alias analyses
that backends specify. Most uses of PassManager use the "default"
AAManager created by PassBuilder::buildDefaultAAPipeline(). Backends can
override the newly added TargetMachine::registerAliasAnalyses() to add custom
alias analyses.
Reviewed By: ychen
Differential Revision: https://reviews.llvm.org/D93261
Added:
Modified:
llvm/include/llvm/Passes/PassBuilder.h
llvm/include/llvm/Target/TargetMachine.h
llvm/lib/Passes/PassBuilder.cpp
Removed:
################################################################################
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<GlobalsAA>();
+ // Add target-specific alias analyses.
+ if (TM)
+ TM->registerAliasAnalyses(AA);
+
return AA;
}
More information about the llvm-branch-commits
mailing list