Skip to content

Commit 2ca028c

Browse files
authored
[LoongArch][MC] Pre-commit tests for instr bl fixupkind testing (#72826)
This patch is used to test whether fixupkind for bl can be returned correctly. When BL has target-flags(loongarch-call), there is no error. But without this flag, an assertion error will appear. So the test is just tagged as "Expectedly Failed" now until the following patch fix it.
1 parent d328512 commit 2ca028c

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## Tagged as "Expectedly Failed" until the following patch fix it
2+
# XFAIL: *
3+
# RUN: llc --mtriple=loongarch64 --filetype=obj %s -o - | \
4+
# RUN: llvm-objdump -d - | FileCheck %s
5+
6+
# REQUIRES: asserts
7+
8+
## Check that bl can get fixupkind correctly.
9+
## When BL has target-flags(loongarch-call), there is no error. But without
10+
## this flag, an assertion error will appear:
11+
## Assertion `FixupKind != LoongArch::fixup_loongarch_invalid && "Unhandled expression!"' failed.
12+
13+
--- |
14+
target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128"
15+
target triple = "loongarch64"
16+
17+
define dso_local void @test_bl_fixupkind_with_flag() {
18+
; CHECK-LABEL: test_bl_fixupkind_with_flag
19+
; CHECK: addi.d $sp, $sp, -16
20+
; CHECK-NEXT: st.d $ra, $sp, 8
21+
; CHECK-NEXT: bl 0 <test_bl_fixupkind_with_flag+0x8>
22+
; CHECK-NEXT: ld.d $ra, $sp, 8
23+
; CHECK-NEXT: addi.d $sp, $sp, 16
24+
; CHECK-NEXT: ret
25+
entry:
26+
call void @foo()
27+
ret void
28+
}
29+
30+
define dso_local void @test_bl_fixupkind_without_flag() {
31+
; CHECK-LABEL: test_bl_fixupkind_without_flag
32+
; CHECK: addi.d $sp, $sp, -16
33+
; CHECK-NEXT: st.d $ra, $sp, 8
34+
; CHECK-NEXT: bl 0 <test_bl_fixupkind_without_flag+0x8>
35+
; CHECK-NEXT: ld.d $ra, $sp, 8
36+
; CHECK-NEXT: addi.d $sp, $sp, 16
37+
; CHECK-NEXT: ret
38+
entry:
39+
call void @foo()
40+
ret void
41+
}
42+
43+
declare dso_local void @foo(...)
44+
...
45+
---
46+
name: test_bl_fixupkind_with_flag
47+
tracksRegLiveness: true
48+
body: |
49+
bb.0.entry:
50+
ADJCALLSTACKDOWN 0, 0, implicit-def dead $r3, implicit $r3
51+
BL target-flags(loongarch-call) @foo, csr_ilp32d_lp64d, implicit-def $r1, implicit-def dead $r1, implicit-def $r3
52+
ADJCALLSTACKUP 0, 0, implicit-def dead $r3, implicit $r3
53+
PseudoRET
54+
55+
...
56+
---
57+
name: test_bl_fixupkind_without_flag
58+
tracksRegLiveness: true
59+
body: |
60+
bb.0.entry:
61+
ADJCALLSTACKDOWN 0, 0, implicit-def dead $r3, implicit $r3
62+
BL @foo, csr_ilp32d_lp64d, implicit-def $r1, implicit-def dead $r1, implicit-def $r3
63+
ADJCALLSTACKUP 0, 0, implicit-def dead $r3, implicit $r3
64+
PseudoRET
65+
66+
...

0 commit comments

Comments
 (0)