[PATCH] D96197: [CSSPGO] Add switches to control prelink/postlink inline separately

Wenlei He via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 5 21:08:49 PST 2021


wenlei created this revision.
wenlei added reviewers: wmi, hoy, davidxl.
Herald added subscribers: modimo, lxfind, hiraditya, eraman.
wenlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

With CSSPGO, to maximize the benefit of global top-down context-sensitive inlining, we are experimenting with shifting more inlining from LTO prelink to postlink. The change adds switches to turn off prelink/postlink inlining separately. Note this is different from -fno-inline as the new switches only augment pass pipeline without changing inline attribute on functions.

Currently both switches are default to on so nothing changes by default, even with CSSPGO. We saw better performance on some benchmark with prelto inlining turned off, but there're other regressions too. Exposing the switch to help tuning.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96197

Files:
  llvm/lib/Transforms/IPO/Inliner.cpp
  llvm/lib/Transforms/IPO/SampleProfile.cpp


Index: llvm/lib/Transforms/IPO/SampleProfile.cpp
===================================================================
--- llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -177,6 +177,10 @@
              "order of call graph during sample profile loading. It only "
              "works for new pass manager. "));
 
+static cl::opt<bool> EnableSampleProfileInline(
+    "enable-sample-profile-inline", cl::Hidden, cl::init(true),
+    cl::desc("Enable Inlining from sample profile loader."));
+
 static cl::opt<bool> ProfileSizeInline(
     "sample-profile-inline-size", cl::Hidden, cl::init(false),
     cl::desc("Inline cold call sites in profile loader if it's beneficial "
@@ -1341,6 +1345,11 @@
 
 bool SampleProfileLoader::tryInlineCandidate(
     InlineCandidate &Candidate, SmallVector<CallBase *, 8> *InlinedCallSites) {
+  // Disable only the inlining part of sample profile loader, and still
+  // perform profile annotation, ICP as well as computing import GUIDs for
+  // ThinLTO's pre-link.
+  if (!EnableSampleProfileInline)
+    return false;
 
   CallBase &CB = *Candidate.CallInstr;
   Function *CalledFunction = CB.getCalledFunction();
Index: llvm/lib/Transforms/IPO/Inliner.cpp
===================================================================
--- llvm/lib/Transforms/IPO/Inliner.cpp
+++ llvm/lib/Transforms/IPO/Inliner.cpp
@@ -99,6 +99,10 @@
         "by inlining from cgscc inline remarks."),
     cl::Hidden);
 
+static cl::opt<bool>
+    EnableRegularCGSCCInline("enable-cgscc-inline", cl::init(true), cl::Hidden,
+                             cl::desc("Enable CGSCC Inlining"));
+
 LegacyInlinerBase::LegacyInlinerBase(char &ID) : CallGraphSCCPass(ID) {}
 
 LegacyInlinerBase::LegacyInlinerBase(char &ID, bool InsertLifetime)
@@ -1006,7 +1010,8 @@
   // because it makes profile annotation in the backend inaccurate.
   if (MandatoryFirst)
     PM.addPass(InlinerPass(/*OnlyMandatory*/ true));
-  PM.addPass(InlinerPass());
+  if (EnableRegularCGSCCInline)
+    PM.addPass(InlinerPass());
 }
 
 PreservedAnalyses ModuleInlinerWrapperPass::run(Module &M,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96197.321917.patch
Type: text/x-patch
Size: 2121 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210206/6171dc56/attachment.bin>


More information about the llvm-commits mailing list