[llvm] r260183 - Add an "addUsedAAAnalyses" helper function
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 8 17:21:58 PST 2016
Author: sanjoy
Date: Mon Feb 8 19:21:57 2016
New Revision: 260183
URL: http://llvm.org/viewvc/llvm-project?rev=260183&view=rev
Log:
Add an "addUsedAAAnalyses" helper function
Summary:
Passes that call `getAnalysisIfAvailable<T>` also need to call
`addUsedIfAvailable<T>` in `getAnalysisUsage` to indicate to the
legacy pass manager that it uses `T`. This contract was being
violated by passes that used `createLegacyPMAAResults`. This change
fixes this by exposing a helper in AliasAnalysis.h,
`addUsedAAAnalyses`, that is complementary to createLegacyPMAAResults
and does the right thing when called from `getAnalysisUsage`.
Reviewers: chandlerc
Subscribers: mcrosier, llvm-commits
Differential Revision: http://reviews.llvm.org/D17010
Added:
llvm/trunk/test/Analysis/alias-analysis-uses.ll
Modified:
llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
llvm/trunk/lib/Analysis/AliasAnalysis.cpp
llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/trunk/lib/Transforms/IPO/Inliner.cpp
Modified: llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/AliasAnalysis.h?rev=260183&r1=260182&r2=260183&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/AliasAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/AliasAnalysis.h Mon Feb 8 19:21:57 2016
@@ -1057,8 +1057,16 @@ ImmutablePass *createExternalAAWrapperPa
/// A helper for the legacy pass manager to create a \c AAResults
/// object populated to the best of our ability for a particular function when
/// inside of a \c ModulePass or a \c CallGraphSCCPass.
+///
+/// If a \c ModulePass or a \c CallGraphSCCPass calls \p
+/// createLegacyPMAAResults, it also needs to call \p addUsedAAAnalyses in \p
+/// getAnalysisUsage.
AAResults createLegacyPMAAResults(Pass &P, Function &F, BasicAAResult &BAR);
+/// A helper for the legacy pass manager to populate \p AU to add uses to make
+/// sure the analyses required by \p createLegacyPMAAResults are available.
+void addUsedAAAnalyses(AnalysisUsage &AU);
+
} // End llvm namespace
#endif
Modified: llvm/trunk/lib/Analysis/AliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasAnalysis.cpp?rev=260183&r1=260182&r2=260183&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/AliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasAnalysis.cpp Mon Feb 8 19:21:57 2016
@@ -563,3 +563,14 @@ bool llvm::isIdentifiedObject(const Valu
bool llvm::isIdentifiedFunctionLocal(const Value *V) {
return isa<AllocaInst>(V) || isNoAliasCall(V) || isNoAliasArgument(V);
}
+
+void llvm::addUsedAAAnalyses(AnalysisUsage &AU) {
+ // This function needs to be in sync with llvm::createLegacyPMAAResults -- if
+ // more alias analyses are added to llvm::createLegacyPMAAResults, they need
+ // to be added here also.
+ AU.addUsedIfAvailable<ScopedNoAliasAAWrapperPass>();
+ AU.addUsedIfAvailable<TypeBasedAAWrapperPass>();
+ AU.addUsedIfAvailable<objcarc::ObjCARCAAWrapperPass>();
+ AU.addUsedIfAvailable<GlobalsAAWrapperPass>();
+ AU.addUsedIfAvailable<CFLAAWrapperPass>();
+}
Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=260183&r1=260182&r2=260183&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Mon Feb 8 19:21:57 2016
@@ -68,6 +68,7 @@ namespace {
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<AssumptionCacheTracker>();
AU.addRequired<TargetLibraryInfoWrapperPass>();
+ addUsedAAAnalyses(AU);
CallGraphSCCPass::getAnalysisUsage(AU);
}
Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=260183&r1=260182&r2=260183&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Mon Feb 8 19:21:57 2016
@@ -64,6 +64,7 @@ struct PostOrderFunctionAttrs : public C
AU.setPreservesCFG();
AU.addRequired<AssumptionCacheTracker>();
AU.addRequired<TargetLibraryInfoWrapperPass>();
+ addUsedAAAnalyses(AU);
CallGraphSCCPass::getAnalysisUsage(AU);
}
Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=260183&r1=260182&r2=260183&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Mon Feb 8 19:21:57 2016
@@ -58,6 +58,7 @@ Inliner::Inliner(char &ID, bool InsertLi
void Inliner::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<AssumptionCacheTracker>();
AU.addRequired<TargetLibraryInfoWrapperPass>();
+ addUsedAAAnalyses(AU);
CallGraphSCCPass::getAnalysisUsage(AU);
}
Added: llvm/trunk/test/Analysis/alias-analysis-uses.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/alias-analysis-uses.ll?rev=260183&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/alias-analysis-uses.ll (added)
+++ llvm/trunk/test/Analysis/alias-analysis-uses.ll Mon Feb 8 19:21:57 2016
@@ -0,0 +1,10 @@
+; RUN: opt -debug-pass=Executions -globals-aa -functionattrs -disable-output < %s 2>&1 | FileCheck %s
+
+; CHECK: Executing Pass 'Globals Alias Analysis'
+; CHECK-NOT: Freeing Pass 'Globals Alias Analysis'
+; CHECK: Executing Pass 'Deduce function attributes'
+; CHECK: Freeing Pass 'Globals Alias Analysis'
+
+define void @test(i8* %p) {
+ ret void
+}
More information about the llvm-commits
mailing list