[PATCH] D121946: [AlwaysInliner] Emit inline remark only when successful

Ellis Hoag via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 17 15:38:47 PDT 2022


ellis updated this revision to Diff 416351.
ellis added a comment.

Extend the `always-inline-remark.ll` test case to match all the inlining remarks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121946/new/

https://reviews.llvm.org/D121946

Files:
  llvm/lib/Transforms/IPO/AlwaysInliner.cpp
  llvm/test/Transforms/Inline/always-inline-remark.ll


Index: llvm/test/Transforms/Inline/always-inline-remark.ll
===================================================================
--- llvm/test/Transforms/Inline/always-inline-remark.ll
+++ llvm/test/Transforms/Inline/always-inline-remark.ll
@@ -1,4 +1,4 @@
-; RUN: opt -passes="always-inline" -pass-remarks-missed=inline -S < %s 2>&1 | FileCheck %s
+; RUN: opt -passes="always-inline" -pass-remarks=inline -pass-remarks-missed=inline -S < %s 2>&1 | FileCheck %s --implicit-check-not="remark: "
 
 declare void @personalityFn1();
 declare void @personalityFn2();
@@ -12,9 +12,11 @@
 }
 
 define void @goo() personality void ()* @personalityFn2 {
-    ; CHECK-DAG: 'bar' is not inlined into 'goo': incompatible personality
+    ; CHECK-DAG: remark: {{.*}}: 'bar' is not inlined into 'goo': incompatible personality
     call void @bar()
-    ; CHECK-DAG: 'foo' is not inlined into 'goo': unsupported operand bundle
+    ; CHECK-DAG: remark: {{.*}}: 'foo' is not inlined into 'goo': unsupported operand bundle
     call void @foo() [ "CUSTOM_OPERAND_BUNDLE"() ]
+    ; CHECK-DAG: remark: {{.*}}: 'foo' inlined into 'goo' with (cost=always): always inline attribute
+    call void @foo()
     ret void
 }
Index: llvm/lib/Transforms/IPO/AlwaysInliner.cpp
===================================================================
--- llvm/lib/Transforms/IPO/AlwaysInliner.cpp
+++ llvm/lib/Transforms/IPO/AlwaysInliner.cpp
@@ -68,17 +68,8 @@
       for (CallBase *CB : Calls) {
         Function *Caller = CB->getCaller();
         OptimizationRemarkEmitter ORE(Caller);
-        auto OIC = shouldInline(
-            *CB,
-            [&](CallBase &CB) {
-              return InlineCost::getAlways("always inline attribute");
-            },
-            ORE);
-        assert(OIC);
         DebugLoc DLoc = CB->getDebugLoc();
         BasicBlock *Block = CB->getParent();
-        emitInlinedIntoBasedOnCost(ORE, DLoc, Block, F, *Caller, *OIC, false,
-                                   DEBUG_TYPE);
 
         InlineFunctionInfo IFI(
             /*cg=*/nullptr, GetAssumptionCache, &PSI,
@@ -98,6 +89,11 @@
           continue;
         }
 
+        emitInlinedIntoBasedOnCost(
+            ORE, DLoc, Block, F, *Caller,
+            InlineCost::getAlways("always inline attribute"),
+            /*ForProfileContext=*/false, DEBUG_TYPE);
+
         // Merge the attributes based on the inlining.
         AttributeFuncs::mergeAttributesForInlining(*Caller, F);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121946.416351.patch
Type: text/x-patch
Size: 2454 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220317/d89a8039/attachment.bin>


More information about the llvm-commits mailing list