diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index e2ca0ab1229..d63e7b0ddad 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -1057,8 +1057,16 @@ ImmutablePass *createExternalAAWrapperPass( /// 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 diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp index 8c06031fed8..a30aedc4060 100644 --- a/lib/Analysis/AliasAnalysis.cpp +++ b/lib/Analysis/AliasAnalysis.cpp @@ -563,3 +563,14 @@ bool llvm::isIdentifiedObject(const Value *V) { bool llvm::isIdentifiedFunctionLocal(const Value *V) { return isa(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(); + AU.addUsedIfAvailable(); + AU.addUsedIfAvailable(); + AU.addUsedIfAvailable(); + AU.addUsedIfAvailable(); +} diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index 0e05129b526..51eb36434f9 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -68,6 +68,7 @@ namespace { void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired(); AU.addRequired(); + addUsedAAAnalyses(AU); CallGraphSCCPass::getAnalysisUsage(AU); } diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp index 527fdd1885a..b84620c4811 100644 --- a/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/lib/Transforms/IPO/FunctionAttrs.cpp @@ -64,6 +64,7 @@ struct PostOrderFunctionAttrs : public CallGraphSCCPass { AU.setPreservesCFG(); AU.addRequired(); AU.addRequired(); + addUsedAAAnalyses(AU); CallGraphSCCPass::getAnalysisUsage(AU); } diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index bdef4733906..a02d85a6263 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -58,6 +58,7 @@ Inliner::Inliner(char &ID, bool InsertLifetime) void Inliner::getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); AU.addRequired(); + addUsedAAAnalyses(AU); CallGraphSCCPass::getAnalysisUsage(AU); } diff --git a/test/Analysis/alias-analysis-uses.ll b/test/Analysis/alias-analysis-uses.ll new file mode 100644 index 00000000000..4163ec25584 --- /dev/null +++ b/test/Analysis/alias-analysis-uses.ll @@ -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 +}