Skip to content

Commit 1bd89b6

Browse files
committed
[move-only] Fix IRGen deinit test for stack changes.
1 parent 1dd896d commit 1bd89b6

File tree

1 file changed

+100
-24
lines changed

1 file changed

+100
-24
lines changed

test/IRGen/moveonly_deinits.swift

Lines changed: 100 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,26 @@ var value: Bool { false }
6363
//////////////////
6464

6565
// IR-LABEL: define {{.*}}swiftcc void @"$s16moveonly_deinits24testIntPairWithoutDeinityyF"()
66-
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
66+
// IR: [[ALLOCA:%.*]] = alloca [[TYPE:%T16moveonly_deinits20IntPairWithoutDeinitV]]
67+
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
6768
//
6869
// IR: [[BB1]]:
69-
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits27consumeIntPairWithoutDeinityyAA0defG0VnF"
70+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 0
71+
// IR-NEXT: [[GEP2:%.*]] = getelementptr inbounds %TSi, %TSi* [[GEP]], i32 0, i32 0
72+
// IR-NEXT: [[LHS:%.*]] = load i64, i64* [[GEP2]]
73+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 1
74+
// IR-NEXT: [[GEP2:%.*]] = getelementptr inbounds %TSi, %TSi* [[GEP]], i32 0, i32 0
75+
// IR-NEXT: [[RHS:%.*]] = load i64, i64* [[GEP2]]
76+
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits27consumeIntPairWithoutDeinityyAA0defG0VnF"(i64 [[LHS]], i64 [[RHS]])
7077
// IR-NEXT: br label %[[CONT:[0-9]+]]
7178
//
7279
// IR: [[BB2]]:
80+
// IR-NEXT: call [[TYPE]]* @"$s16moveonly_deinits20IntPairWithoutDeinitVWOh"([[TYPE]]* [[ALLOCA]])
7381
// IR-NEXT: br label %[[CONT]]
7482
//
7583
// IR: [[CONT]]:
84+
// IR-NEXT: bitcast
85+
// IR-NEXT: @llvm.lifetime.end
7686
// IR-NEXT: ret void
7787
// IR-NEXT: }
7888
public func testIntPairWithoutDeinit() {
@@ -83,17 +93,32 @@ public func testIntPairWithoutDeinit() {
8393
}
8494

8595
// IR-LABEL: define {{.*}}swiftcc void @"$s16moveonly_deinits21testIntPairWithDeinityyF"()
96+
// IR: [[ALLOCA:%.*]] = alloca [[TYPE:%T16moveonly_deinits17IntPairWithDeinitV]]
8697
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
8798
//
8899
// IR: [[BB1]]:
100+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 0
101+
// IR-NEXT: [[GEP2:%.*]] = getelementptr inbounds %TSi, %TSi* [[GEP]], i32 0, i32 0
102+
// IR-NEXT: [[LHS:%.*]] = load i64, i64* [[GEP2]]
103+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 1
104+
// IR-NEXT: [[GEP2:%.*]] = getelementptr inbounds %TSi, %TSi* [[GEP]], i32 0, i32 0
105+
// IR-NEXT: [[RHS:%.*]] = load i64, i64* [[GEP2]]
89106
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits24consumeIntPairWithDeinityyAA0defG0VnF"(
90107
// IR-NEXT: br label %[[CONT:[0-9]+]]
91108
//
92109
// IR: [[BB2]]:
93-
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits17IntPairWithDeinitVfD"(
110+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 0
111+
// IR-NEXT: [[GEP2:%.*]] = getelementptr inbounds %TSi, %TSi* [[GEP]], i32 0, i32 0
112+
// IR-NEXT: [[LHS:%.*]] = load i64, i64* [[GEP2]]
113+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 1
114+
// IR-NEXT: [[GEP2:%.*]] = getelementptr inbounds %TSi, %TSi* [[GEP]], i32 0, i32 0
115+
// IR-NEXT: [[RHS:%.*]] = load i64, i64* [[GEP2]]
116+
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits17IntPairWithDeinitVfD"(i64 [[LHS]], i64 [[RHS]])
94117
// IR-NEXT: br label %[[CONT]]
95118
//
96119
// IR: [[CONT]]
120+
// IR-NEXT: bitcast
121+
// IR-NEXT: @llvm.lifetime.end
97122
// IR-NEXT: ret void
98123
// IR-NEXT: }
99124
public func testIntPairWithDeinit() {
@@ -104,18 +129,24 @@ public func testIntPairWithDeinit() {
104129
}
105130

106131
// IR-LABEL: define {{.*}}swiftcc void @"$s16moveonly_deinits26testKlassPairWithoutDeinityyF"()
107-
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
132+
// IR: [[ALLOCA:%.*]] = alloca [[TYPE:%T16moveonly_deinits22KlassPairWithoutDeinitV]]
133+
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
108134
//
109135
// IR: [[BB1]]:
110-
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits29consumeKlassPairWithoutDeinityyAA0defG0VnF"
136+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 0
137+
// IR-NEXT: [[LHS:%.*]] = load [[KLASS:%T16moveonly_deinits5KlassC]]*, [[KLASS]]** [[GEP]]
138+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 1
139+
// IR-NEXT: [[RHS:%.*]] = load [[KLASS]]*, [[KLASS]]** [[GEP]]
140+
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits29consumeKlassPairWithoutDeinityyAA0defG0VnF"([[KLASS]]* [[LHS]], [[KLASS]]* [[RHS]])
111141
// IR-NEXT: br label %[[CONT:[0-9]+]]
112142
//
113143
// IR: [[BB2]]:
114-
// IR-NEXT: call void bitcast {{.*}} @swift_release
115-
// IR-NEXT: call void bitcast {{.*}} @swift_release
144+
// IR-NEXT: call [[TYPE]]* @"$s16moveonly_deinits22KlassPairWithoutDeinitVWOh"([[TYPE]]* [[ALLOCA]])
116145
// IR-NEXT: br label %[[CONT]]
117146
//
118147
// IR: [[CONT]]:
148+
// IR-NEXT: bitcast
149+
// IR-NEXT: call void
119150
// IR-NEXT: ret void
120151
// IR-NEXT: }
121152
public func testKlassPairWithoutDeinit() {
@@ -126,17 +157,28 @@ public func testKlassPairWithoutDeinit() {
126157
}
127158

128159
// IR-LABEL: define {{.*}}swiftcc void @"$s16moveonly_deinits23testKlassPairWithDeinityyF"()
129-
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
160+
// IR: [[ALLOCA:%.*]] = alloca [[TYPE:%T16moveonly_deinits19KlassPairWithDeinitV]]
161+
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
130162
//
131163
// IR: [[BB1]]:
132-
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits26consumeKlassPairWithDeinityyAA0defG0VnF"(
164+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 0
165+
// IR-NEXT: [[LHS:%.*]] = load [[KLASS:%T16moveonly_deinits5KlassC]]*, [[KLASS]]** [[GEP]]
166+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 1
167+
// IR-NEXT: [[RHS:%.*]] = load [[KLASS]]*, [[KLASS]]** [[GEP]]
168+
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits26consumeKlassPairWithDeinityyAA0defG0VnF"([[KLASS]]* [[LHS]], [[KLASS]]* [[RHS]])
133169
// IR-NEXT: br label %[[CONT:[0-9]+]]
134170
//
135171
// IR: [[BB2]]:
136-
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits19KlassPairWithDeinitVfD"(
172+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 0
173+
// IR-NEXT: [[LHS:%.*]] = load [[KLASS:%T16moveonly_deinits5KlassC]]*, [[KLASS]]** [[GEP]]
174+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 1
175+
// IR-NEXT: [[RHS:%.*]] = load [[KLASS]]*, [[KLASS]]** [[GEP]]
176+
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits19KlassPairWithDeinitVfD"([[KLASS]]* [[LHS]], [[KLASS]]* [[RHS]])
137177
// IR-NEXT: br label %[[CONT]]
138178
//
139179
// IR: [[CONT]]
180+
// IR-NEXT: bitcast
181+
// IR-NEXT: @llvm.lifetime.end
140182
// IR-NEXT: ret void
141183
// IR-NEXT: }
142184
public func testKlassPairWithDeinit() {
@@ -192,16 +234,25 @@ func consumeKlassEnumPairWithDeinit(_ x: __owned KlassEnumPairWithDeinit) { }
192234
////////////////
193235

194236
// IR-LABEL: define {{.*}}swiftcc void @"$s16moveonly_deinits28testIntEnumPairWithoutDeinityyF"()
195-
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
237+
// IR: [[ALLOCA:%.*]] = alloca [[TYPE:%T16moveonly_deinits24IntEnumPairWithoutDeinitO]]
238+
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
196239
//
197240
// IR: [[BB1]]:
198-
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits31consumeIntEnumPairWithoutDeinityyAA0defgH0OnF"
241+
// IR-NEXT: [[CAST:%.*]] = bitcast [[TYPE]]* [[ALLOCA]] to i64*
242+
// IR-NEXT: [[LHS:%.*]] = load i64, i64* [[CAST]]
243+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 1
244+
// IR-NEXT: [[BITCAST:%.*]] = bitcast [1 x i8]* [[GEP]] to i1*
245+
// IR-NEXT: [[RHS:%.*]] = load i1, i1* [[BITCAST]]
246+
// IR-NEXT: [[RHS_ZEXT:%.*]] = zext i1 [[RHS]]
247+
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits31consumeIntEnumPairWithoutDeinityyAA0defgH0OnF"(i64 [[LHS]], i8 [[RHS_ZEXT]])
199248
// IR-NEXT: br label %[[CONT:[0-9]+]]
200249
//
201250
// IR: [[BB2]]:
202251
// IR-NEXT: br label %[[CONT]]
203252
//
204253
// IR: [[CONT]]:
254+
// IR-NEXT: bitcast
255+
// IR-NEXT: call void @llvm.lifetime.end
205256
// IR-NEXT: ret void
206257
// IR-NEXT: }
207258
public func testIntEnumPairWithoutDeinit() {
@@ -212,17 +263,32 @@ public func testIntEnumPairWithoutDeinit() {
212263
}
213264

214265
// IR-LABEL: define {{.*}}swiftcc void @"$s16moveonly_deinits25testIntEnumPairWithDeinityyF"()
215-
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
266+
// IR: [[ALLOCA:%.*]] = alloca [[TYPE:%T16moveonly_deinits21IntEnumPairWithDeinitO]]
267+
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
216268
//
217269
// IR: [[BB1]]:
218-
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits28consumeIntEnumPairWithDeinityyAA0defgH0OnF"(
270+
// IR-NEXT: [[CAST:%.*]] = bitcast [[TYPE]]* [[ALLOCA]] to i64*
271+
// IR-NEXT: [[LHS:%.*]] = load i64, i64* [[CAST]]
272+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 1
273+
// IR-NEXT: [[BITCAST:%.*]] = bitcast [1 x i8]* [[GEP]] to i1*
274+
// IR-NEXT: [[RHS:%.*]] = load i1, i1* [[BITCAST]]
275+
// IR-NEXT: [[RHS_ZEXT:%.*]] = zext i1 [[RHS]]
276+
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits28consumeIntEnumPairWithDeinityyAA0defgH0OnF"(i64 [[LHS]], i8 [[RHS_ZEXT]])
219277
// IR-NEXT: br label %[[CONT:[0-9]+]]
220278
//
221279
// IR: [[BB2]]:
222-
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits21IntEnumPairWithDeinitOfD"(
280+
// IR-NEXT: [[CAST:%.*]] = bitcast [[TYPE]]* [[ALLOCA]] to i64*
281+
// IR-NEXT: [[LHS:%.*]] = load i64, i64* [[CAST]]
282+
// IR-NEXT: [[GEP:%.*]] = getelementptr inbounds [[TYPE]], [[TYPE]]* [[ALLOCA]], i32 0, i32 1
283+
// IR-NEXT: [[BITCAST:%.*]] = bitcast [1 x i8]* [[GEP]] to i1*
284+
// IR-NEXT: [[RHS:%.*]] = load i1, i1* [[BITCAST]]
285+
// IR-NEXT: [[RHS_ZEXT:%.*]] = zext i1 [[RHS]]
286+
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits21IntEnumPairWithDeinitOfD"(i64 [[LHS]], i8 [[RHS_ZEXT]])
223287
// IR-NEXT: br label %[[CONT]]
224288
//
225289
// IR: [[CONT]]
290+
// IR-NEXT: bitcast
291+
// IR-NEXT: @llvm.lifetime.end
226292
// IR-NEXT: ret void
227293
// IR-NEXT: }
228294
public func testIntEnumPairWithDeinit() {
@@ -233,19 +299,22 @@ public func testIntEnumPairWithDeinit() {
233299
}
234300

235301
// IR-LABEL: define {{.*}}swiftcc void @"$s16moveonly_deinits30testKlassEnumPairWithoutDeinityyF"()
236-
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
302+
// IR: [[ALLOCA:%.*]] = alloca [[TYPE:%T16moveonly_deinits26KlassEnumPairWithoutDeinitO]]
303+
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
237304
//
238305
// IR: [[BB1]]:
239-
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits33consumeKlassEnumPairWithoutDeinityyAA0defgH0OnF"
240-
// IR-NEXT: br label %[[CONT:[0-9]+]]
306+
// IR-NEXT: [[CAST:%.*]] = bitcast [[TYPE]]* [[ALLOCA]] to i64*
307+
// IR-NEXT: [[VALUE:%.*]] = load i64, i64* [[CAST]]
308+
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits33consumeKlassEnumPairWithoutDeinityyAA0defgH0OnF"(i64 [[VALUE]])
309+
// IR-NEXT: br label %[[CONT:[0-9]+]]
241310
//
242311
// IR: [[BB2]]:
243-
// IR-NEXT: and i64
244-
// IR-NEXT: inttoptr i64
245-
// IR-NEXT: call void{{.*}} @swift_release
312+
// IR-NEXT: call [[TYPE]]* @"$s16moveonly_deinits26KlassEnumPairWithoutDeinitOWOh"([[TYPE]]* [[ALLOCA]])
246313
// IR-NEXT: br label %[[CONT]]
247314
//
248315
// IR: [[CONT]]:
316+
// IR-NEXT: bitcast
317+
// IR-NEXT: @llvm.lifetime.end
249318
// IR-NEXT: ret void
250319
// IR-NEXT: }
251320
public func testKlassEnumPairWithoutDeinit() {
@@ -292,17 +361,24 @@ public func testKlassEnumPairWithoutDeinit() {
292361
// SIL: } // end sil function '$s16moveonly_deinits27testKlassEnumPairWithDeinityyF'
293362

294363
// IR-LABEL: define {{.*}}swiftcc void @"$s16moveonly_deinits27testKlassEnumPairWithDeinityyF"()
295-
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
364+
// IR: [[ALLOCA:%.*]] = alloca [[TYPE:%T16moveonly_deinits23KlassEnumPairWithDeinitO]]
365+
// IR: br i1 {{%.*}}, label %[[BB1:[0-9]+]], label %[[BB2:[0-9]+]]
296366
//
297367
// IR: [[BB1]]:
298-
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits30consumeKlassEnumPairWithDeinityyAA0defgH0OnF"(
368+
// IR-NEXT: [[CAST:%.*]] = bitcast [[TYPE]]* [[ALLOCA]] to i64*
369+
// IR-NEXT: [[LOAD:%.*]] = load i64, i64* [[CAST]]
370+
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits30consumeKlassEnumPairWithDeinityyAA0defgH0OnF"(i64 [[LOAD]])
299371
// IR-NEXT: br label %[[CONT:[0-9]+]]
300372
//
301373
// IR: [[BB2]]:
302-
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits23KlassEnumPairWithDeinitOfD"(
374+
// IR-NEXT: [[CAST:%.*]] = bitcast [[TYPE]]* [[ALLOCA]] to i64*
375+
// IR-NEXT: [[LOAD:%.*]] = load i64, i64* [[CAST]]
376+
// IR-NEXT: call swiftcc void @"$s16moveonly_deinits23KlassEnumPairWithDeinitOfD"(i64 [[LOAD]])
303377
// IR-NEXT: br label %[[CONT]]
304378
//
305379
// IR: [[CONT]]
380+
// IR-NEXT: bitcast
381+
// IR-NEXT: @llvm.lifetime.end
306382
// IR-NEXT: ret void
307383
// IR-NEXT: }
308384
public func testKlassEnumPairWithDeinit() {

0 commit comments

Comments
 (0)