mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
[CSSPGO] Tweak ICP threshold in top-down inliner
This change slightly relaxed the current ICP threshold in top-down inliner, specifically always allow one ICP for it. It shows some perf improvements on SPEC and our internal benchmarks. Also renamed the previous flag. We can also try to turn off PGO ICP in the future. Reviewed By: wenlei, hoy, wmi Differential Revision: https://reviews.llvm.org/D106588
This commit is contained in:
parent
4ce16022d3
commit
eca1a76d00
@ -197,12 +197,17 @@ cl::opt<int> SampleColdCallSiteThreshold(
|
|||||||
"sample-profile-cold-inline-threshold", cl::Hidden, cl::init(45),
|
"sample-profile-cold-inline-threshold", cl::Hidden, cl::init(45),
|
||||||
cl::desc("Threshold for inlining cold callsites"));
|
cl::desc("Threshold for inlining cold callsites"));
|
||||||
|
|
||||||
static cl::opt<int> ProfileICPThreshold(
|
static cl::opt<unsigned> ProfileICPRelativeHotness(
|
||||||
"sample-profile-icp-threshold", cl::Hidden, cl::init(5),
|
"sample-profile-icp-relative-hotness", cl::Hidden, cl::init(25),
|
||||||
cl::desc(
|
cl::desc(
|
||||||
"Relative hotness threshold for indirect "
|
"Relative hotness percentage threshold for indirect "
|
||||||
"call promotion in proirity-based sample profile loader inlining."));
|
"call promotion in proirity-based sample profile loader inlining."));
|
||||||
|
|
||||||
|
static cl::opt<unsigned> ProfileICPRelativeHotnessSkip(
|
||||||
|
"sample-profile-icp-relative-hotness-skip", cl::Hidden, cl::init(1),
|
||||||
|
cl::desc(
|
||||||
|
"Skip relative hotness check for ICP up to given number of targets."));
|
||||||
|
|
||||||
static cl::opt<bool> CallsitePrioritizedInline(
|
static cl::opt<bool> CallsitePrioritizedInline(
|
||||||
"sample-profile-prioritized-inline", cl::Hidden, cl::ZeroOrMore,
|
"sample-profile-prioritized-inline", cl::Hidden, cl::ZeroOrMore,
|
||||||
cl::init(false),
|
cl::init(false),
|
||||||
@ -1348,6 +1353,7 @@ bool SampleProfileLoader::inlineHotFunctionsWithPriority(
|
|||||||
auto CalleeSamples = findIndirectCallFunctionSamples(*I, Sum);
|
auto CalleeSamples = findIndirectCallFunctionSamples(*I, Sum);
|
||||||
uint64_t SumOrigin = Sum;
|
uint64_t SumOrigin = Sum;
|
||||||
Sum *= Candidate.CallsiteDistribution;
|
Sum *= Candidate.CallsiteDistribution;
|
||||||
|
unsigned ICPCount = 0;
|
||||||
for (const auto *FS : CalleeSamples) {
|
for (const auto *FS : CalleeSamples) {
|
||||||
// TODO: Consider disable pre-lTO ICP for MonoLTO as well
|
// TODO: Consider disable pre-lTO ICP for MonoLTO as well
|
||||||
if (LTOPhase == ThinOrFullLTOPhase::ThinLTOPreLink) {
|
if (LTOPhase == ThinOrFullLTOPhase::ThinLTOPreLink) {
|
||||||
@ -1361,7 +1367,8 @@ bool SampleProfileLoader::inlineHotFunctionsWithPriority(
|
|||||||
// ICP isn't introducing excessive speculative checks even if individual
|
// ICP isn't introducing excessive speculative checks even if individual
|
||||||
// target looks beneficial to promote and inline. That means we should
|
// target looks beneficial to promote and inline. That means we should
|
||||||
// only do ICP when there's a small number dominant targets.
|
// only do ICP when there's a small number dominant targets.
|
||||||
if (EntryCountDistributed < SumOrigin / ProfileICPThreshold)
|
if (ICPCount >= ProfileICPRelativeHotnessSkip &&
|
||||||
|
EntryCountDistributed * 100 < SumOrigin * ProfileICPRelativeHotness)
|
||||||
break;
|
break;
|
||||||
// TODO: Fix CallAnalyzer to handle all indirect calls.
|
// TODO: Fix CallAnalyzer to handle all indirect calls.
|
||||||
// For indirect call, we don't run CallAnalyzer to get InlineCost
|
// For indirect call, we don't run CallAnalyzer to get InlineCost
|
||||||
@ -1383,6 +1390,7 @@ bool SampleProfileLoader::inlineHotFunctionsWithPriority(
|
|||||||
if (getInlineCandidate(&NewCandidate, CB))
|
if (getInlineCandidate(&NewCandidate, CB))
|
||||||
CQueue.emplace(NewCandidate);
|
CQueue.emplace(NewCandidate);
|
||||||
}
|
}
|
||||||
|
ICPCount++;
|
||||||
Changed = true;
|
Changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/indirect-call-csspgo.prof -sample-profile-icp-threshold=100 -pass-remarks=sample-profile -S -o /dev/null 2>&1 | FileCheck -check-prefix=ICP-ALL %s
|
; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/indirect-call-csspgo.prof -sample-profile-icp-relative-hotness=1 -pass-remarks=sample-profile -S -o /dev/null 2>&1 | FileCheck -check-prefix=ICP-ALL %s
|
||||||
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/indirect-call-csspgo.prof -sample-profile-icp-threshold=100 -pass-remarks=sample-profile -S -o /dev/null 2>&1 | FileCheck -check-prefix=ICP-ALL %s
|
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/indirect-call-csspgo.prof -sample-profile-icp-relative-hotness=1 -pass-remarks=sample-profile -S -o /dev/null 2>&1 | FileCheck -check-prefix=ICP-ALL %s
|
||||||
; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/indirect-call-csspgo.prof -sample-profile-icp-threshold=100 -pass-remarks=sample-profile -sample-profile-inline-size=0 -S -o /dev/null 2>&1 | FileCheck -check-prefix=ICP-HOT %s
|
; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/indirect-call-csspgo.prof -sample-profile-icp-relative-hotness=1 -pass-remarks=sample-profile -sample-profile-inline-size=0 -S -o /dev/null 2>&1 | FileCheck -check-prefix=ICP-HOT %s
|
||||||
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/indirect-call-csspgo.prof -sample-profile-icp-threshold=100 -pass-remarks=sample-profile -sample-profile-inline-size=0 -S -o /dev/null 2>&1 | FileCheck -check-prefix=ICP-HOT %s
|
; RUN: opt < %s -passes=sample-profile -sample-profile-file=%S/Inputs/indirect-call-csspgo.prof -sample-profile-icp-relative-hotness=1 -pass-remarks=sample-profile -sample-profile-inline-size=0 -S -o /dev/null 2>&1 | FileCheck -check-prefix=ICP-HOT %s
|
||||||
|
|
||||||
define void @test(void ()*) #0 !dbg !3 {
|
define void @test(void ()*) #0 !dbg !3 {
|
||||||
;; Add two direct call to force top-down order for sample profile loader
|
;; Add two direct call to force top-down order for sample profile loader
|
||||||
|
Loading…
Reference in New Issue
Block a user