[llvm] r263211 - [PM/AA] Teach the AAManager how to handle module analyses in addition to
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 11 01:15:12 PST 2016
Author: chandlerc
Date: Fri Mar 11 03:15:11 2016
New Revision: 263211
URL: http://llvm.org/viewvc/llvm-project?rev=263211&view=rev
Log:
[PM/AA] Teach the AAManager how to handle module analyses in addition to
function analyses, and use it to wire up globals-aa to the new pass
manager.
Modified:
llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
llvm/trunk/include/llvm/Analysis/GlobalsModRef.h
llvm/trunk/lib/Analysis/GlobalsModRef.cpp
llvm/trunk/lib/Passes/PassBuilder.cpp
llvm/trunk/lib/Passes/PassRegistry.def
llvm/trunk/test/Analysis/GlobalsModRef/aliastest.ll
llvm/trunk/test/Analysis/GlobalsModRef/indirect-global.ll
Modified: llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/AliasAnalysis.h?rev=263211&r1=263210&r2=263211&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/AliasAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/AliasAnalysis.h Fri Mar 11 03:15:11 2016
@@ -845,27 +845,30 @@ public:
// This type hase value semantics. We have to spell these out because MSVC
// won't synthesize them.
AAManager() {}
- AAManager(AAManager &&Arg)
- : FunctionResultGetters(std::move(Arg.FunctionResultGetters)) {}
- AAManager(const AAManager &Arg)
- : FunctionResultGetters(Arg.FunctionResultGetters) {}
+ AAManager(AAManager &&Arg) : ResultGetters(std::move(Arg.ResultGetters)) {}
+ AAManager(const AAManager &Arg) : ResultGetters(Arg.ResultGetters) {}
AAManager &operator=(AAManager &&RHS) {
- FunctionResultGetters = std::move(RHS.FunctionResultGetters);
+ ResultGetters = std::move(RHS.ResultGetters);
return *this;
}
AAManager &operator=(const AAManager &RHS) {
- FunctionResultGetters = RHS.FunctionResultGetters;
+ ResultGetters = RHS.ResultGetters;
return *this;
}
/// Register a specific AA result.
template <typename AnalysisT> void registerFunctionAnalysis() {
- FunctionResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
+ ResultGetters.push_back(&getFunctionAAResultImpl<AnalysisT>);
+ }
+
+ /// Register a specific AA result.
+ template <typename AnalysisT> void registerModuleAnalysis() {
+ ResultGetters.push_back(&getModuleAAResultImpl<AnalysisT>);
}
Result run(Function &F, AnalysisManager<Function> *AM) {
Result R(AM->getResult<TargetLibraryAnalysis>(F));
- for (auto &Getter : FunctionResultGetters)
+ for (auto &Getter : ResultGetters)
(*Getter)(F, *AM, R);
return R;
}
@@ -873,7 +876,7 @@ public:
private:
SmallVector<void (*)(Function &F, AnalysisManager<Function> &AM,
AAResults &AAResults),
- 4> FunctionResultGetters;
+ 4> ResultGetters;
template <typename AnalysisT>
static void getFunctionAAResultImpl(Function &F,
@@ -881,6 +884,15 @@ private:
AAResults &AAResults) {
AAResults.addAAResult(AM.template getResult<AnalysisT>(F));
}
+
+ template <typename AnalysisT>
+ static void getModuleAAResultImpl(Function &F, AnalysisManager<Function> &AM,
+ AAResults &AAResults) {
+ auto &MAM =
+ AM.getResult<ModuleAnalysisManagerFunctionProxy>(F).getManager();
+ if (auto *R = MAM.template getCachedResult<AnalysisT>(*F.getParent()))
+ AAResults.addAAResult(*R);
+ }
};
extern template class AnalysisBase<AAManager>;
Modified: llvm/trunk/include/llvm/Analysis/GlobalsModRef.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/GlobalsModRef.h?rev=263211&r1=263210&r2=263211&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/GlobalsModRef.h (original)
+++ llvm/trunk/include/llvm/Analysis/GlobalsModRef.h Fri Mar 11 03:15:11 2016
@@ -77,6 +77,7 @@ class GlobalsAAResult : public AAResultB
public:
GlobalsAAResult(GlobalsAAResult &&Arg);
+ ~GlobalsAAResult();
static GlobalsAAResult analyzeModule(Module &M, const TargetLibraryInfo &TLI,
CallGraph &CG);
Modified: llvm/trunk/lib/Analysis/GlobalsModRef.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/GlobalsModRef.cpp?rev=263211&r1=263210&r2=263211&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/GlobalsModRef.cpp (original)
+++ llvm/trunk/lib/Analysis/GlobalsModRef.cpp Fri Mar 11 03:15:11 2016
@@ -917,6 +917,8 @@ GlobalsAAResult::GlobalsAAResult(Globals
}
}
+GlobalsAAResult::~GlobalsAAResult() {}
+
/*static*/ GlobalsAAResult
GlobalsAAResult::analyzeModule(Module &M, const TargetLibraryInfo &TLI,
CallGraph &CG) {
Modified: llvm/trunk/lib/Passes/PassBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Passes/PassBuilder.cpp?rev=263211&r1=263210&r2=263211&view=diff
==============================================================================
--- llvm/trunk/lib/Passes/PassBuilder.cpp (original)
+++ llvm/trunk/lib/Passes/PassBuilder.cpp Fri Mar 11 03:15:11 2016
@@ -25,6 +25,7 @@
#include "llvm/Analysis/CGSCCPassManager.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/DominanceFrontier.h"
+#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/LazyCallGraph.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/MemoryDependenceAnalysis.h"
@@ -337,6 +338,12 @@ bool PassBuilder::parseLoopPassName(Loop
}
bool PassBuilder::parseAAPassName(AAManager &AA, StringRef Name) {
+#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
+ if (Name == NAME) { \
+ AA.registerModuleAnalysis< \
+ std::remove_reference<decltype(CREATE_PASS)>::type>(); \
+ return true; \
+ }
#define FUNCTION_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
if (Name == NAME) { \
AA.registerFunctionAnalysis< \
Modified: llvm/trunk/lib/Passes/PassRegistry.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Passes/PassRegistry.def?rev=263211&r1=263210&r2=263211&view=diff
==============================================================================
--- llvm/trunk/lib/Passes/PassRegistry.def (original)
+++ llvm/trunk/lib/Passes/PassRegistry.def Fri Mar 11 03:15:11 2016
@@ -23,6 +23,13 @@ MODULE_ANALYSIS("callgraph", CallGraphAn
MODULE_ANALYSIS("lcg", LazyCallGraphAnalysis())
MODULE_ANALYSIS("no-op-module", NoOpModuleAnalysis())
MODULE_ANALYSIS("targetlibinfo", TargetLibraryAnalysis())
+
+#ifndef MODULE_ALIAS_ANALYSIS
+#define MODULE_ALIAS_ANALYSIS(NAME, CREATE_PASS) \
+ MODULE_ANALYSIS(NAME, CREATE_PASS)
+#endif
+MODULE_ALIAS_ANALYSIS("globals-aa", GlobalsAA())
+#undef MODULE_ALIAS_ANALYSIS
#undef MODULE_ANALYSIS
#ifndef MODULE_PASS
Modified: llvm/trunk/test/Analysis/GlobalsModRef/aliastest.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/GlobalsModRef/aliastest.ll?rev=263211&r1=263210&r2=263211&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/GlobalsModRef/aliastest.ll (original)
+++ llvm/trunk/test/Analysis/GlobalsModRef/aliastest.ll Fri Mar 11 03:15:11 2016
@@ -1,4 +1,5 @@
; RUN: opt < %s -basicaa -globals-aa -gvn -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
+; RUN: opt < %s -aa-pipeline=basic-aa,globals-aa -passes="require<globals-aa>,function(gvn)" -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
;
; Note that this test relies on an unsafe feature of GlobalsModRef. While this
; test is correct and safe, GMR's technique for handling this isn't generally.
Modified: llvm/trunk/test/Analysis/GlobalsModRef/indirect-global.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/GlobalsModRef/indirect-global.ll?rev=263211&r1=263210&r2=263211&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/GlobalsModRef/indirect-global.ll (original)
+++ llvm/trunk/test/Analysis/GlobalsModRef/indirect-global.ll Fri Mar 11 03:15:11 2016
@@ -1,4 +1,5 @@
; RUN: opt < %s -basicaa -globals-aa -gvn -instcombine -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
+; RUN: opt < %s -aa-pipeline=basic-aa,globals-aa -passes="require<globals-aa>,function(gvn,instcombine)" -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
;
; Note that this test relies on an unsafe feature of GlobalsModRef. While this
; test is correct and safe, GMR's technique for handling this isn't generally.
More information about the llvm-commits
mailing list