diff options
| author | Dehao Chen <dehao@google.com> | 2017-03-21 19:55:36 +0000 |
|---|---|---|
| committer | Dehao Chen <dehao@google.com> | 2017-03-21 19:55:36 +0000 |
| commit | 9907e9d860051d80b81fc2a0e9ddcb0ee98d5c72 (patch) | |
| tree | 30dfc5f2d0ef56661604e5af0f9f86cffd4f941a | |
| parent | f4bbdc2953920acf9a22da876b5e4d025667cded (diff) | |
| download | bcm5719-llvm-9907e9d860051d80b81fc2a0e9ddcb0ee98d5c72.tar.gz bcm5719-llvm-9907e9d860051d80b81fc2a0e9ddcb0ee98d5c72.zip | |
Do not inline hot callsites for samplepgo in thinlto compile phase.
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
llvm-svn: 298428
| -rw-r--r-- | llvm/include/llvm/Transforms/IPO.h | 3 | ||||
| -rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 2 | ||||
| -rw-r--r-- | llvm/lib/Transforms/IPO/InlineSimple.cpp | 8 | ||||
| -rw-r--r-- | llvm/tools/bugpoint/bugpoint.cpp | 3 | ||||
| -rw-r--r-- | llvm/tools/opt/opt.cpp | 2 |
5 files changed, 12 insertions, 6 deletions
diff --git a/llvm/include/llvm/Transforms/IPO.h b/llvm/include/llvm/Transforms/IPO.h index eded0de9a8c..9f374896095 100644 --- a/llvm/include/llvm/Transforms/IPO.h +++ b/llvm/include/llvm/Transforms/IPO.h @@ -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); //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index 0789b8cee0a..ec14d1bf003 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -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 diff --git a/llvm/lib/Transforms/IPO/InlineSimple.cpp b/llvm/lib/Transforms/IPO/InlineSimple.cpp index 514baa81090..50e7cc89a3b 100644 --- a/llvm/lib/Transforms/IPO/InlineSimple.cpp +++ b/llvm/lib/Transforms/IPO/InlineSimple.cpp @@ -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) { diff --git a/llvm/tools/bugpoint/bugpoint.cpp b/llvm/tools/bugpoint/bugpoint.cpp index a5de953b2b7..85c1ddd8277 100644 --- a/llvm/tools/bugpoint/bugpoint.cpp +++ b/llvm/tools/bugpoint/bugpoint.cpp @@ -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); diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index e61bc915bf8..48eda15bd1e 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -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(); } |

