summaryrefslogtreecommitdiffstats
path: root/llvm/tools/opt/opt.cpp
diff options
context:
space:
mode:
authorEli Bendersky <eliben@google.com>2014-03-12 16:12:36 +0000
committerEli Bendersky <eliben@google.com>2014-03-12 16:12:36 +0000
commit49f6565267c12c9da02a34f220d1190ae1c8aedb (patch)
tree4c4c29e187c24a7a11fd4e8426d78d412fbe44bb /llvm/tools/opt/opt.cpp
parent501eadb42919f8312a55d78455a44b39e16762ed (diff)
downloadbcm5719-llvm-49f6565267c12c9da02a34f220d1190ae1c8aedb.tar.gz
bcm5719-llvm-49f6565267c12c9da02a34f220d1190ae1c8aedb.zip
Move duplicated code into a helper function (exposed through overload).
There's a bit of duplicated "magic" code in opt.cpp and Clang's CodeGen that computes the inliner threshold from opt level and size opt level. This patch moves the code to a function that lives alongside the inliner itself, providing a convenient overload to the inliner creation. A separate patch can be committed to Clang to use this once it's committed to LLVM. Standalone tools that use the inlining pass can also avoid duplicating this code and fearing it will go out of sync. Note: this patch also restructures the conditinal logic of the computation to be cleaner. llvm-svn: 203669
Diffstat (limited to 'llvm/tools/opt/opt.cpp')
-rw-r--r--llvm/tools/opt/opt.cpp9
1 files changed, 1 insertions, 8 deletions
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index 14a40a4af76..4dd9544fc32 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/tools/opt/opt.cpp
@@ -210,14 +210,7 @@ static void AddOptimizationPasses(PassManagerBase &MPM,FunctionPassManager &FPM,
if (DisableInline) {
// No inlining pass
} else if (OptLevel > 1) {
- unsigned Threshold = 225;
- if (SizeLevel == 1) // -Os
- Threshold = 75;
- else if (SizeLevel == 2) // -Oz
- Threshold = 25;
- if (OptLevel > 2)
- Threshold = 275;
- Builder.Inliner = createFunctionInliningPass(Threshold);
+ Builder.Inliner = createFunctionInliningPass(OptLevel, SizeLevel);
} else {
Builder.Inliner = createAlwaysInlinerPass();
}
OpenPOWER on IntegriCloud