mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-17 10:55:58 +00:00

Summary: Don't use the metadata on call instructions for determining hotness unless we are in sample PGO mode, where it is needed because profile counts are not accurate. In instrumentation mode this is not necessary and does more harm than good when calls have VP metadata that hasn't been properly scaled after transformations or dropped after constant prop based devirtualization (both should be fixed, but we don't need to do this in the first place for instrumentation PGO). This required adjusting a number of tests to distinguish between sample and instrumentation PGO handling, and to add in profile summary metadata so that getProfileCount can get the summary. Reviewers: davidxl, danielcdh Subscribers: aemerson, rengolin, mehdi_amini, Prazek, llvm-commits Differential Revision: https://reviews.llvm.org/D32877 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302844 91177308-0d34-0410-b5e6-96231b3b80d8
58 lines
1.7 KiB
LLVM
58 lines
1.7 KiB
LLVM
; RUN: opt < %s -codegenprepare -S | FileCheck %s
|
|
|
|
target triple = "x86_64-pc-linux-gnu"
|
|
|
|
; This tests that hot/cold functions get correct section prefix assigned
|
|
|
|
; CHECK: hot_func{{.*}}!section_prefix ![[HOT_ID:[0-9]+]]
|
|
; The entry is hot
|
|
define void @hot_func() !prof !15 {
|
|
ret void
|
|
}
|
|
|
|
; CHECK: hot_call_func{{.*}}!section_prefix ![[HOT_ID]]
|
|
; The sum of 2 callsites are hot
|
|
define void @hot_call_func() !prof !16 {
|
|
call void @hot_func(), !prof !17
|
|
call void @hot_func(), !prof !17
|
|
ret void
|
|
}
|
|
|
|
; CHECK-NOT: normal_func{{.*}}!section_prefix
|
|
; The sum of all callsites are neither hot or cold
|
|
define void @normal_func() !prof !16 {
|
|
call void @hot_func(), !prof !17
|
|
call void @hot_func(), !prof !18
|
|
call void @hot_func(), !prof !18
|
|
ret void
|
|
}
|
|
|
|
; CHECK: cold_func{{.*}}!section_prefix ![[COLD_ID:[0-9]+]]
|
|
; The entry and the callsite are both cold
|
|
define void @cold_func() !prof !16 {
|
|
call void @hot_func(), !prof !18
|
|
ret void
|
|
}
|
|
|
|
; CHECK: ![[HOT_ID]] = !{!"function_section_prefix", !".hot"}
|
|
; CHECK: ![[COLD_ID]] = !{!"function_section_prefix", !".unlikely"}
|
|
!llvm.module.flags = !{!1}
|
|
!1 = !{i32 1, !"ProfileSummary", !2}
|
|
!2 = !{!3, !4, !5, !6, !7, !8, !9, !10}
|
|
!3 = !{!"ProfileFormat", !"SampleProfile"}
|
|
!4 = !{!"TotalCount", i64 10000}
|
|
!5 = !{!"MaxCount", i64 1000}
|
|
!6 = !{!"MaxInternalCount", i64 1}
|
|
!7 = !{!"MaxFunctionCount", i64 1000}
|
|
!8 = !{!"NumCounts", i64 3}
|
|
!9 = !{!"NumFunctions", i64 3}
|
|
!10 = !{!"DetailedSummary", !11}
|
|
!11 = !{!12, !13, !14}
|
|
!12 = !{i32 10000, i64 100, i32 1}
|
|
!13 = !{i32 999000, i64 100, i32 1}
|
|
!14 = !{i32 999999, i64 1, i32 2}
|
|
!15 = !{!"function_entry_count", i64 1000}
|
|
!16 = !{!"function_entry_count", i64 1}
|
|
!17 = !{!"branch_weights", i32 80}
|
|
!18 = !{!"branch_weights", i32 1}
|