[IPO] Reorder parameters of InlineFunction (NFC)
authorKazu Hirata <kazu@google.com>
Tue, 20 Sep 2022 16:09:38 +0000 (09:09 -0700)
committerKazu Hirata <kazu@google.com>
Tue, 20 Sep 2022 16:09:38 +0000 (09:09 -0700)
With the recent addition of new parameter MergeAttributes (D134117),
callers need to specify several default parameters before getting to
specify the new parameter.

This patch reorders the parameters so that callers do not have to
specify as many default parameters.

Differential Revision: https://reviews.llvm.org/D134125

llvm/include/llvm/Transforms/Utils/Cloning.h
llvm/lib/Transforms/IPO/AlwaysInliner.cpp
llvm/lib/Transforms/IPO/Inliner.cpp
llvm/lib/Transforms/IPO/ModuleInliner.cpp
llvm/lib/Transforms/IPO/PartialInlining.cpp
llvm/lib/Transforms/IPO/SampleProfile.cpp
llvm/lib/Transforms/Utils/InlineFunction.cpp

index 31309a1..72276eb 100644 (file)
@@ -264,10 +264,10 @@ public:
 /// The callee's function attributes are merged into the callers' if
 /// MergeAttributes is set to true.
 InlineResult InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
+                            bool MergeAttributes = false,
                             AAResults *CalleeAAR = nullptr,
                             bool InsertLifetime = true,
-                            Function *ForwardVarArgsTo = nullptr,
-                            bool MergeAttributes = false);
+                            Function *ForwardVarArgsTo = nullptr);
 
 /// Clones a loop \p OrigLoop.  Returns the loop and the blocks in \p
 /// Blocks.
index 377f224..0928648 100644 (file)
@@ -70,10 +70,9 @@ PreservedAnalyses AlwaysInlinerPass::run(Module &M,
             &FAM.getResult<BlockFrequencyAnalysis>(*Caller),
             &FAM.getResult<BlockFrequencyAnalysis>(F));
 
-        InlineResult Res = InlineFunction(
-            *CB, IFI, &FAM.getResult<AAManager>(F), InsertLifetime,
-            /*ForwardVarArgsTo=*/nullptr,
-            /*MergeAttributes=*/true);
+        InlineResult Res =
+            InlineFunction(*CB, IFI, /*MergeAttributes=*/true,
+                           &FAM.getResult<AAManager>(F), InsertLifetime);
         if (!Res.isSuccess()) {
           ORE.emit([&]() {
             return OptimizationRemarkMissed(DEBUG_TYPE, "NotInlined", DLoc,
index d3390e0..ea462f4 100644 (file)
@@ -315,9 +315,9 @@ static InlineResult inlineCallIfPossible(
 
   // Try to inline the function.  Get the list of static allocas that were
   // inlined.
-  InlineResult IR = InlineFunction(CB, IFI, &AAR, InsertLifetime,
-                                   /*ForwardVarArgsTo=*/nullptr,
-                                   /*MergeAttributes=*/true);
+  InlineResult IR =
+      InlineFunction(CB, IFI,
+                     /*MergeAttributes=*/true, &AAR, InsertLifetime);
   if (!IR.isSuccess())
     return IR;
 
@@ -915,10 +915,8 @@ PreservedAnalyses InlinerPass::run(LazyCallGraph::SCC &InitialC,
           &FAM.getResult<BlockFrequencyAnalysis>(Callee));
 
       InlineResult IR =
-          InlineFunction(*CB, IFI, &FAM.getResult<AAManager>(*CB->getCaller()),
-                         /*InsertLifetime=*/true,
-                         /*ForwardVarArgsTo=*/nullptr,
-                         /*MergeAttributes=*/true);
+          InlineFunction(*CB, IFI, /*MergeAttributes=*/true,
+                         &FAM.getResult<AAManager>(*CB->getCaller()));
       if (!IR.isSuccess()) {
         Advice->recordUnsuccessfulInlining(IR);
         continue;
index 66c5731..ee38265 100644 (file)
@@ -218,10 +218,8 @@ PreservedAnalyses ModuleInlinerPass::run(Module &M,
         &FAM.getResult<BlockFrequencyAnalysis>(Callee));
 
     InlineResult IR =
-        InlineFunction(*CB, IFI, &FAM.getResult<AAManager>(*CB->getCaller()),
-                       /*InsertLifetime=*/true,
-                       /*ForwardVarArgsTo=*/nullptr,
-                       /*MergeAttributes=*/true);
+        InlineFunction(*CB, IFI, /*MergeAttributes=*/true,
+                       &FAM.getResult<AAManager>(*CB->getCaller()));
     if (!IR.isSuccess()) {
       Advice->recordUnsuccessfulInlining(IR);
       continue;
index 653addd..13e44cf 100644 (file)
@@ -1434,7 +1434,7 @@ bool PartialInlinerImpl::tryPartialInline(FunctionCloner &Cloner) {
     InlineFunctionInfo IFI(nullptr, GetAssumptionCache, &PSI);
     // We can only forward varargs when we outlined a single region, else we
     // bail on vararg functions.
-    if (!InlineFunction(*CB, IFI, nullptr, true,
+    if (!InlineFunction(*CB, IFI, /*MergeAttributes=*/false, nullptr, true,
                         (Cloner.ClonedOI ? Cloner.OutlinedFunctions.back().first
                                          : nullptr))
              .isSuccess())
index a326f23..bbdbabb 100644 (file)
@@ -1222,9 +1222,6 @@ bool SampleProfileLoader::tryInlineCandidate(
   InlineFunctionInfo IFI(nullptr, GetAC);
   IFI.UpdateProfile = false;
   InlineResult IR = InlineFunction(CB, IFI,
-                                   /*CalleeAAR=*/nullptr,
-                                   /*InsertLifetime=*/true,
-                                   /*ForwardVarArgsTo=*/nullptr,
                                    /*MergeAttributes=*/true);
   if (!IR.isSuccess())
     return false;
index 1ea73d1..cf7541f 100644 (file)
@@ -1784,10 +1784,10 @@ inlineRetainOrClaimRVCalls(CallBase &CB, objcarc::ARCInstKind RVCallKind,
 /// exists in the instruction stream.  Similarly this will inline a recursive
 /// function by one level.
 llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
+                                        bool MergeAttributes,
                                         AAResults *CalleeAAR,
                                         bool InsertLifetime,
-                                        Function *ForwardVarArgsTo,
-                                        bool MergeAttributes) {
+                                        Function *ForwardVarArgsTo) {
   assert(CB.getParent() && CB.getFunction() && "Instruction not in function!");
 
   // FIXME: we don't inline callbr yet.