[PATCH] D34309: [NewPM/Inliner] Customize threshold based on optlevel and sizelevel
Easwaran Raman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 16 17:42:30 PDT 2017
eraman created this revision.
(Note: It will be cleaner to expose the OptimizationLevel enum to InlineCost and Inliner instead of mapping back from the enum to SizeLevel/OptLevel, but I don't know what is the right header file to move the enum into)
https://reviews.llvm.org/D34309
Files:
include/llvm/Transforms/IPO/Inliner.h
lib/Passes/PassBuilder.cpp
Index: lib/Passes/PassBuilder.cpp
===================================================================
--- lib/Passes/PassBuilder.cpp
+++ lib/Passes/PassBuilder.cpp
@@ -553,8 +553,9 @@
// Run the inliner first. The theory is that we are walking bottom-up and so
// the callees have already been fully optimized, and we want to inline them
// into the callers so that our optimizations can reflect that.
- // FIXME; Customize the threshold based on optimization level.
- MainCGPipeline.addPass(InlinerPass());
+ unsigned OptLevel = Level > O3 ? 2 : Level;
+ unsigned SizeLevel = Level > O3 ? Level - O3 : 0;
+ MainCGPipeline.addPass(InlinerPass(OptLevel, SizeLevel));
// Now deduce any function attributes based in the current code.
MainCGPipeline.addPass(PostOrderFunctionAttrsPass());
@@ -863,7 +864,10 @@
// valuable as the inliner doesn't currently care whether it is inlining an
// invoke or a call.
// Run the inliner now.
- MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(InlinerPass()));
+ unsigned OptLevel = Level > O3 ? 2 : Level;
+ unsigned SizeLevel = Level > O3 ? Level - O3 : 0;
+ MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(
+ InlinerPass(OptLevel, SizeLevel)));
// Optimize globals again after we ran the inliner.
MPM.addPass(GlobalOptPass());
Index: include/llvm/Transforms/IPO/Inliner.h
===================================================================
--- include/llvm/Transforms/IPO/Inliner.h
+++ include/llvm/Transforms/IPO/Inliner.h
@@ -96,6 +96,9 @@
InlinerPass(InlineParams Params = getInlineParams())
: Params(std::move(Params)) {}
+ InlinerPass(unsigned OptLevel, unsigned SizeLevel)
+ : InlinerPass(getInlineParams(OptLevel, SizeLevel)) {}
+
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
LazyCallGraph &CG, CGSCCUpdateResult &UR);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34309.102915.patch
Type: text/x-patch
Size: 1892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170617/400a4c4d/attachment.bin>
More information about the llvm-commits
mailing list