diff options
| author | Easwaran Raman <eraman@google.com> | 2019-01-09 19:26:17 +0000 |
|---|---|---|
| committer | Easwaran Raman <eraman@google.com> | 2019-01-09 19:26:17 +0000 |
| commit | ed279752f0d3cad126065566b7ae4a6f91c59d57 (patch) | |
| tree | ec080c9d66b7a1214b952d32f6bf985128d42441 /llvm | |
| parent | 64fb85c907e9e6db754c19de1c3539c80271fda5 (diff) | |
| download | bcm5719-llvm-ed279752f0d3cad126065566b7ae4a6f91c59d57.tar.gz bcm5719-llvm-ed279752f0d3cad126065566b7ae4a6f91c59d57.zip | |
[Inliner] Assert that the computed inline threshold is non-negative.
Reviewers: chandlerc
Subscribers: haicheng, llvm-commits
Differential Revision: https://reviews.llvm.org/D56409
llvm-svn: 350751
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 7 | ||||
| -rw-r--r-- | llvm/test/Transforms/Inline/inline-remark.ll | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index a3347dbcb93..6ddb3cbc01a 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -1731,6 +1731,13 @@ InlineResult CallAnalyzer::analyzeCall(CallSite CS) { // Update the threshold based on callsite properties updateThreshold(CS, F); + // While Threshold depends on commandline options that can take negative + // values, we want to enforce the invariant that the computed threshold and + // bonuses are non-negative. + assert(Threshold >= 0); + assert(SingleBBBonus >= 0); + assert(VectorBonus >= 0); + // Speculatively apply all possible bonuses to Threshold. If cost exceeds // this Threshold any time, and cost cannot decrease, we can stop processing // the rest of the function body. diff --git a/llvm/test/Transforms/Inline/inline-remark.ll b/llvm/test/Transforms/Inline/inline-remark.ll index d436fa6f096..402493542dc 100644 --- a/llvm/test/Transforms/Inline/inline-remark.ll +++ b/llvm/test/Transforms/Inline/inline-remark.ll @@ -1,7 +1,9 @@ -; RUN: opt < %s -inline -inline-remark-attribute --inline-threshold=-2 -S | FileCheck %s +; RUN: opt < %s -inline -inline-remark-attribute --inline-threshold=0 -S | FileCheck %s ; Test that the inliner adds inline remark attributes to non-inlined callsites. +declare void @ext(); + define void @foo() { call void @bar(i1 true) ret void @@ -12,6 +14,7 @@ define void @bar(i1 %p) { bb1: call void @foo() + call void @ext() ret void bb2: @@ -43,6 +46,6 @@ define void @test2(i8*) { ret void } -; CHECK: attributes [[ATTR1]] = { "inline-remark"="(cost=-5, threshold=-6)" } +; CHECK: attributes [[ATTR1]] = { "inline-remark"="(cost=25, threshold=0)" } ; CHECK: attributes [[ATTR2]] = { "inline-remark"="(cost=never): recursive" } ; CHECK: attributes [[ATTR3]] = { "inline-remark"="unsupported operand bundle; (cost={{.*}}, threshold={{.*}})" } |

