mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:19:43 +00:00
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 llvm-svn: 260183
This commit is contained in:
parent
5bf7895a5f
commit
ca2c8b410a
@ -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
|
||||
|
@ -563,3 +563,14 @@ bool llvm::isIdentifiedObject(const Value *V) {
|
||||
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>();
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ namespace {
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.addRequired<AssumptionCacheTracker>();
|
||||
AU.addRequired<TargetLibraryInfoWrapperPass>();
|
||||
addUsedAAAnalyses(AU);
|
||||
CallGraphSCCPass::getAnalysisUsage(AU);
|
||||
}
|
||||
|
||||
|
@ -64,6 +64,7 @@ struct PostOrderFunctionAttrs : public CallGraphSCCPass {
|
||||
AU.setPreservesCFG();
|
||||
AU.addRequired<AssumptionCacheTracker>();
|
||||
AU.addRequired<TargetLibraryInfoWrapperPass>();
|
||||
addUsedAAAnalyses(AU);
|
||||
CallGraphSCCPass::getAnalysisUsage(AU);
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,7 @@ Inliner::Inliner(char &ID, bool InsertLifetime)
|
||||
void Inliner::getAnalysisUsage(AnalysisUsage &AU) const {
|
||||
AU.addRequired<AssumptionCacheTracker>();
|
||||
AU.addRequired<TargetLibraryInfoWrapperPass>();
|
||||
addUsedAAAnalyses(AU);
|
||||
CallGraphSCCPass::getAnalysisUsage(AU);
|
||||
}
|
||||
|
||||
|
10
test/Analysis/alias-analysis-uses.ll
Normal file
10
test/Analysis/alias-analysis-uses.ll
Normal file
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user