[llvm-commits] [dragonegg] r132845 - /dragonegg/trunk/src/Backend.cpp
Duncan Sands
baldrick at free.fr
Fri Jun 10 06:38:44 PDT 2011
Author: baldrick
Date: Fri Jun 10 08:38:44 2011
New Revision: 132845
URL: http://llvm.org/viewvc/llvm-project?rev=132845&view=rev
Log:
Make it easy to tweak the per-module and per-function optimization
levels individually.
Modified:
dragonegg/trunk/src/Backend.cpp
Modified: dragonegg/trunk/src/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Backend.cpp?rev=132845&r1=132844&r2=132845&view=diff
==============================================================================
--- dragonegg/trunk/src/Backend.cpp (original)
+++ dragonegg/trunk/src/Backend.cpp Fri Jun 10 08:38:44 2011
@@ -216,22 +216,16 @@
return CodeGenOpt::Aggressive;
}
-/// IROptLevel - The optimization level to be used by the IR level optimizers.
-static int IROptLevel() {
+/// PerFunctionOptLevel - The optimization level to be used by the per-function
+/// IR optimizers.
+static int PerFunctionOptLevel() {
return LLVMIROptimizeArg >= 0 ? LLVMIROptimizeArg : optimize;
}
-// GuessAtInliningThreshold - Figure out a reasonable threshold to pass llvm's
-// inliner. gcc has many options that control inlining, but we have decided
-// not to support anything like that for llvm-gcc.
-static unsigned GuessAtInliningThreshold() {
- if (optimize_size)
- // Reduce inline limit.
- return 75;
-
- if (IROptLevel() >= 3)
- return 275;
- return 225;
+/// ModuleOptLevel - The optimization level to be used by the module level IR
+/// optimizers.
+static int ModuleOptLevel() {
+ return LLVMIROptimizeArg >= 0 ? LLVMIROptimizeArg : optimize;
}
// SizeOfGlobalMatchesDecl - Whether the size of the given global value is the
@@ -519,7 +513,6 @@
InstallLanguageSettings();
// Configure the pass builder.
- PassBuilder.OptLevel = IROptLevel();
PassBuilder.SizeLevel = optimize_size;
PassBuilder.DisableSimplifyLibCalls = flag_no_simplify_libcalls;
PassBuilder.DisableUnrollLoops = !flag_unroll_loops;
@@ -561,6 +554,7 @@
PerFunctionPasses->add(createVerifierPass());
#endif
+ PassBuilder.OptLevel = PerFunctionOptLevel();
PassBuilder.populateFunctionPassManager(*PerFunctionPasses);
// If there are no module-level passes that have to be run, we codegen as
@@ -602,8 +596,18 @@
bool NeedAlwaysInliner = false;
llvm::Pass *InliningPass = 0;
if (flag_inline_small_functions && !flag_no_inline) {
- // Inline small functions.
- InliningPass = createFunctionInliningPass(GuessAtInliningThreshold());
+ // Inline small functions. Figure out a reasonable threshold to pass llvm's
+ // inliner. GCC has many options that control inlining, but we have decided
+ // not to support anything like that for dragonegg.
+ unsigned Threshold;
+ if (optimize_size)
+ // Reduce inline limit.
+ Threshold = 75;
+ else if (ModuleOptLevel() >= 3)
+ Threshold = 275;
+ else
+ Threshold = 225;
+ InliningPass = createFunctionInliningPass(Threshold);
} else {
// If full inliner is not run, check if always-inline is needed to handle
// functions that are marked as always_inline.
@@ -619,6 +623,7 @@
InliningPass = createAlwaysInlinerPass(); // Inline always_inline funcs
}
+ PassBuilder.OptLevel = ModuleOptLevel();
PassBuilder.Inliner = InliningPass;
PassBuilder.populateModulePassManager(*PerModulePasses);
More information about the llvm-commits
mailing list