[PATCH] D63706: [InlineCost] Fix bug 42084: remember negative result when computing full inline cost
Yevgeny Rouban via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 24 02:54:57 PDT 2019
yrouban created this revision.
yrouban added reviewers: fedor.sergeev, xbolva00, chandlerc, haicheng, eraman.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
yrouban set the repository for this revision to rG LLVM Github Monorepo.
This is a minimal fix for the bug https://bugs.llvm.org/show_bug.cgi?id=42084 extracted from the patch D63058 <https://reviews.llvm.org/D63058>.
The rest of D63058 <https://reviews.llvm.org/D63058> could be treated as a feature.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D63706
Files:
llvm/lib/Analysis/InlineCost.cpp
llvm/test/Transforms/Inline/inline_negative_result.ll
Index: llvm/test/Transforms/Inline/inline_negative_result.ll
===================================================================
--- llvm/test/Transforms/Inline/inline_negative_result.ll
+++ llvm/test/Transforms/Inline/inline_negative_result.ll
@@ -1,14 +1,17 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -inline -S | FileCheck %s
+; RUN: opt < %s -inline -S -inline-remark-attribute | FileCheck %s
+; RUN: opt < %s -inline -S -inline-remark-attribute --pass-remarks-missed=inline --pass-remarks-analysis=inline --pass-remarks=inline | FileCheck %s
+; RUN: opt < %s -inline -S -inline-remark-attribute -inline-cost-full=true | FileCheck %s
+; RUN: opt < %s -inline -S -inline-remark-attribute -inline-cost-full=false | FileCheck %s
; PR42084
+; The test checks that inline remarks do not change inline decisions.
define internal fastcc void @func4() {
; CHECK-LABEL: @func4(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[FOR_COND:%.*]]
; CHECK: for.cond:
-; CHECK-NEXT: tail call void (...) @g()
+; CHECK-NEXT: tail call void (...) @g() [[INLINE_REMARK0:#[0-9]+]]
; CHECK-NEXT: br label [[FOR_COND]]
;
entry:
@@ -22,7 +25,7 @@
define internal fastcc void @func3() {
; CHECK-LABEL: @func3(
; CHECK-NEXT: entry:
-; CHECK-NEXT: tail call fastcc void @func4()
+; CHECK-NEXT: tail call fastcc void @func4() [[INLINE_REMARK1:#[0-9]+]]
; CHECK-NEXT: unreachable
;
entry:
@@ -33,7 +36,7 @@
define internal fastcc void @func2() {
; CHECK-LABEL: @func2(
; CHECK-NEXT: entry:
-; CHECK-NEXT: tail call fastcc void @func3()
+; CHECK-NEXT: tail call fastcc void @func3() [[INLINE_REMARK1:#[0-9]+]]
; CHECK-NEXT: unreachable
;
entry:
@@ -44,7 +47,7 @@
define internal fastcc void @func1() {
; CHECK-LABEL: @func1(
; CHECK-NEXT: entry:
-; CHECK-NEXT: tail call fastcc void @func2()
+; CHECK-NEXT: tail call fastcc void @func2() [[INLINE_REMARK1:#[0-9]+]]
; CHECK-NEXT: unreachable
;
entry:
@@ -55,7 +58,7 @@
define i32 @main() {
; CHECK-LABEL: @main(
; CHECK-NEXT: entry:
-; CHECK-NEXT: tail call fastcc void @func1()
+; CHECK-NEXT: tail call fastcc void @func1() [[INLINE_REMARK1:#[0-9]+]]
; CHECK-NEXT: unreachable
;
entry:
@@ -64,3 +67,6 @@
}
declare void @g(...)
+
+; CHECK: attributes [[INLINE_REMARK0]] = { "inline-remark"="unavailable definition" }
+; CHECK: attributes [[INLINE_REMARK1]] = { "inline-remark"="(cost=0, threshold=0)" }
Index: llvm/lib/Analysis/InlineCost.cpp
===================================================================
--- llvm/lib/Analysis/InlineCost.cpp
+++ llvm/lib/Analysis/InlineCost.cpp
@@ -1580,6 +1580,8 @@
InlineResult
CallAnalyzer::analyzeBlock(BasicBlock *BB,
SmallPtrSetImpl<const Value *> &EphValues) {
+ bool Result = true;
+
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
// FIXME: Currently, the number of instructions in a function regardless of
// our ability to simplify them during inline to constants or dead code,
@@ -1654,11 +1656,14 @@
// Check if we've passed the maximum possible threshold so we don't spin in
// huge basic blocks that will never inline.
- if (Cost >= Threshold && !ComputeFullInlineCost)
- return false;
+ if (Cost >= Threshold) {
+ Result = false;
+ if (!ComputeFullInlineCost)
+ break;
+ }
}
- return true;
+ return Result;
}
/// Compute the base pointer and cumulative constant offsets for V.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63706.206175.patch
Type: text/x-patch
Size: 3529 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190624/a85bff8e/attachment.bin>
More information about the llvm-commits
mailing list