xref: /llvm-project/llvm/test/CodeGen/RISCV/relax-per-target-feature.ll (revision 7fee58acf4c81159655b30c503b773913966255c)
1; RUN: llc -filetype=obj -mtriple=riscv64 %s -o %t
2; RUN: llvm-objdump -dr -M no-aliases --mattr=+c %t | FileCheck %s
3
4;; Functions may have more features than the base triple; code generation and
5;; instruction selection may be performed based on this information. This test
6;; makes sure that the MC layer uses the target-features of the function.
7
8declare dso_local i32 @ext(i32)
9
10; CHECK-LABEL: <f>:
11; CHECK-NEXT:    c.li a0, 0x1f
12; CHECK-NEXT:    auipc t1, 0x0
13; CHECK-NEXT:    R_RISCV_CALL_PLT     ext
14; CHECK-NEXT:    R_RISCV_RELAX *ABS*
15; CHECK-NEXT:    jalr zero, 0x0(t1)
16define dso_local i32 @f() #0 {
17entry:
18  %r = tail call i32 @ext(i32 31)
19  ret i32 %r
20}
21
22; CHECK-LABEL: <g>:
23; CHECK-NEXT:    addi a0, zero, 0x1f
24; CHECK-NEXT:    auipc t1, 0x0
25; CHECK-NEXT:    R_RISCV_CALL_PLT     ext
26; CHECK-NEXT:    jalr zero, 0x0(t1)
27define dso_local i32 @g() #1 {
28entry:
29  %r = tail call i32 @ext(i32 31)
30  ret i32 %r
31}
32
33attributes #0 = { nounwind "target-features"="+c,+relax" }
34attributes #1 = { nounwind "target-features"="-c,-relax" }
35