66; RUN: llc -mtriple=x86_64-unknown-linux-gnu -stop-after=finalize-isel -min-jump-table-entries=2 %s -o %t.mir
77; RUN: llc -mtriple=x86_64-unknown-linux-gnu --run-pass=static-data-splitter -stats -x mir %t.mir -o - 2>&1 | FileCheck %s --check-prefix=STAT
88
9- ; In function @foo, the 2 switch instructions to jt0.* and jt1.* get lowered to
10- ; hot jump tables, and the 2 switch instructions to jt2.* and jt3.* get lowered
11- ; to cold jump tables.
12-
13- ; @func_without_entry_count simulates the functions without profile information
14- ; (e.g., not instrumented or not profiled), it's jump table hotness is unknown.
15-
16- ; Tests stat messages are expected.
9+ ; @foo has 2 hot and 2 cold jump tables.
10+ ; The two jump tables with unknown hotness come from @func_without_profile and
11+ ; @bar respectively.
1712; STAT: 2 static-data-splitter - Number of cold jump tables seen
1813; STAT: 2 static-data-splitter - Number of hot jump tables seen
19- ; STAT: 1 static-data-splitter - Number of jump tables with unknown hotness
20-
21- ; Hot jump tables are in the `.rodata.hot`-prefixed section, and cold ones in
22- ; the `.rodata.unlikely`-prefixed section. In the function without profile
23- ; information, jump table section is `rodata` without hot or unlikely prefix.
14+ ; STAT: 2 static-data-splitter - Number of jump tables with unknown hotness
2415
2516; RUN: llc -mtriple=x86_64-unknown-linux-gnu -enable-split-machine-functions \
2617; RUN: -partition-static-data-sections=true -function-sections=true \
3627; RUN: -partition-static-data-sections=true -function-sections=false \
3728; RUN: -min-jump-table-entries=2 %s -o - 2>&1 | FileCheck %s --check-prefixes=FUNCLESS,JT
3829
39- ; NUM: .section .rodata.hot,"a",@progbits,unique,2
30+ ; In function @foo, the 2 switch instructions to jt0.* and jt1.* are placed in
31+ ; hot-prefixed sections, and the 2 switch instructions to jt2.* and jt3.* are
32+ ; placed in cold-prefixed sections.
33+ ; NUM: .section .rodata.hot.,"a",@progbits,unique,2
4034; FUNC: .section .rodata.hot.foo,"a",@progbits
41- ; FUNCLESS: .section .rodata.hot,"a",@progbits
35+ ; FUNCLESS: .section .rodata.hot. ,"a",@progbits
4236; JT: .LJTI0_0:
4337; JT: .LJTI0_2:
44- ; NUM: .section .rodata.unlikely,"a",@progbits,unique,3
38+ ; NUM: .section .rodata.unlikely. ,"a",@progbits,unique,3
4539; FUNC: .section .rodata.unlikely.foo,"a",@progbits
46- ; FUNCLESS: .section .rodata.unlikely,"a",@progbits
40+ ; FUNCLESS: .section .rodata.unlikely. ,"a",@progbits
4741; JT: .LJTI0_1:
4842; JT: .LJTI0_3:
49- ; FUNC: .section .rodata.func_without_entry_count,"a",@progbits
43+
44+ ; @func_without_profile simulates the functions without profile information
45+ ; (e.g., not instrumented or not profiled), its jump tables are placed in
46+ ; sections without hot or unlikely prefixes.
47+ ; NUM: .section .rodata,"a",@progbits,unique,5
48+ ; FUNC: .section .rodata.func_without_profile,"a",@progbits
5049; FUNCLESS: .section .rodata,"a",@progbits
5150; JT: .LJTI1_0:
5251
52+ ; @bar doesn't have profile information and it has a section prefix.
53+ ; Tests that its jump tables are placed in sections with function prefixes.
54+ ; NUM: .section .rodata.bar_prefix.,"a",@progbits,unique,7
55+ ; FUNC: .section .rodata.bar_prefix.bar
56+ ; FUNCLESS: .section .rodata.bar_prefix.,"a"
57+ ; JT: .LJTI2_0
58+
5359target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
5460target triple = "x86_64-unknown-linux-gnu"
5561
@@ -159,7 +165,7 @@ return:
159165 ret i32 %mod3
160166}
161167
162- define void @func_without_entry_count (i32 %num ) {
168+ define void @func_without_profile (i32 %num ) {
163169entry:
164170 switch i32 %num , label %sw.default [
165171 i32 1 , label %sw.bb
@@ -182,6 +188,29 @@ sw.epilog:
182188 ret void
183189}
184190
191+ define void @bar (i32 %num ) !section_prefix !20 {
192+ entry:
193+ switch i32 %num , label %sw.default [
194+ i32 1 , label %sw.bb
195+ i32 2 , label %sw.bb1
196+ ]
197+
198+ sw.bb:
199+ call i32 @puts (ptr @str.10 )
200+ br label %sw.epilog
201+
202+ sw.bb1:
203+ call i32 @puts (ptr @str.9 )
204+ br label %sw.epilog
205+
206+ sw.default:
207+ call i32 @puts (ptr @str.11 )
208+ br label %sw.epilog
209+
210+ sw.epilog:
211+ ret void
212+ }
213+
185214declare i32 @puts (ptr )
186215declare i32 @printf (ptr , ...)
187216declare i32 @compute (i32 )
@@ -210,3 +239,4 @@ declare i32 @cleanup(i32)
210239!17 = !{!"branch_weights" , i32 99999 , i32 1 }
211240!18 = !{!"branch_weights" , i32 99998 , i32 1 }
212241!19 = !{!"branch_weights" , i32 97000 , i32 1000 , i32 1000 , i32 1000 }
242+ !20 = !{!"function_section_prefix" , !"bar_prefix" }
0 commit comments