xref: /llvm-project/llvm/test/MC/RISCV/long-jump-disable-relax.s (revision afb2e9f44c13101c7b22c99e080b0beb0cd5b01e)
1## Test that long branches are not relaxed with -riscv-asm-relax-branches=0
2# RUN: split-file %s %t
3# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+c \
4# RUN:       -riscv-asm-relax-branches=0 %t/pass.s \
5# RUN:     | llvm-objdump -dr -M no-aliases - \
6# RUN:     | FileCheck %t/pass.s
7# RUN: not llvm-mc -filetype=obj -triple=riscv64 -mattr=+c -o /dev/null \
8# RUN:       -riscv-asm-relax-branches=0 %t/fail.s 2>&1 \
9# RUN:     | FileCheck %t/fail.s
10
11#--- pass.s
12  .text
13test_undefined:
14## Branches to undefined symbols should not be relaxed
15# CHECK:      bne a0, a1, {{.*}}
16# CHECK-NEXT: R_RISCV_BRANCH foo
17   bne a0, a1, foo
18# CHECK:      c.beqz a0, {{.*}}
19# CHECK-NEXT: R_RISCV_RVC_BRANCH foo
20   c.beqz a0, foo
21# CHECK:      c.j {{.*}}
22# CHECK-NEXT: R_RISCV_RVC_JUMP foo
23   c.j foo
24
25## Branches to defined in-range symbols should work normally
26test_defined_in_range:
27# CHECK:      bne a0, a1, {{.*}} <bar>
28  bne a0, a1, bar
29# CHECK:      c.beqz a0, {{.*}} <bar>
30   c.beqz a0, bar
31# CHECK:      c.j {{.*}} <bar>
32   c.j bar
33bar:
34
35#--- fail.s
36  .text
37## Branches to defined out-of-range symbols should report an error
38test_defined_out_of_range:
39  bne a0, a1, 1f # CHECK: :[[#@LINE]]:3: error: fixup value out of range
40  .skip (1 << 12)
411:
42  c.beqz a0, 1f # CHECK: :[[#@LINE]]:3: error: fixup value out of range
43  .skip (1 << 8)
441:
45  c.j 1f # CHECK: :[[#@LINE]]:3: error: fixup value out of range
46  .skip (1 << 11)
471:
48