| 1 |
; REQUIRES: x86-registered-target |
| 2 |
; RUN: opt -S %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline.prof | opt -S -passes='require<profile-summary>,function(codegenprepare)' | FileCheck %s |
| 3 |
; RUN: opt -S %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline.prof | opt -S -passes='require<profile-summary>,function(codegenprepare)' -profile-unknown-in-special-section -partial-profile | FileCheck %s --check-prefix=UNKNOWN |
| 4 |
; RUN: opt -S %s -passes=sample-profile -sample-profile-file=%S/Inputs/inline.prof -profile-sample-accurate -S | opt -S -passes='require<profile-summary>,function(codegenprepare)' | FileCheck %s --check-prefix=ACCURATE |
| 5 |
|
| 6 |
target triple = "x86_64-pc-linux-gnu" |
| 7 |
|
| 8 |
; The test checks that function without profile gets unlikely section prefix |
| 9 |
; if -profile-sample-accurate is specified or the function has the |
| 10 |
; profile-sample-accurate attribute. |
| 11 |
|
| 12 |
declare void @hot_func() |
| 13 |
|
| 14 |
; CHECK-NOT: foo_not_in_profile{{.*}}!section_prefix |
| 15 |
; CHECK: foo_not_in_profile{{.*}}!prof ![[NOPROFILE_ID:[0-9]+]] |
| 16 |
; UNKNOWN: foo_not_in_profile{{.*}}!prof ![[NOPROFILE_ID:[0-9]+]] !section_prefix ![[UNKNOWN_ID:[0-9]+]] |
| 17 |
; ACCURATE: foo_not_in_profile{{.*}}!prof ![[ZERO_ID:[0-9]+]] !section_prefix ![[COLD_ID:[0-9]+]] |
| 18 |
; The function not appearing in profile is cold when -profile-sample-accurate |
| 19 |
; is on. |
| 20 |
define void @foo_not_in_profile() #1 { |
| 21 |
call void @hot_func() |
| 22 |
ret void |
| 23 |
} |
| 24 |
|
| 25 |
; CHECK: bar_not_in_profile{{.*}}!prof ![[ZERO_ID:[0-9]+]] !section_prefix ![[COLD_ID:[0-9]+]] |
| 26 |
; ACCURATE: bar_not_in_profile{{.*}}!prof ![[ZERO_ID:[0-9]+]] !section_prefix ![[COLD_ID:[0-9]+]] |
| 27 |
; The function not appearing in profile is cold when the func has |
| 28 |
; profile-sample-accurate attribute. |
| 29 |
define void @bar_not_in_profile() #0 { |
| 30 |
call void @hot_func() |
| 31 |
ret void |
| 32 |
} |
| 33 |
|
| 34 |
attributes #0 = { "profile-sample-accurate" "use-sample-profile" } |
| 35 |
attributes #1 = { "use-sample-profile" } |
| 36 |
|
| 37 |
; CHECK: ![[NOPROFILE_ID]] = !{!"function_entry_count", i64 -1} |
| 38 |
; CHECK: ![[ZERO_ID]] = !{!"function_entry_count", i64 0} |
| 39 |
; CHECK: ![[COLD_ID]] = !{!"section_prefix", !"unlikely"} |
| 40 |
; UNKNOWN: ![[NOPROFILE_ID]] = !{!"function_entry_count", i64 -1} |
| 41 |
; UNKNOWN: ![[UNKNOWN_ID]] = !{!"section_prefix", !"unknown"} |
| 42 |
; ACCURATE: ![[ZERO_ID]] = !{!"function_entry_count", i64 0} |
| 43 |
; ACCURATE: ![[COLD_ID]] = !{!"section_prefix", !"unlikely"} |
| 44 |
!llvm.module.flags = !{!1} |
| 45 |
!1 = !{i32 1, !"ProfileSummary", !2} |
| 46 |
!2 = !{!3, !4, !5, !6, !7, !8, !9, !10} |
| 47 |
!3 = !{!"ProfileFormat", !"SampleProfile"} |
| 48 |
!4 = !{!"TotalCount", i64 10000} |
| 49 |
!5 = !{!"MaxCount", i64 1000} |
| 50 |
!6 = !{!"MaxInternalCount", i64 1} |
| 51 |
!7 = !{!"MaxFunctionCount", i64 1000} |
| 52 |
!8 = !{!"NumCounts", i64 3} |
| 53 |
!9 = !{!"NumFunctions", i64 3} |
| 54 |
!10 = !{!"DetailedSummary", !11} |
| 55 |
!11 = !{!12, !13, !14} |
| 56 |
!12 = !{i32 10000, i64 100, i32 1} |
| 57 |
!13 = !{i32 999000, i64 100, i32 1} |
| 58 |
!14 = !{i32 999999, i64 1, i32 2} |