Skip to content

Commit 39ba027

Browse files
committed
[RISCV,test] Test whether MCAssembler uses function target-features
Test https://discourse.llvm.org/t/possible-problem-related-to-subtarget-usage/75283 The test is similar to ARM/relax-per-target-feature.ll in spirit.
1 parent f1963fd commit 39ba027

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
8+
declare dso_local i32 @ext(i32)
9+
10+
; CHECK-LABEL: <f>:
11+
; CHECK-NEXT: c.li a0, 31
12+
; CHECK-NEXT: auipc t1, 0
13+
; CHECK-NEXT: R_RISCV_CALL_PLT ext
14+
; CHECK-NEXT: jalr zero, 0(t1)
15+
define dso_local i32 @f() #0 {
16+
entry:
17+
%r = tail call i32 @ext(i32 31)
18+
ret i32 %r
19+
}
20+
21+
; CHECK-LABEL: <g>:
22+
; CHECK-NEXT: addi a0, zero, 31
23+
; CHECK-NEXT: auipc t1, 0
24+
; CHECK-NEXT: R_RISCV_CALL_PLT ext
25+
; CHECK-NEXT: jalr zero, 0(t1)
26+
define dso_local i32 @g() #1 {
27+
entry:
28+
%r = tail call i32 @ext(i32 31)
29+
ret i32 %r
30+
}
31+
32+
attributes #0 = { nounwind "target-features"="+c,+relax" }
33+
attributes #1 = { nounwind "target-features"="-c,-relax" }

0 commit comments

Comments
 (0)