[PATCH] D128727: [ArgPromotion] Remove AARGetter

Pavel Samolysov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 28 06:35:12 PDT 2022


psamolysov created this revision.
psamolysov added reviewers: nikic, aeubanks.
psamolysov added a project: LLVM.
Herald added subscribers: ormris, hiraditya.
Herald added a project: All.
psamolysov requested review of this revision.
Herald added a subscriber: llvm-commits.

AARGetter is an abstraction over a source of the `AAResults` introduced
to support the legacy pass manager as well as the modern one. Since the
Argument Promotion pass doesn't support the legacy pass manager anymore,
the abstraction is not required and `AAResults` may be used directly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128727

Files:
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp


Index: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
===================================================================
--- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -756,7 +756,7 @@
 /// example, all callers are direct).  If safe to promote some arguments, it
 /// calls the DoPromotion method.
 static Function *
-promoteArguments(Function *F, function_ref<AAResults &(Function &F)> AARGetter,
+promoteArguments(Function *F, AAResults &AAR,
                  function_ref<DominatorTree &(Function &F)> DTGetter,
                  function_ref<AssumptionCache *(Function &F)> ACGetter,
                  unsigned MaxElements,
@@ -820,8 +820,6 @@
 
   const DataLayout &DL = F->getParent()->getDataLayout();
 
-  AAResults &AAR = AARGetter(*F);
-
   // Check to see which arguments are promotable.  If an argument is promotable,
   // add it to ArgsToPromote.
   DenseMap<Argument *, SmallVector<OffsetAndArgPart, 4>> ArgsToPromote;
@@ -877,13 +875,6 @@
     for (LazyCallGraph::Node &N : C) {
       Function &OldF = N.getFunction();
 
-      // FIXME: This lambda must only be used with this function. We should
-      // skip the lambda and just get the AA results directly.
-      auto AARGetter = [&](Function &F) -> AAResults & {
-        assert(&F == &OldF && "Called with an unexpected function!");
-        return FAM.getResult<AAManager>(F);
-      };
-
       auto DTGetter = [&](Function &F) -> DominatorTree & {
         assert(&F != &OldF && "Called with the obsolete function!");
         return FAM.getResult<DominatorTreeAnalysis>(F);
@@ -894,8 +885,9 @@
         return &FAM.getResult<AssumptionAnalysis>(F);
       };
 
+      auto &AAR = FAM.getResult<AAManager>(OldF);
       const auto &TTI = FAM.getResult<TargetIRAnalysis>(OldF);
-      Function *NewF = promoteArguments(&OldF, AARGetter, DTGetter, ACGetter,
+      Function *NewF = promoteArguments(&OldF, AAR, DTGetter, ACGetter,
                                         MaxElements, None, TTI, IsRecursive);
       if (!NewF)
         continue;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128727.440593.patch
Type: text/x-patch
Size: 2080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220628/a83e574e/attachment.bin>


More information about the llvm-commits mailing list