xref: /llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_relax_nonrelaxable.s (revision 794970988e9fd02fdb8ddc8479f4dcc7cdd93474)
1## Test that non-relaxable edges have their offset adjusted by relaxation
2
3# RUN: rm -rf %t && mkdir %t && cd %t
4
5# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+relax %s -o %t.rv32
6# RUN: llvm-jitlink -noexec \
7# RUN:     -slab-allocate 100Kb -slab-address 0x0 -slab-page-size 4096 \
8# RUN:     -check %s %t.rv32
9
10# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+relax %s -o %t.rv64
11# RUN: llvm-jitlink -noexec \
12# RUN:     -slab-allocate 100Kb -slab-address 0x0 -slab-page-size 4096 \
13# RUN:     -check %s %t.rv64
14
15    .globl main,nonrelaxable,nonrelaxable_target
16    .size nonrelaxable, 4
17    .size nonrelaxable_target, 4
18main:
19    call f
20nonrelaxable:
21    ## Non-relaxable R_RISCV_BRANCH edge after a relaxable R_RISCV_CALL edge.
22    ## Even though this edge isn't relaxable, its offset should still be
23    ## adjusted.
24    beq zero, zero, nonrelaxable_target
25nonrelaxable_target:
26    ret
27    .size main, .-main
28
29    .globl f
30f:
31    ret
32    .size f, .-f
33
34# jitlink-check: decode_operand(nonrelaxable, 2) = (nonrelaxable_target - nonrelaxable)
35
36