Skip to content

Commit ec79a47

Browse files
nickdesaulnierststellar
authored andcommitted
[CodeGen] precommit machine-latecleanup test
Demonstrates a hazard in machine-latecleanup. Differential Revision: https://reviews.llvm.org/D149190 (cherry picked from commit 095a0c6) [nd: remove isOutlined MIR key due to missing commit 267708f ("[MachineOutliner] Add IsOutlined to MachineFunction")]
1 parent bd6783b commit ec79a47

File tree

1 file changed

+259
-0
lines changed

1 file changed

+259
-0
lines changed
Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,259 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
2+
# RUN: llc -start-before=machine-latecleanup -stop-after=machine-latecleanup \
3+
# RUN: -o - %s | FileCheck %s
4+
--- |
5+
; ModuleID = 'reduced5.ll'
6+
source_filename = "reduced5.ll"
7+
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
8+
target triple = "aarch64-unknown-linux-gnu"
9+
10+
; Function Attrs: nounwind
11+
define void @zot(ptr %arg, ptr %arg1, ptr %arg2, i64 %arg3, i1 %arg4, ptr %arg5) #0 {
12+
bb:
13+
%const = bitcast i64 29273397577910035 to i64
14+
callbr void asm sideeffect "b $0", "!i"()
15+
to label %bb9 [label %bb8]
16+
17+
bb8: ; preds = %bb
18+
%const_mat = add i64 %const, 2048
19+
br label %bb9
20+
21+
bb9: ; preds = %bb8, %bb
22+
%phi = phi i64 [ %const_mat, %bb8 ], [ %const, %bb ]
23+
store volatile i64 %phi, ptr null, align 8
24+
br label %bb10
25+
26+
bb10: ; preds = %bb22, %bb9
27+
%phi11 = phi i64 [ 0, %bb9 ], [ %or24, %bb22 ]
28+
%phi12 = phi i64 [ 0, %bb9 ], [ %select, %bb22 ]
29+
%load = load volatile i64, ptr %arg2, align 8
30+
%select = select i1 %arg4, i64 %arg3, i64 0
31+
store i64 %const, ptr %arg5, align 8
32+
%call = call i64 %arg()
33+
callbr void asm sideeffect "", "!i"()
34+
to label %bb22 [label %bb22]
35+
36+
bb22: ; preds = %bb10, %bb10
37+
store i64 0, ptr %arg1, align 8
38+
store volatile i64 1, ptr null, align 8
39+
%or = or i64 %phi11, 0
40+
%or24 = or i64 %phi11, %phi12
41+
br label %bb10
42+
}
43+
44+
attributes #0 = { nounwind "frame-pointer"="non-leaf" }
45+
46+
...
47+
---
48+
name: zot
49+
alignment: 4
50+
exposesReturnsTwice: false
51+
legalized: false
52+
regBankSelected: false
53+
selected: false
54+
failedISel: false
55+
tracksRegLiveness: true
56+
hasWinCFI: false
57+
callsEHReturn: false
58+
callsUnwindInit: false
59+
hasEHCatchret: false
60+
hasEHScopes: false
61+
hasEHFunclets: false
62+
debugInstrRef: false
63+
failsVerification: false
64+
tracksDebugUserValues: true
65+
registers: []
66+
liveins:
67+
- { reg: '$x0', virtual-reg: '' }
68+
- { reg: '$x1', virtual-reg: '' }
69+
- { reg: '$x2', virtual-reg: '' }
70+
- { reg: '$x3', virtual-reg: '' }
71+
- { reg: '$w4', virtual-reg: '' }
72+
- { reg: '$x5', virtual-reg: '' }
73+
frameInfo:
74+
isFrameAddressTaken: false
75+
isReturnAddressTaken: false
76+
hasStackMap: false
77+
hasPatchPoint: false
78+
stackSize: 96
79+
offsetAdjustment: 0
80+
maxAlignment: 8
81+
adjustsStack: true
82+
hasCalls: true
83+
stackProtector: ''
84+
functionContext: ''
85+
maxCallFrameSize: 0
86+
cvBytesOfCalleeSavedRegisters: 0
87+
hasOpaqueSPAdjustment: false
88+
hasVAStart: false
89+
hasMustTailInVarArgFunc: false
90+
hasTailCall: false
91+
localFrameSize: 0
92+
savePoint: ''
93+
restorePoint: ''
94+
fixedStack: []
95+
stack:
96+
- { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8,
97+
stack-id: default, callee-saved-register: '$x19', callee-saved-restored: true,
98+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
99+
- { id: 1, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8,
100+
stack-id: default, callee-saved-register: '$x20', callee-saved-restored: true,
101+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
102+
- { id: 2, name: '', type: spill-slot, offset: -24, size: 8, alignment: 8,
103+
stack-id: default, callee-saved-register: '$x21', callee-saved-restored: true,
104+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
105+
- { id: 3, name: '', type: spill-slot, offset: -32, size: 8, alignment: 8,
106+
stack-id: default, callee-saved-register: '$x22', callee-saved-restored: true,
107+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
108+
- { id: 4, name: '', type: spill-slot, offset: -40, size: 8, alignment: 8,
109+
stack-id: default, callee-saved-register: '$x23', callee-saved-restored: true,
110+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
111+
- { id: 5, name: '', type: spill-slot, offset: -48, size: 8, alignment: 8,
112+
stack-id: default, callee-saved-register: '$x24', callee-saved-restored: true,
113+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
114+
- { id: 6, name: '', type: spill-slot, offset: -56, size: 8, alignment: 8,
115+
stack-id: default, callee-saved-register: '$x25', callee-saved-restored: true,
116+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
117+
- { id: 7, name: '', type: spill-slot, offset: -64, size: 8, alignment: 8,
118+
stack-id: default, callee-saved-register: '$x26', callee-saved-restored: true,
119+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
120+
- { id: 8, name: '', type: spill-slot, offset: -72, size: 8, alignment: 8,
121+
stack-id: default, callee-saved-register: '$x27', callee-saved-restored: true,
122+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
123+
- { id: 9, name: '', type: spill-slot, offset: -80, size: 8, alignment: 8,
124+
stack-id: default, callee-saved-register: '$x28', callee-saved-restored: true,
125+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
126+
- { id: 10, name: '', type: spill-slot, offset: -88, size: 8, alignment: 8,
127+
stack-id: default, callee-saved-register: '$lr', callee-saved-restored: true,
128+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
129+
- { id: 11, name: '', type: spill-slot, offset: -96, size: 8, alignment: 8,
130+
stack-id: default, callee-saved-register: '$fp', callee-saved-restored: true,
131+
debug-info-variable: '', debug-info-expression: '', debug-info-location: '' }
132+
callSites: []
133+
debugValueSubstitutions: []
134+
constants: []
135+
machineFunctionInfo:
136+
hasRedZone: false
137+
body: |
138+
; CHECK-LABEL: name: zot
139+
; CHECK: bb.0.bb:
140+
; CHECK-NEXT: successors: %bb.2(0x80000000), %bb.1(0x00000000)
141+
; CHECK-NEXT: liveins: $w4, $x0, $x1, $x2, $x3, $x5, $lr, $x27, $x28, $x25, $x26, $x23, $x24, $x21, $x22, $x19, $x20
142+
; CHECK-NEXT: {{ $}}
143+
; CHECK-NEXT: early-clobber $sp = frame-setup STPXpre killed $fp, killed $lr, $sp, -12 :: (store (s64) into %stack.11), (store (s64) into %stack.10)
144+
; CHECK-NEXT: frame-setup STPXi killed $x28, killed $x27, $sp, 2 :: (store (s64) into %stack.9), (store (s64) into %stack.8)
145+
; CHECK-NEXT: frame-setup STPXi killed $x26, killed $x25, $sp, 4 :: (store (s64) into %stack.7), (store (s64) into %stack.6)
146+
; CHECK-NEXT: frame-setup STPXi killed $x24, killed $x23, $sp, 6 :: (store (s64) into %stack.5), (store (s64) into %stack.4)
147+
; CHECK-NEXT: frame-setup STPXi killed $x22, killed $x21, $sp, 8 :: (store (s64) into %stack.3), (store (s64) into %stack.2)
148+
; CHECK-NEXT: frame-setup STPXi killed $x20, killed $x19, $sp, 10 :: (store (s64) into %stack.1), (store (s64) into %stack.0)
149+
; CHECK-NEXT: $fp = frame-setup ADDXri $sp, 0, 0
150+
; CHECK-NEXT: renamable $x19 = COPY $x5
151+
; CHECK-NEXT: renamable $w20 = COPY $w4
152+
; CHECK-NEXT: renamable $x21 = COPY $x3
153+
; CHECK-NEXT: renamable $x22 = COPY $x2
154+
; CHECK-NEXT: renamable $x23 = COPY $x1
155+
; CHECK-NEXT: renamable $x24 = COPY $x0
156+
; CHECK-NEXT: INLINEASM_BR &"b $0", 1 /* sideeffect attdialect */, 13 /* imm */, %bb.1
157+
; CHECK-NEXT: renamable $x8 = MOVi64imm 29273397577910035
158+
; CHECK-NEXT: B %bb.2
159+
; CHECK-NEXT: {{ $}}
160+
; CHECK-NEXT: bb.1.bb8 (machine-block-address-taken, inlineasm-br-indirect-target):
161+
; CHECK-NEXT: successors: %bb.2(0x80000000)
162+
; CHECK-NEXT: liveins: $w20, $x19, $x21, $x22, $x23, $x24, $x8
163+
; CHECK-NEXT: {{ $}}
164+
; CHECK-NEXT: renamable $x8 = ADDXri killed renamable $x8, 2048, 0
165+
; CHECK-NEXT: {{ $}}
166+
; CHECK-NEXT: bb.2.bb9:
167+
; CHECK-NEXT: successors: %bb.3(0x80000000)
168+
; CHECK-NEXT: liveins: $w20, $x8, $x19, $x21, $x22, $x23, $x24
169+
; CHECK-NEXT: {{ $}}
170+
; CHECK-NEXT: renamable $x25 = COPY $xzr
171+
; CHECK-NEXT: renamable $w27 = MOVi32imm 1, implicit-def $x27
172+
; CHECK-NEXT: renamable $x26 = COPY $xzr
173+
; CHECK-NEXT: STRXui killed renamable $x8, renamable $x25, 0 :: (volatile store (s64) into `ptr null`)
174+
; CHECK-NEXT: {{ $}}
175+
; CHECK-NEXT: bb.3.bb10:
176+
; CHECK-NEXT: successors: %bb.4(0x80000000)
177+
; CHECK-NEXT: liveins: $w20, $x19, $x21, $x22, $x23, $x24, $x25, $x26, $x27
178+
; CHECK-NEXT: {{ $}}
179+
; CHECK-NEXT: dead $wzr = ANDSWri renamable $w20, 0, implicit-def $nzcv
180+
; CHECK-NEXT: dead $xzr = LDRXui renamable $x22, 0 :: (volatile load (s64) from %ir.arg2)
181+
; CHECK-NEXT: renamable $x28 = CSELXr renamable $x21, $xzr, 1, implicit killed $nzcv
182+
; CHECK-NEXT: renamable $x8 = MOVi64imm 29273397577910035
183+
; CHECK-NEXT: STRXui killed renamable $x8, renamable $x19, 0 :: (store (s64) into %ir.arg5)
184+
; CHECK-NEXT: BLR renamable $x24, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def dead $x0
185+
; CHECK-NEXT: INLINEASM_BR &"", 1 /* sideeffect attdialect */, 13 /* imm */, %bb.4
186+
; CHECK-NEXT: B %bb.4
187+
; CHECK-NEXT: {{ $}}
188+
; CHECK-NEXT: bb.4.bb22 (machine-block-address-taken, inlineasm-br-indirect-target):
189+
; CHECK-NEXT: successors: %bb.3(0x80000000)
190+
; CHECK-NEXT: liveins: $w20, $x19, $x21, $x22, $x23, $x24, $x25, $x26, $x27, $x28
191+
; CHECK-NEXT: {{ $}}
192+
; CHECK-NEXT: renamable $x8 = COPY $xzr
193+
; CHECK-NEXT: renamable $x25 = ORRXrr killed renamable $x25, killed renamable $x26
194+
; CHECK-NEXT: renamable $x26 = COPY killed renamable $x28
195+
; CHECK-NEXT: STRXui $xzr, renamable $x23, 0 :: (store (s64) into %ir.arg1)
196+
; CHECK-NEXT: STRXui renamable $x27, killed renamable $x8, 0 :: (volatile store (s64) into `ptr null`)
197+
; CHECK-NEXT: B %bb.3
198+
bb.0.bb:
199+
successors: %bb.2(0x80000000), %bb.1(0x00000000)
200+
liveins: $w4, $x0, $x1, $x2, $x3, $x5, $lr, $x27, $x28, $x25, $x26, $x23, $x24, $x21, $x22, $x19, $x20
201+
202+
early-clobber $sp = frame-setup STPXpre killed $fp, killed $lr, $sp, -12 :: (store (s64) into %stack.11), (store (s64) into %stack.10)
203+
frame-setup STPXi killed $x28, killed $x27, $sp, 2 :: (store (s64) into %stack.9), (store (s64) into %stack.8)
204+
frame-setup STPXi killed $x26, killed $x25, $sp, 4 :: (store (s64) into %stack.7), (store (s64) into %stack.6)
205+
frame-setup STPXi killed $x24, killed $x23, $sp, 6 :: (store (s64) into %stack.5), (store (s64) into %stack.4)
206+
frame-setup STPXi killed $x22, killed $x21, $sp, 8 :: (store (s64) into %stack.3), (store (s64) into %stack.2)
207+
frame-setup STPXi killed $x20, killed $x19, $sp, 10 :: (store (s64) into %stack.1), (store (s64) into %stack.0)
208+
$fp = frame-setup ADDXri $sp, 0, 0
209+
renamable $x19 = COPY $x5
210+
renamable $w20 = COPY $w4
211+
renamable $x21 = COPY $x3
212+
renamable $x22 = COPY $x2
213+
renamable $x23 = COPY $x1
214+
renamable $x24 = COPY $x0
215+
INLINEASM_BR &"b $0", 1 /* sideeffect attdialect */, 13 /* imm */, %bb.1
216+
renamable $x8 = MOVi64imm 29273397577910035
217+
B %bb.2
218+
219+
bb.1.bb8 (machine-block-address-taken, inlineasm-br-indirect-target):
220+
successors: %bb.2(0x80000000)
221+
liveins: $w20, $x19, $x21, $x22, $x23, $x24
222+
223+
renamable $x8 = MOVi64imm 29273397577910035
224+
renamable $x8 = ADDXri killed renamable $x8, 2048, 0
225+
226+
bb.2.bb9:
227+
successors: %bb.3(0x80000000)
228+
liveins: $w20, $x8, $x19, $x21, $x22, $x23, $x24
229+
230+
renamable $x25 = COPY $xzr
231+
renamable $w27 = MOVi32imm 1, implicit-def $x27
232+
renamable $x26 = COPY $xzr
233+
STRXui killed renamable $x8, renamable $x25, 0 :: (volatile store (s64) into `ptr null`)
234+
235+
bb.3.bb10:
236+
successors: %bb.4(0x80000000)
237+
liveins: $w20, $x19, $x21, $x22, $x23, $x24, $x25, $x26, $x27
238+
239+
dead $wzr = ANDSWri renamable $w20, 0, implicit-def $nzcv
240+
dead $xzr = LDRXui renamable $x22, 0 :: (volatile load (s64) from %ir.arg2)
241+
renamable $x28 = CSELXr renamable $x21, $xzr, 1, implicit killed $nzcv
242+
renamable $x8 = MOVi64imm 29273397577910035
243+
STRXui killed renamable $x8, renamable $x19, 0 :: (store (s64) into %ir.arg5)
244+
BLR renamable $x24, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def dead $x0
245+
INLINEASM_BR &"", 1 /* sideeffect attdialect */, 13 /* imm */, %bb.4
246+
B %bb.4
247+
248+
bb.4.bb22 (machine-block-address-taken, inlineasm-br-indirect-target):
249+
successors: %bb.3(0x80000000)
250+
liveins: $w20, $x19, $x21, $x22, $x23, $x24, $x25, $x26, $x27, $x28
251+
252+
renamable $x8 = COPY $xzr
253+
renamable $x25 = ORRXrr killed renamable $x25, killed renamable $x26
254+
renamable $x26 = COPY killed renamable $x28
255+
STRXui $xzr, renamable $x23, 0 :: (store (s64) into %ir.arg1)
256+
STRXui renamable $x27, killed renamable $x8, 0 :: (volatile store (s64) into `ptr null`)
257+
B %bb.3
258+
259+
...

0 commit comments

Comments
 (0)