mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[Inliner] Do not mix callsite and callee hotness based updates.
Update threshold based on callee's hotness only when BFI is not available. Otherwise use only callsite's hotness. This makes it easier to reason about hotness related threshold updates. Differential revision: https://reviews.llvm.org/D33157 llvm-svn: 303210
This commit is contained in:
parent
82dcf06a2b
commit
d91313ddb5
@ -669,21 +669,33 @@ void CallAnalyzer::updateThreshold(CallSite CS, Function &Callee) {
|
|||||||
Threshold = MaxIfValid(Threshold, Params.HintThreshold);
|
Threshold = MaxIfValid(Threshold, Params.HintThreshold);
|
||||||
if (PSI) {
|
if (PSI) {
|
||||||
BlockFrequencyInfo *CallerBFI = GetBFI ? &((*GetBFI)(*Caller)) : nullptr;
|
BlockFrequencyInfo *CallerBFI = GetBFI ? &((*GetBFI)(*Caller)) : nullptr;
|
||||||
if (PSI->isHotCallSite(CS, CallerBFI)) {
|
// FIXME: After switching to the new passmanager, simplify the logic below
|
||||||
DEBUG(dbgs() << "Hot callsite.\n");
|
// by checking only the callsite hotness/coldness. The check for CallerBFI
|
||||||
Threshold = Params.HotCallSiteThreshold.getValue();
|
// exists only because we do not have BFI available with the old PM.
|
||||||
} else if (PSI->isFunctionEntryHot(&Callee)) {
|
//
|
||||||
DEBUG(dbgs() << "Hot callee.\n");
|
// Use callee's hotness information only if we have no way of determining
|
||||||
// If callsite hotness can not be determined, we may still know
|
// callsite's hotness information. Callsite hotness can be determined if
|
||||||
// that the callee is hot and treat it as a weaker hint for threshold
|
// sample profile is used (which adds hotness metadata to calls) or if
|
||||||
// increase.
|
// caller's BlockFrequencyInfo is available.
|
||||||
Threshold = MaxIfValid(Threshold, Params.HintThreshold);
|
if (CallerBFI || PSI->hasSampleProfile()) {
|
||||||
} else if (PSI->isColdCallSite(CS, CallerBFI)) {
|
if (PSI->isHotCallSite(CS, CallerBFI)) {
|
||||||
DEBUG(dbgs() << "Cold callsite.\n");
|
DEBUG(dbgs() << "Hot callsite.\n");
|
||||||
Threshold = MinIfValid(Threshold, Params.ColdCallSiteThreshold);
|
Threshold = Params.HotCallSiteThreshold.getValue();
|
||||||
} else if (PSI->isFunctionEntryCold(&Callee)) {
|
} else if (PSI->isColdCallSite(CS, CallerBFI)) {
|
||||||
DEBUG(dbgs() << "Cold callee.\n");
|
DEBUG(dbgs() << "Cold callsite.\n");
|
||||||
Threshold = MinIfValid(Threshold, Params.ColdThreshold);
|
Threshold = MinIfValid(Threshold, Params.ColdCallSiteThreshold);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (PSI->isFunctionEntryHot(&Callee)) {
|
||||||
|
DEBUG(dbgs() << "Hot callee.\n");
|
||||||
|
// If callsite hotness can not be determined, we may still know
|
||||||
|
// that the callee is hot and treat it as a weaker hint for threshold
|
||||||
|
// increase.
|
||||||
|
Threshold = MaxIfValid(Threshold, Params.HintThreshold);
|
||||||
|
} else if (PSI->isFunctionEntryCold(&Callee)) {
|
||||||
|
DEBUG(dbgs() << "Cold callee.\n");
|
||||||
|
Threshold = MinIfValid(Threshold, Params.ColdThreshold);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
; RUN: opt < %s -inline -inline-threshold=0 -inlinehint-threshold=100 -S | FileCheck %s
|
; RUN: opt < %s -inline -inline-threshold=0 -inlinehint-threshold=100 -S | FileCheck %s
|
||||||
; RUN: opt < %s -passes='require<profile-summary>,cgscc(inline)' -inline-threshold=0 -inlinehint-threshold=100 -S | FileCheck %s
|
|
||||||
|
|
||||||
; This tests that a hot callee gets the (higher) inlinehint-threshold even without
|
; This tests that a hot callee gets the (higher) inlinehint-threshold even
|
||||||
; inline hints and gets inlined because the cost is less than inlinehint-threshold.
|
; without inline hints and gets inlined because the cost is less than
|
||||||
; A cold callee with identical body does not get inlined because cost exceeds the
|
; inlinehint-threshold. A cold callee with identical body does not get inlined
|
||||||
; inline-threshold
|
; because cost exceeds the inline-threshold. This test is relevant only when the
|
||||||
|
; old pass manager is used.
|
||||||
|
|
||||||
define i32 @callee1(i32 %x) !prof !21 {
|
define i32 @callee1(i32 %x) !prof !21 {
|
||||||
%x1 = add i32 %x, 1
|
%x1 = add i32 %x, 1
|
||||||
|
Loading…
Reference in New Issue
Block a user