[PATCH] D56409: [Inliner] Assert that the computed inline threshold is non-negative.

Easwaran Raman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 9 11:30:14 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL350751: [Inliner] Assert that the computed inline threshold is non-negative. (authored by eraman, committed by ).

Repository:
  rL LLVM

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

https://reviews.llvm.org/D56409

Files:
  llvm/trunk/lib/Analysis/InlineCost.cpp
  llvm/trunk/test/Transforms/Inline/inline-remark.ll


Index: llvm/trunk/test/Transforms/Inline/inline-remark.ll
===================================================================
--- llvm/trunk/test/Transforms/Inline/inline-remark.ll
+++ llvm/trunk/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 @@
 
 bb1:
   call void @foo()
+  call void @ext()
   ret void
 
 bb2:
@@ -43,6 +46,6 @@
   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={{.*}})" }
Index: llvm/trunk/lib/Analysis/InlineCost.cpp
===================================================================
--- llvm/trunk/lib/Analysis/InlineCost.cpp
+++ llvm/trunk/lib/Analysis/InlineCost.cpp
@@ -1731,6 +1731,13 @@
   // 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56409.180891.patch
Type: text/x-patch
Size: 1851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190109/bc628ad1/attachment.bin>


More information about the llvm-commits mailing list