]> granicus.if.org Git - llvm/commitdiff
Do not inline hot callsites for samplepgo in thinlto compile phase.
authorDehao Chen <dehao@google.com>
Tue, 21 Mar 2017 19:55:36 +0000 (19:55 +0000)
committerDehao Chen <dehao@google.com>
Tue, 21 Mar 2017 19:55:36 +0000 (19:55 +0000)
Summary: Because SamplePGO passes will be invoked twice in ThinLTO build: once at compile phase, the other at backend. We want to make sure the IR at the 2nd phase matches the hot part in profile, thus we do not want to inline hot callsites in the first phase.

Reviewers: tejohnson, eraman

Reviewed By: tejohnson

Subscribers: mehdi_amini, llvm-commits, Prazek

Differential Revision: https://reviews.llvm.org/D31201

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298428 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/IPO.h
lib/Analysis/InlineCost.cpp
lib/Transforms/IPO/InlineSimple.cpp
tools/bugpoint/bugpoint.cpp
tools/opt/opt.cpp

index eded0de9a8cd1d607fadf846b5fa127cf534edcd..9f374896095a6f7365dadf248425cfe96e15fa7e 100644 (file)
@@ -108,7 +108,8 @@ Pass *createFunctionImportPass();
 /// threshold given here.
 Pass *createFunctionInliningPass();
 Pass *createFunctionInliningPass(int Threshold);
-Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);
+Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel,
+                                 bool DisableInlineHotCallSite);
 Pass *createFunctionInliningPass(InlineParams &Params);
 
 //===----------------------------------------------------------------------===//
index 0789b8cee0ad4a05c3c35de437c4b1c297c13d10..ec14d1bf00324771425c2de51c5735192fe832f9 100644 (file)
@@ -670,7 +670,7 @@ void CallAnalyzer::updateThreshold(CallSite CS, Function &Callee) {
       BlockFrequencyInfo *CallerBFI = GetBFI ? &((*GetBFI)(*Caller)) : nullptr;
       if (PSI->isHotCallSite(CS, CallerBFI)) {
         DEBUG(dbgs() << "Hot callsite.\n");
-        Threshold = MaxIfValid(Threshold, Params.HotCallSiteThreshold);
+        Threshold = Params.HotCallSiteThreshold.getValue();
       } else if (PSI->isFunctionEntryHot(&Callee)) {
         DEBUG(dbgs() << "Hot callee.\n");
         // If callsite hotness can not be determined, we may still know
index 514baa810903a4a9993ee5f102d488e40bd4fd80..50e7cc89a3b32f2608418b72019db810dfebdf25 100644 (file)
@@ -93,8 +93,12 @@ Pass *llvm::createFunctionInliningPass(int Threshold) {
 }
 
 Pass *llvm::createFunctionInliningPass(unsigned OptLevel,
-                                       unsigned SizeOptLevel) {
-  return new SimpleInliner(llvm::getInlineParams(OptLevel, SizeOptLevel));
+                                       unsigned SizeOptLevel,
+                                       bool DisableInlineHotCallSite) {
+  auto Param = llvm::getInlineParams(OptLevel, SizeOptLevel);
+  if (DisableInlineHotCallSite)
+    Param.HotCallSiteThreshold = 0;
+  return new SimpleInliner(Param);
 }
 
 Pass *llvm::createFunctionInliningPass(InlineParams &Params) {
index a5de953b2b75bdaff7a98992ed8e0209f853274c..85c1ddd8277d9017331ef771f44c207354e1fc48 100644 (file)
@@ -181,7 +181,8 @@ int main(int argc, char **argv) {
     if (OptLevelO1)
       Builder.Inliner = createAlwaysInlinerLegacyPass();
     else if (OptLevelOs || OptLevelO2)
-      Builder.Inliner = createFunctionInliningPass(2, OptLevelOs ? 1 : 0);
+      Builder.Inliner = createFunctionInliningPass(
+          2, OptLevelOs ? 1 : 0, false);
     else
       Builder.Inliner = createFunctionInliningPass(275);
     Builder.populateFunctionPassManager(PM);
index e61bc915bf8c60aca6475651ac7b4c6c6c8c151f..48eda15bd1e3be96df7cffc1a552a1bceabf6ffb 100644 (file)
@@ -268,7 +268,7 @@ static void AddOptimizationPasses(legacy::PassManagerBase &MPM,
   if (DisableInline) {
     // No inlining pass
   } else if (OptLevel > 1) {
-    Builder.Inliner = createFunctionInliningPass(OptLevel, SizeLevel);
+    Builder.Inliner = createFunctionInliningPass(OptLevel, SizeLevel, false);
   } else {
     Builder.Inliner = createAlwaysInlinerLegacyPass();
   }