summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorEaswaran Raman <eraman@google.com>2019-01-09 19:26:17 +0000
committerEaswaran Raman <eraman@google.com>2019-01-09 19:26:17 +0000
commited279752f0d3cad126065566b7ae4a6f91c59d57 (patch)
treeec080c9d66b7a1214b952d32f6bf985128d42441 /llvm/lib/Analysis/InlineCost.cpp
parent64fb85c907e9e6db754c19de1c3539c80271fda5 (diff)
downloadbcm5719-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/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp7
1 files changed, 7 insertions, 0 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.
OpenPOWER on IntegriCloud