Skip to content

Commit 7a9d84e

Browse files
committed
Test showing incorrect codegen
1 parent d09632b commit 7a9d84e

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2+
# RUN: llc -mtriple aarch64-none-elf -mattr=+mte --run-pass=aarch64-ldst-opt %s -o - | FileCheck %s
3+
4+
## When generating code with sanitize_memtag, we make use of the fact that the
5+
## sp+imm forms of many load and store instructions are not tag-checked, so we
6+
## can use SP directly instead of needing a register holding the tagged
7+
## pointer. However, this isn't true for the writeback versions of the
8+
## instructions, so we can't fold ADDs and SUBs into them in
9+
## AArch64LoadStoreOptimizer. This would be possible in cases where the
10+
## loads/stores only access untagged stack slots, but that information isn't
11+
## easily available after frame index elimination.
12+
13+
--- |
14+
define void @pre_index() {
15+
entry:
16+
ret void
17+
}
18+
define void @pre_index_memtag() sanitize_memtag {
19+
entry:
20+
ret void
21+
}
22+
define void @pre_index_memtag_not_sp() sanitize_memtag {
23+
entry:
24+
ret void
25+
}
26+
define void @post_index() {
27+
entry:
28+
ret void
29+
}
30+
define void @post_index_memtag() sanitize_memtag {
31+
entry:
32+
ret void
33+
}
34+
define void @post_index_memtag_not_sp() sanitize_memtag {
35+
entry:
36+
ret void
37+
}
38+
...
39+
---
40+
name: pre_index
41+
body: |
42+
bb.0.entry:
43+
liveins: $x0
44+
45+
; CHECK-LABEL: name: pre_index
46+
; CHECK: liveins: $x0
47+
; CHECK-NEXT: {{ $}}
48+
; CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0
49+
; CHECK-NEXT: early-clobber $sp = STRXpre killed renamable $x0, $sp, 16
50+
; CHECK-NEXT: RET undef $lr
51+
$sp = frame-setup SUBXri $sp, 16, 0
52+
STRXui killed renamable $x0, $sp, 2
53+
$sp = ADDXri $sp, 16, 0
54+
RET undef $lr
55+
...
56+
---
57+
name: pre_index_memtag
58+
body: |
59+
bb.0.entry:
60+
liveins: $x0
61+
62+
; CHECK-LABEL: name: pre_index_memtag
63+
; CHECK: liveins: $x0
64+
; CHECK-NEXT: {{ $}}
65+
; CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0
66+
; CHECK-NEXT: early-clobber $sp = STRXpre killed renamable $x0, $sp, 16
67+
; CHECK-NEXT: RET undef $lr
68+
$sp = frame-setup SUBXri $sp, 16, 0
69+
STRXui killed renamable $x0, $sp, 2
70+
$sp = ADDXri $sp, 16, 0
71+
RET undef $lr
72+
...
73+
---
74+
name: pre_index_memtag_not_sp
75+
body: |
76+
bb.0.entry:
77+
liveins: $x0, $x1
78+
79+
; CHECK-LABEL: name: pre_index_memtag_not_sp
80+
; CHECK: liveins: $x0, $x1
81+
; CHECK-NEXT: {{ $}}
82+
; CHECK-NEXT: $x1 = frame-setup SUBXri $x1, 16, 0
83+
; CHECK-NEXT: early-clobber $x1 = STRXpre killed renamable $x0, $x1, 16
84+
; CHECK-NEXT: RET undef $lr, implicit $x1
85+
$x1 = frame-setup SUBXri $x1, 16, 0
86+
STRXui killed renamable $x0, $x1, 2
87+
$x1 = ADDXri $x1, 16, 0
88+
RET undef $lr, implicit $x1
89+
...
90+
---
91+
name: post_index
92+
body: |
93+
bb.0.entry:
94+
liveins: $x0
95+
96+
; CHECK-LABEL: name: post_index
97+
; CHECK: liveins: $x0
98+
; CHECK-NEXT: {{ $}}
99+
; CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0
100+
; CHECK-NEXT: early-clobber $sp = STRXpost killed renamable $x0, $sp, 16
101+
; CHECK-NEXT: RET undef $lr
102+
$sp = frame-setup SUBXri $sp, 16, 0
103+
STRXui killed renamable $x0, $sp, 0
104+
$sp = ADDXri $sp, 16, 0
105+
RET undef $lr
106+
...
107+
---
108+
name: post_index_memtag
109+
body: |
110+
bb.0.entry:
111+
liveins: $x0
112+
113+
; CHECK-LABEL: name: post_index_memtag
114+
; CHECK: liveins: $x0
115+
; CHECK-NEXT: {{ $}}
116+
; CHECK-NEXT: $sp = frame-setup SUBXri $sp, 16, 0
117+
; CHECK-NEXT: early-clobber $sp = STRXpost killed renamable $x0, $sp, 16
118+
; CHECK-NEXT: RET undef $lr
119+
$sp = frame-setup SUBXri $sp, 16, 0
120+
STRXui killed renamable $x0, $sp, 0
121+
$sp = ADDXri $sp, 16, 0
122+
RET undef $lr
123+
...
124+
---
125+
name: post_index_memtag_not_sp
126+
body: |
127+
bb.0.entry:
128+
liveins: $x0, $x1
129+
130+
; CHECK-LABEL: name: post_index_memtag_not_sp
131+
; CHECK: liveins: $x0, $x1
132+
; CHECK-NEXT: {{ $}}
133+
; CHECK-NEXT: $x1 = frame-setup SUBXri $x1, 16, 0
134+
; CHECK-NEXT: early-clobber $x1 = STRXpost killed renamable $x0, $x1, 16
135+
; CHECK-NEXT: RET undef $lr, implicit $x1
136+
$x1 = frame-setup SUBXri $x1, 16, 0
137+
STRXui killed renamable $x0, $x1, 0
138+
$x1 = ADDXri $x1, 16, 0
139+
RET undef $lr, implicit $x1
140+
...

0 commit comments

Comments
 (0)