[PATCH] D23377: Add a new method to create SimpleInliner instance and make pre-inliner use this

Easwaran Raman via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 10 14:58:20 PDT 2016


eraman created this revision.
eraman added reviewers: chandlerc, xur.
eraman added subscribers: llvm-commits, davidxl.
Herald added a subscriber: mehdi_amini.

This adds a createFunctionInliningPass pass that takes an InlineParams object and use this to create the pre-inliner pass. This prevents the regular inliner's threshold flag from influencing the preinliner. We could make the callers of createFunctionInliningPass(Threshold) and createFunctionInliningPass(OptLevel, SizeOptLevel) use this instead, but I suppose we can't remove them because there may be other external users. 



https://reviews.llvm.org/D23377

Files:
  include/llvm/Transforms/IPO.h
  lib/Transforms/IPO/InlineSimple.cpp
  lib/Transforms/IPO/PassManagerBuilder.cpp

Index: lib/Transforms/IPO/PassManagerBuilder.cpp
===================================================================
--- lib/Transforms/IPO/PassManagerBuilder.cpp
+++ lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -19,6 +19,7 @@
 #include "llvm/Analysis/CFLAndersAliasAnalysis.h"
 #include "llvm/Analysis/CFLSteensAliasAnalysis.h"
 #include "llvm/Analysis/GlobalsModRef.h"
+#include "llvm/Analysis/InlineCost.h"
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Analysis/ScopedNoAliasAA.h"
 #include "llvm/Analysis/TargetLibraryInfo.h"
@@ -252,8 +253,20 @@
   // Perform the preinline and cleanup passes for O1 and above.
   // And avoid doing them if optimizing for size.
   if (OptLevel > 0 && SizeLevel == 0 && !DisablePreInliner) {
-    // Create preinline pass.
-    MPM.add(createFunctionInliningPass(PreInlineThreshold));
+    // Create preinline pass. We construct an InlineParams object and specify
+    // the threshold here to avoid the command line options of the regular
+    // inliner to influence pre-inlining. The only fields of InlineParams we
+    // care about are DefaultThreshold and HintThreshold. HotCallSiteThreshold
+    // is not relevant for pre-inlining as profile information is not yet
+    // attached to the IR.
+    InlineParams IP;
+    IP.DefaultThreshold = PreInlineThreshold;
+    IP.HotCallSiteThreshold = PreInlineThreshold;
+    // FIXME: The hint threshold has the same value used by the regular inliner.
+    // This should probably be lowered after performance testing.
+    IP.HintThreshold = 325;
+
+    MPM.add(createFunctionInliningPass(IP));
     MPM.add(createSROAPass());
     MPM.add(createEarlyCSEPass());             // Catch trivial redundancies
     MPM.add(createCFGSimplificationPass());    // Merge & remove BBs
Index: lib/Transforms/IPO/InlineSimple.cpp
===================================================================
--- lib/Transforms/IPO/InlineSimple.cpp
+++ lib/Transforms/IPO/InlineSimple.cpp
@@ -95,6 +95,10 @@
   return new SimpleInliner(llvm::getInlineParams(OptLevel, SizeOptLevel));
 }
 
+Pass *llvm::createFunctionInliningPass(InlineParams &Params) {
+  return new SimpleInliner(Params);
+}
+
 bool SimpleInliner::runOnSCC(CallGraphSCC &SCC) {
   TTIWP = &getAnalysis<TargetTransformInfoWrapperPass>();
   return Inliner::runOnSCC(SCC);
Index: include/llvm/Transforms/IPO.h
===================================================================
--- include/llvm/Transforms/IPO.h
+++ include/llvm/Transforms/IPO.h
@@ -20,6 +20,7 @@
 
 namespace llvm {
 
+class InlineParams;
 class StringRef;
 class ModuleSummaryIndex;
 class ModulePass;
@@ -103,6 +104,7 @@
 Pass *createFunctionInliningPass();
 Pass *createFunctionInliningPass(int Threshold);
 Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
+Pass *createFunctionInliningPass(InlineParams &Params);
 
 //===----------------------------------------------------------------------===//
 /// createAlwaysInlinerPass - Return a new pass object that inlines only


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23377.67612.patch
Type: text/x-patch
Size: 3008 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160810/e7b4b267/attachment.bin>


More information about the llvm-commits mailing list