xref: /llvm-project/bolt/test/RISCV/function-alignment.s (revision b6b492880f5ac6357d85ba2f3ad8e41fded1d97c)
1## Test that BOLT uses a minimum function alignment of 4 (or 2 for RVC) bytes.
2
3# RUN: llvm-mc -triple=riscv64 -filetype=obj -o %t.o %s
4# RUN: ld.lld -q -o %t %t.o
5# RUN: llvm-bolt --align-functions=1 --use-old-text=0 -o %t.bolt %t
6# RUN: llvm-nm -n %t.bolt | FileCheck %s
7
8# RUN: llvm-mc -triple=riscv64 -mattr=+c -filetype=obj -o %t-c.o %s
9# RUN: ld.lld -q -o %t-c %t-c.o
10# RUN: llvm-bolt --align-functions=1 --use-old-text=0 -o %t-c.bolt %t-c
11# RUN: llvm-nm -n %t-c.bolt | FileCheck --check-prefix=CHECK-C %s
12
13# CHECK:      {{[048c]}} T _start
14# CHECK-NEXT: {{[048c]}} T dummy
15
16# CHECK-C:      {{[02468ace]}} T _start
17# CHECK-C-NEXT: {{[02468ace]}} T dummy
18
19    .text
20
21    # Make sure input binary is only 1 byte aligned. BOLT should increase the
22    # alignment to 2 or 4 bytes.
23    .byte 0
24    .balign 1
25
26    .globl _start
27    .type _start, @function
28_start:
29    # Dummy reloc to force relocation mode.
30    .reloc 0, R_RISCV_NONE
31    ret
32    .size _start, .-_start
33
34    .globl dummy
35    .type dummy, @function
36dummy:
37    ret
38    .size dummy, .-dummy
39