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