Skip to content

Commit 4dc0221

Browse files
committed
fixup! fixup! [BOLT][AArch64] Add support for compact code model
1 parent 3cabeab commit 4dc0221

File tree

1 file changed

+55
-11
lines changed

1 file changed

+55
-11
lines changed

bolt/test/AArch64/compact-code-model.s

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,84 @@
22
## model.
33

44
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
5+
# RUN: link_fdata %s %t.o %t.fdata
6+
# RUN: llvm-strip --strip-unneeded %t.o
57
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static
6-
# RUN: llvm-bolt %t.exe -o %t.bolt --split-functions --split-strategy=randomN \
8+
# RUN: llvm-bolt %t.exe -o %t.bolt --data %t.fdata --split-functions \
79
# RUN: --keep-nops --compact-code-model
8-
# RUN: llvm-objdump -d --disassemble-symbols=_start %t.bolt | FileCheck %s
9-
# RUN: llvm-nm -n %t.bolt | FileCheck %s --check-prefix=CHECK-NM
10+
# RUN: llvm-objdump -d \
11+
# RUN: --disassemble-symbols=_start,_start.cold.0,foo,foo.cold.0 %t.bolt \
12+
# RUN: | FileCheck %s
13+
# RUN: llvm-nm -nS %t.bolt | FileCheck %s --check-prefix=CHECK-NM
1014

11-
## _start will be split and its main fragment will be separated from other
12-
## fragments by large_function() which is over 1MB.
15+
## Fragments of _start and foo will be separated by large_function which is over
16+
## 1MB in size - larger than all conditional branches can cover requiring branch
17+
## relaxation.
1318

1419
# CHECK-NM: _start
15-
# CHECK-NM-NEXT: large_function
16-
# CHECK-NM-NEXT: _start.cold
20+
# CHECK-NM: foo
21+
# CHECK-NM: 0000000000124f84 T large_function
22+
# CHECK-NM: _start.cold.0
23+
# CHECK-NM: foo.cold.0
1724

1825
.text
1926
.globl _start
2027
.type _start, %function
2128
_start:
29+
# CHECK: <_start>:
30+
# FDATA: 0 [unknown] 0 1 _start 0 0 100
2231
.cfi_startproc
23-
cmp x1, 1
24-
b.hi .L1
25-
# CHECK: b.hi
32+
cmp x0, 1
33+
b.eq .L0
34+
# CHECK: b.eq
2635
# CHECK-NEXT: b
2736
# CHECK-NEXT: b
2837

2938
bl large_function
30-
.L1:
39+
.L0:
3140
ret x30
3241
.cfi_endproc
3342
.size _start, .-_start
3443

44+
## Check that long branch in foo() is reused during relaxation. I.e. we should
45+
## see just one branch to the cold fragment.
46+
47+
.globl foo
48+
.type foo, %function
49+
foo:
50+
# CHECK: <foo>:
51+
# FDATA: 0 [unknown] 0 1 foo 0 0 100
52+
.cfi_startproc
53+
cmp x0, 0
54+
.T0:
55+
b.eq .ERROR
56+
# CHECK: b {{.*}} <foo.cold.0>
57+
# CHECK-NOT: b {{.*}} <foo.cold.0>
58+
# FDATA: 1 foo #.T0# 1 foo #.T1# 0 100
59+
.T1:
60+
bl large_function
61+
cmp x0, 1
62+
.T2:
63+
b.eq .ERROR
64+
# FDATA: 1 foo #.T2# 1 foo #.T3# 0 100
65+
.T3:
66+
mov x1, x0
67+
mov x0, 0
68+
ret x30
69+
70+
# CHECK: <foo.cold.0>:
71+
# CHECK-NEXT: mov x0, #0x1
72+
# CHECK-NEXT: ret
73+
.ERROR:
74+
mov x0, 1
75+
ret x30
76+
.cfi_endproc
77+
.size foo, .-foo
3578

3679
.globl large_function
3780
.type large_function, %function
3881
large_function:
82+
# FDATA: 0 [unknown] 0 1 large_function 0 0 100
3983
.cfi_startproc
4084
.rept 300000
4185
nop

0 commit comments

Comments
 (0)