[PATCH] D17010: Add an "addUsedAAAnalyses" helper function

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 8 17:26:19 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL260183: Add an "addUsedAAAnalyses" helper function (authored by sanjoy).

Changed prior to commit:
  http://reviews.llvm.org/D17010?vs=47273&id=47278#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17010

Files:
  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
  llvm/trunk/test/Analysis/alias-analysis-uses.ll

Index: llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
+++ llvm/trunk/include/llvm/Analysis/AliasAnalysis.h
@@ -1057,8 +1057,16 @@
 /// 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
Index: llvm/trunk/test/Analysis/alias-analysis-uses.ll
===================================================================
--- llvm/trunk/test/Analysis/alias-analysis-uses.ll
+++ llvm/trunk/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
+}
Index: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -64,6 +64,7 @@
     AU.setPreservesCFG();
     AU.addRequired<AssumptionCacheTracker>();
     AU.addRequired<TargetLibraryInfoWrapperPass>();
+    addUsedAAAnalyses(AU);
     CallGraphSCCPass::getAnalysisUsage(AU);
   }
 
Index: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp
@@ -58,6 +58,7 @@
 void Inliner::getAnalysisUsage(AnalysisUsage &AU) const {
   AU.addRequired<AssumptionCacheTracker>();
   AU.addRequired<TargetLibraryInfoWrapperPass>();
+  addUsedAAAnalyses(AU);
   CallGraphSCCPass::getAnalysisUsage(AU);
 }
 
Index: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
===================================================================
--- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -68,6 +68,7 @@
     void getAnalysisUsage(AnalysisUsage &AU) const override {
       AU.addRequired<AssumptionCacheTracker>();
       AU.addRequired<TargetLibraryInfoWrapperPass>();
+      addUsedAAAnalyses(AU);
       CallGraphSCCPass::getAnalysisUsage(AU);
     }
 
Index: llvm/trunk/lib/Analysis/AliasAnalysis.cpp
===================================================================
--- llvm/trunk/lib/Analysis/AliasAnalysis.cpp
+++ llvm/trunk/lib/Analysis/AliasAnalysis.cpp
@@ -563,3 +563,14 @@
 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>();
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17010.47278.patch
Type: text/x-patch
Size: 3829 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160209/09e01047/attachment-0001.bin>


More information about the llvm-commits mailing list