[llvm] f6b5142 - [AlwaysInliner] Emit inline remark only when successful
Ellis Hoag via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 17 15:40:30 PDT 2022
Author: Ellis Hoag
Date: 2022-03-17T15:40:24-07:00
New Revision: f6b5142ac2e4c49b9eff4c22d699f464a6812feb
URL: https://github.com/llvm/llvm-project/commit/f6b5142ac2e4c49b9eff4c22d699f464a6812feb
DIFF: https://github.com/llvm/llvm-project/commit/f6b5142ac2e4c49b9eff4c22d699f464a6812feb.diff
LOG: [AlwaysInliner] Emit inline remark only when successful
Failures in `InlineFunction()` are caught after D121722, but `emitInlinedIntoBasedOnCost()` should only be called when inlining is successful. This also removes an unnecessary call to `shouldInline()` which always returned `InlineCost::getAlways()`.
Reviewed By: kyulee, nikic
Differential Revision: https://reviews.llvm.org/D121946
Added:
Modified:
llvm/lib/Transforms/IPO/AlwaysInliner.cpp
llvm/test/Transforms/Inline/always-inline-remark.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/AlwaysInliner.cpp b/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
index c7889a26e3058..7b016819acf1c 100644
--- a/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
+++ b/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
@@ -68,17 +68,8 @@ PreservedAnalyses AlwaysInlinerPass::run(Module &M,
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 @@ PreservedAnalyses AlwaysInlinerPass::run(Module &M,
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);
diff --git a/llvm/test/Transforms/Inline/always-inline-remark.ll b/llvm/test/Transforms/Inline/always-inline-remark.ll
index 294a00936878a..e328070589445 100644
--- a/llvm/test/Transforms/Inline/always-inline-remark.ll
+++ b/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 @bar() alwaysinline personality void ()* @personalityFn1 {
}
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
}
More information about the llvm-commits
mailing list