Skip to content

Commit f86f457

Browse files
authored
[BOLT][Linux] Fix static keys test case (#119771)
The key address in the static keys jump table was incorrectly encoded as an absolute value instead of PC-relative causing incorrect interpretation of the "likely" property of the key.
1 parent 8daf4f1 commit f86f457

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

bolt/test/X86/linux-static-keys.s

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ _start:
3535
.L0:
3636
jmp L1
3737
# CHECK: jit
38-
# CHECK-SAME: # ID: 1 {{.*}} # Likely: 0 # InitValue: 1
38+
# CHECK-SAME: # ID: 1 {{.*}} # Likely: 1 # InitValue: 0
3939
nop
4040
L1:
4141
.nops 5
42-
jmp .L0
4342
# CHECK: jit
44-
# CHECK-SAME: # ID: 2 {{.*}} # Likely: 1 # InitValue: 1
43+
# CHECK-SAME: # ID: 2 {{.*}} # Likely: 0 # InitValue: 0
44+
jmp .L0
4545

4646
## Check that a branch profile associated with a NOP is handled properly when
4747
## dynamic branch is created.
@@ -67,18 +67,24 @@ foo:
6767
.type __start___jump_table, %object
6868
__start___jump_table:
6969

70-
.long .L0 - . # Jump address
71-
.long L1 - . # Target address
72-
.quad 1 # Key address
70+
.long .L0 - . # Jump address
71+
.long L1 - . # Target address
72+
.quad fake_static_key + 1 - . # Key address; LSB = 1 : likely
7373

74-
.long L1 - . # Jump address
75-
.long L2 - . # Target address
76-
.quad 0 # Key address
74+
.long L1 - . # Jump address
75+
.long L2 - . # Target address
76+
.quad fake_static_key -. # Key address; LSB = 0 : unlikely
7777

7878
.globl __stop___jump_table
7979
.type __stop___jump_table, %object
8080
__stop___jump_table:
8181

82+
## Staic keys (we just use the label ignoring the format of the keys).
83+
.data
84+
.align 8
85+
fake_static_key:
86+
.quad 0
87+
8288
## Fake Linux Kernel sections.
8389
.section __ksymtab,"a",@progbits
8490
.section __ksymtab_gpl,"a",@progbits

0 commit comments

Comments
 (0)