mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[SampleFDO] Extend profile-sample-accurate option to cover isFunctionColdInCallGraph
For SampleFDO, when a callsite doesn't appear in the profile, it will not be marked as cold callsite unless the option -profile-sample-accurate is specified. But profile-sample-accurate doesn't cover function isFunctionColdInCallGraph which is used to decide whether a function should be put into text.unlikely section, so even if the user knows the profile is accurate and specifies profile-sample-accurate, those functions not appearing in the sample profile are still not be put into text.unlikely section right now. The patch fixes that. Differential Revision: https://reviews.llvm.org/D55567 llvm-svn: 348940
This commit is contained in:
parent
c6adc5adda
commit
25453a0385
@ -261,7 +261,14 @@ bool ProfileSummaryInfo::isHotBlock(const BasicBlock *BB, BlockFrequencyInfo *BF
|
|||||||
bool ProfileSummaryInfo::isColdBlock(const BasicBlock *BB,
|
bool ProfileSummaryInfo::isColdBlock(const BasicBlock *BB,
|
||||||
BlockFrequencyInfo *BFI) {
|
BlockFrequencyInfo *BFI) {
|
||||||
auto Count = BFI->getBlockProfileCount(BB);
|
auto Count = BFI->getBlockProfileCount(BB);
|
||||||
return Count && isColdCount(*Count);
|
if (Count)
|
||||||
|
return isColdCount(*Count);
|
||||||
|
if (!hasSampleProfile())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const Function *F = BB->getParent();
|
||||||
|
return ProfileSampleAccurate ||
|
||||||
|
(F && F->hasFnAttribute("profile-sample-accurate"));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProfileSummaryInfo::isHotCallSite(const CallSite &CS,
|
bool ProfileSummaryInfo::isHotCallSite(const CallSite &CS,
|
||||||
|
@ -1,16 +1,19 @@
|
|||||||
; RUN: opt < %s -codegenprepare -S | FileCheck %s
|
; RUN: opt < %s -codegenprepare -S | FileCheck %s
|
||||||
|
; RUN: opt < %s -codegenprepare -profile-sample-accurate -S | FileCheck %s --check-prefix ACCURATE
|
||||||
|
|
||||||
target triple = "x86_64-pc-linux-gnu"
|
target triple = "x86_64-pc-linux-gnu"
|
||||||
|
|
||||||
; This tests that hot/cold functions get correct section prefix assigned
|
; This tests that hot/cold functions get correct section prefix assigned
|
||||||
|
|
||||||
; CHECK: hot_func{{.*}}!section_prefix ![[HOT_ID:[0-9]+]]
|
; CHECK: hot_func{{.*}}!section_prefix ![[HOT_ID:[0-9]+]]
|
||||||
|
; ACCURATE: hot_func{{.*}}!section_prefix ![[HOT_ID:[0-9]+]]
|
||||||
; The entry is hot
|
; The entry is hot
|
||||||
define void @hot_func() !prof !15 {
|
define void @hot_func() !prof !15 {
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
; CHECK: hot_call_func{{.*}}!section_prefix ![[HOT_ID]]
|
; CHECK: hot_call_func{{.*}}!section_prefix ![[HOT_ID]]
|
||||||
|
; ACCURATE: hot_call_func{{.*}}!section_prefix ![[HOT_ID]]
|
||||||
; The sum of 2 callsites are hot
|
; The sum of 2 callsites are hot
|
||||||
define void @hot_call_func() !prof !16 {
|
define void @hot_call_func() !prof !16 {
|
||||||
call void @hot_func(), !prof !17
|
call void @hot_func(), !prof !17
|
||||||
@ -19,6 +22,7 @@ define void @hot_call_func() !prof !16 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
; CHECK-NOT: normal_func{{.*}}!section_prefix
|
; CHECK-NOT: normal_func{{.*}}!section_prefix
|
||||||
|
; ACCURATE-NOT: normal_func{{.*}}!section_prefix
|
||||||
; The sum of all callsites are neither hot or cold
|
; The sum of all callsites are neither hot or cold
|
||||||
define void @normal_func() !prof !16 {
|
define void @normal_func() !prof !16 {
|
||||||
call void @hot_func(), !prof !17
|
call void @hot_func(), !prof !17
|
||||||
@ -28,12 +32,36 @@ define void @normal_func() !prof !16 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
; CHECK: cold_func{{.*}}!section_prefix ![[COLD_ID:[0-9]+]]
|
; CHECK: cold_func{{.*}}!section_prefix ![[COLD_ID:[0-9]+]]
|
||||||
|
; ACCURATE: cold_func{{.*}}!section_prefix ![[COLD_ID:[0-9]+]]
|
||||||
; The entry and the callsite are both cold
|
; The entry and the callsite are both cold
|
||||||
define void @cold_func() !prof !16 {
|
define void @cold_func() !prof !16 {
|
||||||
call void @hot_func(), !prof !18
|
call void @hot_func(), !prof !18
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; CHECK-NOT: foo_not_in_profile{{.*}}!section_prefix
|
||||||
|
; The function not appearing in profile is neither hot nor cold
|
||||||
|
;
|
||||||
|
; ACCURATE: foo_not_in_profile{{.*}}!section_prefix ![[COLD_ID:[0-9]+]]
|
||||||
|
; The function not appearing in profile is cold when -profile-sample-accurate
|
||||||
|
; is on
|
||||||
|
define void @foo_not_in_profile() !prof !19 {
|
||||||
|
call void @hot_func()
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; CHECK: bar_not_in_profile{{.*}}!section_prefix ![[COLD_ID:[0-9]+]]
|
||||||
|
; ACCURATE: bar_not_in_profile{{.*}}!section_prefix ![[COLD_ID:[0-9]+]]
|
||||||
|
; The function not appearing in profile is cold when the func has
|
||||||
|
; profile-sample-accurate attribute
|
||||||
|
define void @bar_not_in_profile() #0 !prof !19 {
|
||||||
|
call void @hot_func()
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes #0 = { "profile-sample-accurate" }
|
||||||
|
|
||||||
; CHECK: ![[HOT_ID]] = !{!"function_section_prefix", !".hot"}
|
; CHECK: ![[HOT_ID]] = !{!"function_section_prefix", !".hot"}
|
||||||
; CHECK: ![[COLD_ID]] = !{!"function_section_prefix", !".unlikely"}
|
; CHECK: ![[COLD_ID]] = !{!"function_section_prefix", !".unlikely"}
|
||||||
!llvm.module.flags = !{!1}
|
!llvm.module.flags = !{!1}
|
||||||
@ -55,3 +83,4 @@ define void @cold_func() !prof !16 {
|
|||||||
!16 = !{!"function_entry_count", i64 1}
|
!16 = !{!"function_entry_count", i64 1}
|
||||||
!17 = !{!"branch_weights", i32 80}
|
!17 = !{!"branch_weights", i32 80}
|
||||||
!18 = !{!"branch_weights", i32 1}
|
!18 = !{!"branch_weights", i32 1}
|
||||||
|
!19 = !{!"function_entry_count", i64 -1}
|
||||||
|
Loading…
Reference in New Issue
Block a user