aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2020-02-04 10:37:53 -0800
committerTeresa Johnson <tejohnson@google.com>2020-02-04 12:06:20 -0800
commit7f37a8026f6cfe51479309733be642102428fee4 (patch)
treebba16c88a756a3914ac35dcdc77b8b56186476b8 /llvm/lib/Analysis/InlineCost.cpp
parent5d2749938c4ec0b44fe3d63e355e3f31d8b4078f (diff)
downloadllvm-7f37a8026f6cfe51479309733be642102428fee4.zip
llvm-7f37a8026f6cfe51479309733be642102428fee4.tar.gz
llvm-7f37a8026f6cfe51479309733be642102428fee4.tar.bz2
[InlineCost] Add flag to allow changing the default inline cost
Summary: It can be useful to tune the default inline threshold without overriding other inlining thresholds (e.g. in code compiled for size). The existing `-inline-threshold` flag overrides other thresholds, so it is insufficient in codebases where there is a mix of code compiled for size and speed. Patch by Michael Holman <michael.holman@microsoft.com> Reviewers: eraman, tejohnson Reviewed By: tejohnson Subscribers: tejohnson, mtrofin, davidxl, hiraditya, haicheng, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73217
Diffstat (limited to 'llvm/lib/Analysis/InlineCost.cpp')
-rw-r--r--llvm/lib/Analysis/InlineCost.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 49014e8..98ece45 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -46,6 +46,11 @@ using namespace llvm;
STATISTIC(NumCallsAnalyzed, "Number of call sites analyzed");
+static cl::opt<int>
+ DefaultThreshold("inlinedefault-threshold", cl::Hidden, cl::init(225),
+ cl::ZeroOrMore,
+ cl::desc("Default amount of inlining to perform"));
+
static cl::opt<int> InlineThreshold(
"inline-threshold", cl::Hidden, cl::init(225), cl::ZeroOrMore,
cl::desc("Control the amount of inlining to perform (default = 225)"));
@@ -2303,7 +2308,7 @@ InlineParams llvm::getInlineParams(int Threshold) {
}
InlineParams llvm::getInlineParams() {
- return getInlineParams(InlineThreshold);
+ return getInlineParams(DefaultThreshold);
}
// Compute the default threshold for inlining based on the opt level and the
@@ -2316,7 +2321,7 @@ static int computeThresholdFromOptLevels(unsigned OptLevel,
return InlineConstants::OptSizeThreshold;
if (SizeOptLevel == 2) // -Oz
return InlineConstants::OptMinSizeThreshold;
- return InlineThreshold;
+ return DefaultThreshold;
}
InlineParams llvm::getInlineParams(unsigned OptLevel, unsigned SizeOptLevel) {