11target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
22target triple = "x86_64-unknown-linux-gnu"
33
4- ;; A minimal test case. Subsequent PRs will expand on this test case
5- ;; (e.g., with more functions, variables and profiles) and test the hotness
6- ;; reconcillation implementation.
4+ ;; Requires asserts for -debug-only.
5+ ; REQUIRES: asserts
6+
7+ ; RUN: rm -rf %t && split-file %s %t && cd %t
8+
9+ ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
10+ ; RUN: -partition-static-data-sections=true \
11+ ; RUN: -debug-only=static-data-profile-info \
12+ ; RUN: -data-sections=true -unique-section-names=false \
13+ ; RUN: input-with-data-access-prof-on.ll -o - 2>&1 | FileCheck %s --check-prefixes=LOG,IR
14+
715; RUN: llc -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic \
816; RUN: -partition-static-data-sections=true \
17+ ; RUN: -debug-only=static-data-profile-info \
918; RUN: -data-sections=true -unique-section-names=false \
10- ; RUN: %s -o - 2>&1 | FileCheck %s --check-prefix=IR
19+ ; RUN: input-with-data-access-prof-off.ll -o - 2>&1 | FileCheck %s --check-prefixes=OFF
20+
21+ ; LOG: hot_bss has section prefix hot, the max from data access profiles as hot and PGO counters as hot
22+ ; LOG: data_unknown_hotness has section prefix <empty>, the max from data access profiles as <empty> and PGO counters as unlikely
23+ ; LOG: external_relro_array has section prefix unlikely, solely from data access profiles
24+
25+ ; IR: .type hot_bss,@object
26+ ; IR-NEXT: .section .bss.hot.,"aw"
27+ ; IR: .type data_unknown_hotness,@object
28+ ; IR-NEXT: .section .data,"aw"
29+ ; IR: .type external_relro_array,@object
30+ ; IR-NEXT: .section .data.rel.ro.unlikely.,"aw"
31+
32+
33+ ; OFF: .type hot_bss,@object
34+ ; OFF-NEXT: .section .bss.hot.,"aw"
35+ ; OFF: .type data_unknown_hotness,@object
36+ ; OFF-NEXT: .section .data.unlikely.,"aw"
37+ ;; Global variable section prefix metadata is not used when
38+ ;; module flag `EnableDataAccessProf` is 0, and @external_relro_array has
39+ ;; external linkage, so analysis based on PGO counters doesn't apply.
40+ ; OFF: .type external_relro_array,@object # @external_relro_array
41+ ; OFF-NEXT: .section .data.rel.ro,"aw"
42+
43+ ;--- input-with-data-access-prof-on.ll
44+ ; Internal vars
45+ @hot_bss = internal global i32 0 , !section_prefix !17
46+ @data_unknown_hotness = internal global i32 1
47+ ; External vars
48+ @external_relro_array = constant [2 x ptr ] [ptr @hot_bss , ptr @data_unknown_hotness ], !section_prefix !18
49+
50+ define void @cold_func () !prof !15 {
51+ %9 = load i32 , ptr @data_unknown_hotness
52+ %11 = call i32 (...) @func_taking_arbitrary_param (i32 %9 )
53+ ret void
54+ }
55+
56+ define void @hot_func () !prof !14 {
57+ %9 = load i32 , ptr @hot_bss
58+ %11 = call i32 (...) @func_taking_arbitrary_param (i32 %9 )
59+ ret void
60+ }
61+
62+ declare i32 @func_taking_arbitrary_param (...)
1163
12- ; IR: .section .bss.hot.,"aw"
64+ !llvm.module.flags = !{ !0 , !1 }
1365
66+ !0 = !{i32 2 , !"EnableDataAccessProf" , i32 1 }
67+ !1 = !{i32 1 , !"ProfileSummary" , !2 }
68+ !2 = !{!3 , !4 , !5 , !6 , !7 , !8 , !9 , !10 }
69+ !3 = !{!"ProfileFormat" , !"InstrProf" }
70+ !4 = !{!"TotalCount" , i64 1460183 }
71+ !5 = !{!"MaxCount" , i64 849024 }
72+ !6 = !{!"MaxInternalCount" , i64 32769 }
73+ !7 = !{!"MaxFunctionCount" , i64 849024 }
74+ !8 = !{!"NumCounts" , i64 23627 }
75+ !9 = !{!"NumFunctions" , i64 3271 }
76+ !10 = !{!"DetailedSummary" , !11 }
77+ !11 = !{!12 , !13 }
78+ !12 = !{i32 990000 , i64 166 , i32 73 }
79+ !13 = !{i32 999999 , i64 3 , i32 1443 }
80+ !14 = !{!"function_entry_count" , i64 100000 }
81+ !15 = !{!"function_entry_count" , i64 1 }
82+ !16 = !{!"branch_weights" , i32 1 , i32 99999 }
83+ !17 = !{!"section_prefix" , !"hot" }
84+ !18 = !{!"section_prefix" , !"unlikely" }
85+
86+ ;--- input-with-data-access-prof-off.ll
87+ ; Same as file above except that module flag `EnableDataAccessProf` has value 0.
88+ ; Internal vars
1489@hot_bss = internal global i32 0 , !section_prefix !17
90+ @data_unknown_hotness = internal global i32 1
91+ ; External vars
92+ @external_relro_array = constant [2 x ptr ] [ptr @hot_bss , ptr @data_unknown_hotness ], !section_prefix !18
93+
94+ define void @cold_func () !prof !15 {
95+ %9 = load i32 , ptr @data_unknown_hotness
96+ %11 = call i32 (...) @func_taking_arbitrary_param (i32 %9 )
97+ ret void
98+ }
1599
16100define void @hot_func () !prof !14 {
17101 %9 = load i32 , ptr @hot_bss
@@ -21,8 +105,9 @@ define void @hot_func() !prof !14 {
21105
22106declare i32 @func_taking_arbitrary_param (...)
23107
24- !llvm.module.flags = !{!1 }
108+ !llvm.module.flags = !{!0 , ! 1 }
25109
110+ !0 = !{i32 2 , !"EnableDataAccessProf" , i32 0 }
26111!1 = !{i32 1 , !"ProfileSummary" , !2 }
27112!2 = !{!3 , !4 , !5 , !6 , !7 , !8 , !9 , !10 }
28113!3 = !{!"ProfileFormat" , !"InstrProf" }
@@ -40,3 +125,4 @@ declare i32 @func_taking_arbitrary_param(...)
40125!15 = !{!"function_entry_count" , i64 1 }
41126!16 = !{!"branch_weights" , i32 1 , i32 99999 }
42127!17 = !{!"section_prefix" , !"hot" }
128+ !18 = !{!"section_prefix" , !"unlikely" }
0 commit comments