xref: /llvm-project/llvm/test/CodeGen/RISCV/option-relax-relocation.ll (revision 6c207ee5d20d2b054509123e6d0507df1332b376)
1;; With +relax, J below needs a relocation to ensure the target is correct
2;; after linker relaxation. See https://github.com/ClangBuiltLinux/linux/issues/1965
3
4; RUN: llc -mtriple=riscv64 -mattr=-relax -filetype=obj < %s \
5; RUN:     | llvm-objdump -d -r - | FileCheck %s
6; RUN: llc -mtriple=riscv64 -mattr=+relax -filetype=obj < %s \
7; RUN:     | llvm-objdump -d -r - | FileCheck %s --check-prefixes=CHECK,RELAX
8
9; CHECK:        j       {{.*}}
10; RELAX-NEXT:           R_RISCV_JAL  {{.*}}
11; CHECK-NEXT:   auipc   ra, 0x0
12; CHECK-NEXT:           R_RISCV_CALL_PLT     f
13; RELAX-NEXT:           R_RISCV_RELAX        *ABS*
14; CHECK-NEXT:   jalr    ra
15
16define dso_local noundef signext i32 @main() local_unnamed_addr #0 {
17entry:
18  callbr void asm sideeffect ".option push\0A.option norvc\0A.option norelax\0Aj $0\0A.option pop\0A", "!i"() #2
19          to label %asm.fallthrough [label %label]
20
21asm.fallthrough:                                  ; preds = %entry
22  tail call void @f()
23  br label %label
24
25label:                                            ; preds = %asm.fallthrough, %entry
26  ret i32 0
27}
28
29declare void @f()
30
31attributes #0 = { nounwind "target-features"="-c,+relax" }
32