[llvm] 3bf703f - [AlwaysInliner] Emit optimization remarks
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 22:10:26 PDT 2020
Author: Arthur Eubanks
Date: 2020-09-21T22:09:28-07:00
New Revision: 3bf703fb6d55b23d29c792325a78cd3ead9ad07c
URL: https://github.com/llvm/llvm-project/commit/3bf703fb6d55b23d29c792325a78cd3ead9ad07c
DIFF: https://github.com/llvm/llvm-project/commit/3bf703fb6d55b23d29c792325a78cd3ead9ad07c.diff
LOG: [AlwaysInliner] Emit optimization remarks
To match the normal inliner in preparation for https://reviews.llvm.org/D86988.
Also change a FIXME to an assert.
Reviewed By: davidxl
Differential Revision: https://reviews.llvm.org/D88067
Added:
Modified:
llvm/lib/Transforms/IPO/AlwaysInliner.cpp
llvm/test/Transforms/Inline/optimization-remarks.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/AlwaysInliner.cpp b/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
index 53f9512f86f3..a9cf363ec98f 100644
--- a/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
+++ b/llvm/lib/Transforms/IPO/AlwaysInliner.cpp
@@ -54,12 +54,25 @@ PreservedAnalyses AlwaysInlinerPass::run(Module &M,
if (CB->getCalledFunction() == &F)
Calls.insert(CB);
- for (CallBase *CB : Calls)
- // FIXME: We really shouldn't be able to fail to inline at this point!
- // We should do something to log or check the inline failures here.
- Changed |=
- InlineFunction(*CB, IFI, /*CalleeAAR=*/nullptr, InsertLifetime)
- .isSuccess();
+ 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);
+ emitInlinedInto(ORE, CB->getDebugLoc(), CB->getParent(), F, *Caller,
+ *OIC, false, DEBUG_TYPE);
+
+ InlineResult Res =
+ InlineFunction(*CB, IFI, /*CalleeAAR=*/nullptr, InsertLifetime);
+ assert(Res.isSuccess() && "unexpected failure to inline");
+ (void)Res;
+ Changed = true;
+ }
// Remember to try and delete this function afterward. This both avoids
// re-walking the rest of the module and avoids dealing with any iterator
diff --git a/llvm/test/Transforms/Inline/optimization-remarks.ll b/llvm/test/Transforms/Inline/optimization-remarks.ll
index 1a15849a6823..6e94d1f9bb96 100644
--- a/llvm/test/Transforms/Inline/optimization-remarks.ll
+++ b/llvm/test/Transforms/Inline/optimization-remarks.ll
@@ -1,28 +1,35 @@
; RUN: opt < %s -inline -pass-remarks=inline -pass-remarks-missed=inline \
; RUN: -pass-remarks-analysis=inline -S 2>&1 | \
-; RUN: FileCheck -check-prefix=CHECK -check-prefix=NO_HOTNESS %s
+; RUN: FileCheck -check-prefixes=CHECK,NO_HOTNESS,ALWAYS %s
; RUN: opt < %s -inline -pass-remarks=inline -pass-remarks-missed=inline \
; RUN: -pass-remarks-analysis=inline -pass-remarks-with-hotness -S 2>&1 | \
-; RUN: FileCheck -check-prefix=CHECK -check-prefix=HOTNESS %s
+; RUN: FileCheck -check-prefixes=CHECK,HOTNESS,ALWAYS %s
+
+; RUN: opt < %s -passes=always-inline -pass-remarks=inline -pass-remarks-missed=inline \
+; RUN: -pass-remarks-analysis=inline -S 2>&1 | \
+; RUN: FileCheck -check-prefixes=ALWAYS %s
+; RUN: opt < %s -passes=always-inline -pass-remarks=inline -pass-remarks-missed=inline \
+; RUN: -pass-remarks-analysis=inline -pass-remarks-with-hotness -S 2>&1 | \
+; RUN: FileCheck -check-prefixes=ALWAYS %s
; RUN: opt < %s -passes=inline -pass-remarks=inline -pass-remarks-missed=inline \
; RUN: -pass-remarks-analysis=inline -S 2>&1 | \
-; RUN: FileCheck -check-prefix=CHECK -check-prefix=NO_HOTNESS %s
+; RUN: FileCheck -check-prefixes=CHECK,NO_HOTNESS,ALWAYS %s
; RUN: opt < %s -passes=inline -pass-remarks=inline -pass-remarks-missed=inline \
; RUN: -pass-remarks-analysis=inline -pass-remarks-with-hotness -S 2>&1 | \
-; RUN: FileCheck -check-prefix=CHECK -check-prefix=HOTNESS %s
+; RUN: FileCheck -check-prefixes=CHECK,HOTNESS,ALWAYS %s
; RUN: opt < %s -passes=inliner-wrapper -pass-remarks=inline -pass-remarks-missed=inline \
; RUN: -pass-remarks-analysis=inline -S 2>&1 | \
-; RUN: FileCheck -check-prefix=CHECK -check-prefix=NO_HOTNESS %s
+; RUN: FileCheck -check-prefixes=CHECK,NO_HOTNESS,ALWAYS %s
; RUN: opt < %s -passes=inliner-wrapper -pass-remarks=inline -pass-remarks-missed=inline \
; RUN: -pass-remarks-analysis=inline -pass-remarks-with-hotness -S 2>&1 | \
-; RUN: FileCheck -check-prefix=CHECK -check-prefix=HOTNESS %s
+; RUN: FileCheck -check-prefixes=CHECK,HOTNESS,ALWAYS %s
-; HOTNESS: fox will not be inlined into bar because its definition is unavailable
+; HOTNESS-DAG: fox will not be inlined into bar because its definition is unavailable
; NO_HOTNESS-NOT: fox will not be inlined into bar because its definition is unavailable
-; CHECK: foo inlined into bar with (cost=always): always inline attribute
-; CHECK: foz not inlined into bar because it should never be inlined (cost=never): noinline function attribute
+; ALWAYS-DAG: foo inlined into bar with (cost=always): always inline attribute
+; CHECK-DAG: foz not inlined into bar because it should never be inlined (cost=never): noinline function attribute
; Function Attrs: alwaysinline nounwind uwtable
define i32 @foo(i32 %x, i32 %y) #0 !prof !1 {
More information about the llvm-commits
mailing list