Skip to content

Commit c528cab

Browse files
author
Mikhail Gudim
committed
Add a test showing that scalable offsets are not handled.
Currently we encode scalable offsets in CFIs using cfi_escape. But CFIInstrInserter can't handle cfi_escape.
1 parent 7287816 commit c528cab

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2+
# RUN: llc %s -mtriple=riscv64 -mattr=+v \
3+
# RUN: -run-pass=prologepilog,cfi-instr-inserter \
4+
# RUN: -riscv-enable-cfi-instr-inserter=true \
5+
# RUN: -o - | FileCheck %s
6+
# XFAIL: *
7+
#
8+
# In this test prolog will be inserted in bb.3. We need to save the scalable vector register v1.
9+
# In bb.3 the new rule for computing CFA will be (sp + 16 + 1 * vlenb) which we encode using cfi_escape. Also, $v1 will be saved at (cfa - 1 * vlenb), which we also encode using cfi_escape.
10+
# Since the only way to get to bb.2 is from bb.3, the same cfi's should be emitted at beginning of bb.2
11+
#
12+
# Currently CFIInstrInserter can't handle escape, so we end up with wrong CFI.
13+
# NOTE: if llc was compiled with NDEBUG, this will just crash. Otherwise, the output will be as in CHECK lines.
14+
15+
--- |
16+
17+
define riscv_vector_cc void @test0(ptr %p0, ptr %p1) #0 {
18+
entry:
19+
%v = load <4 x i32>, ptr %p0, align 16
20+
store <4 x i32> %v, ptr %p1, align 16
21+
ret void
22+
}
23+
24+
attributes #0 = { "target-features"="+v" }
25+
26+
...
27+
---
28+
name: test0
29+
tracksRegLiveness: true
30+
frameInfo:
31+
savePoint:
32+
- point: '%bb.3'
33+
restorePoint:
34+
- point: '%bb.2'
35+
body: |
36+
; CHECK-LABEL: name: test0
37+
; CHECK: bb.0.entry:
38+
; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.1(0x40000000)
39+
; CHECK-NEXT: liveins: $x10, $x11, $v1
40+
; CHECK-NEXT: {{ $}}
41+
; CHECK-NEXT: BEQ $x10, $x0, %bb.3
42+
; CHECK-NEXT: {{ $}}
43+
; CHECK-NEXT: bb.1:
44+
; CHECK-NEXT: liveins: $v1
45+
; CHECK-NEXT: {{ $}}
46+
; CHECK-NEXT: PseudoRET
47+
; CHECK-NEXT: {{ $}}
48+
; CHECK-NEXT: bb.2:
49+
; CHECK-NEXT: successors: %bb.1(0x80000000)
50+
; CHECK-NEXT: {{ $}}
51+
; CHECK-NEXT: CFI_INSTRUCTION def_cfa_offset 16
52+
; CHECK-NEXT: $x10 = ADDI $x2, 16
53+
; CHECK-NEXT: $v1 = frame-destroy VL1RE8_V killed $x10 :: (load (<vscale x 1 x s64>) from %stack.0)
54+
; CHECK-NEXT: $x10 = frame-destroy PseudoReadVLENB
55+
; CHECK-NEXT: $x2 = frame-destroy ADD $x2, killed $x10
56+
; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa $x2, 16
57+
; CHECK-NEXT: frame-destroy CFI_INSTRUCTION restore $v1
58+
; CHECK-NEXT: $x2 = frame-destroy ADDI $x2, 16
59+
; CHECK-NEXT: frame-destroy CFI_INSTRUCTION def_cfa_offset 0
60+
; CHECK-NEXT: PseudoBR %bb.1
61+
; CHECK-NEXT: {{ $}}
62+
; CHECK-NEXT: bb.3:
63+
; CHECK-NEXT: successors: %bb.2(0x80000000)
64+
; CHECK-NEXT: liveins: $x10, $x11, $v1
65+
; CHECK-NEXT: {{ $}}
66+
; CHECK-NEXT: $x2 = frame-setup ADDI $x2, -16
67+
; CHECK-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
68+
; CHECK-NEXT: $x12 = frame-setup PseudoReadVLENB
69+
; CHECK-NEXT: $x2 = frame-setup SUB $x2, killed $x12
70+
; CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x0f, 0x0d, 0x72, 0x00, 0x11, 0x10, 0x22, 0x11, 0x01, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22
71+
; CHECK-NEXT: $x12 = ADDI $x2, 16
72+
; CHECK-NEXT: frame-setup VS1R_V killed $v1, killed $x12 :: (store (<vscale x 1 x s64>) into %stack.0)
73+
; CHECK-NEXT: frame-setup CFI_INSTRUCTION escape 0x10, 0x61, 0x08, 0x11, 0x7f, 0x92, 0xa2, 0x38, 0x00, 0x1e, 0x22
74+
; CHECK-NEXT: dead $x0 = PseudoVSETIVLI 4, 208 /* e32, m1, ta, ma */, implicit-def $vl, implicit-def $vtype
75+
; CHECK-NEXT: renamable $v1 = PseudoVLE32_V_M1 undef renamable $v1, killed renamable $x10, 4, 5 /* e32 */, 2 /* tu, ma */, implicit $vl, implicit $vtype
76+
; CHECK-NEXT: PseudoVSE32_V_M1 killed renamable $v1, killed renamable $x11, 4, 5 /* e32 */, implicit $vl, implicit $vtype
77+
; CHECK-NEXT: PseudoBR %bb.2
78+
bb.0.entry:
79+
liveins: $x10, $x11
80+
BEQ $x10, $x0, %bb.3
81+
82+
bb.1:
83+
PseudoRET
84+
85+
bb.2:
86+
PseudoBR %bb.1
87+
88+
bb.3:
89+
liveins: $x10, $x11
90+
dead $x0 = PseudoVSETIVLI 4, 208, implicit-def $vl, implicit-def $vtype
91+
renamable $v1 = PseudoVLE32_V_M1 undef renamable $v1, killed renamable $x10, 4, 5, 2, implicit $vl, implicit $vtype
92+
PseudoVSE32_V_M1 killed renamable $v1, killed renamable $x11, 4, 5, implicit $vl, implicit $vtype
93+
PseudoBR %bb.2
94+
...

0 commit comments

Comments
 (0)