Skip to content

Commit 176ba99

Browse files
committed
Don't run the stand-alone devirtualization and specialization passes.
They aren't needed at the moment, and running the specialization pass early might have resulted in some performance regressions. We can add these back in (and in the appropriate place in the pipeline) when the changes to unbundle this functionality from the inliner goes in.
1 parent 0ce9ad9 commit 176ba99

File tree

2 files changed

+91
-88
lines changed

2 files changed

+91
-88
lines changed

lib/SILOptimizer/PassManager/Passes.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ void swift::runSILOptimizationPasses(SILModule &Module) {
251251

252252
// Run two iterations of the high-level SSA passes.
253253
PM.setStageName("HighLevel");
254-
PM.addDevirtualizer();
255-
PM.addGenericSpecializer();
256254
AddSSAPasses(PM, OptimizationLevelKind::HighLevel);
257255
PM.runOneIteration();
258256
PM.runOneIteration();

test/SILOptimizer/specialize_unconditional_checked_cast.swift

Lines changed: 91 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -33,48 +33,48 @@ ArchetypeToArchetype(t: d, t2: c)
3333
ArchetypeToArchetype(t: c, t2: e)
3434
ArchetypeToArchetype(t: b, t2: f)
3535

36-
// x -> x where x is not a class.
37-
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8_S____TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out UInt8, @in UInt8, @in UInt8) -> () {
36+
// x -> y where x and y are unrelated non classes.
37+
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8_Vs6UInt64___TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out UInt64, @in UInt8, @in UInt64) -> () {
3838
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
39-
40-
// x -> x where x is a class.
41-
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C_S0____TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out C, @in C, @in C) -> () {
39+
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
40+
// CHECK: builtin "int_trap"
4241
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
4342

44-
// x -> y where x is not a class but y is.
45-
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8_C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out C, @in UInt8, @in C) -> () {
46-
// CHECK-NOT: unconditional_checked_cast_addr
47-
// CHECK-NOT: unconditional_checked_cast_addr
48-
// CHECK: builtin "int_trap"
49-
// CHECK-NOT: unconditional_checked_cast_addr
50-
51-
// y -> x where x is not a class but y is.
52-
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C_Vs5UInt8___TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out UInt8, @in C, @in UInt8) -> () {
43+
// x -> y where x and y are unrelated classes.
44+
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C_CS_1E___TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out E, @in C, @in E) -> () {
5345
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
5446
// CHECK: builtin "int_trap"
5547
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
5648

57-
// x -> y where x is a super class of y.
58-
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C_CS_1D___TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out D, @in C, @in D) -> () {
59-
// CHECK: unconditional_checked_cast_addr take_always C in %1 : $*C to D in
60-
6149
// y -> x where x is a super class of y.
6250
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1D_CS_1C___TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out C, @in D, @in C) -> () {
6351
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
6452
// CHECK: upcast {{%[0-9]+}} : $D to $C
6553
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
6654

67-
// x -> y where x and y are unrelated classes.
68-
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C_CS_1E___TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out E, @in C, @in E) -> () {
55+
// x -> y where x is a super class of y.
56+
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C_CS_1D___TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out D, @in C, @in D) -> () {
57+
// CHECK: unconditional_checked_cast_addr take_always C in %1 : $*C to D in
58+
59+
// y -> x where x is not a class but y is.
60+
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C_Vs5UInt8___TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out UInt8, @in C, @in UInt8) -> () {
6961
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
7062
// CHECK: builtin "int_trap"
7163
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
7264

73-
// x -> y where x and y are unrelated non classes.
74-
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8_Vs6UInt64___TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out UInt64, @in UInt8, @in UInt64) -> () {
75-
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
65+
// x -> y where x is not a class but y is.
66+
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8_C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out C, @in UInt8, @in C) -> () {
67+
// CHECK-NOT: unconditional_checked_cast_addr
68+
// CHECK-NOT: unconditional_checked_cast_addr
69+
// CHECK: builtin "int_trap"
70+
// CHECK-NOT: unconditional_checked_cast_addr
71+
72+
// x -> x where x is a class.
73+
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C_S0____TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out C, @in C, @in C) -> () {
7674
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
77-
// CHECK: builtin "int_trap"
75+
76+
// x -> x where x is not a class.
77+
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8_S____TF37specialize_unconditional_checked_cast20ArchetypeToArchetype{{.*}} : $@convention(thin) (@out UInt8, @in UInt8, @in UInt8) -> () {
7878
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
7979

8080

@@ -90,26 +90,29 @@ ArchetypeToConcreteConvertUInt8(t: b)
9090
ArchetypeToConcreteConvertUInt8(t: c)
9191
ArchetypeToConcreteConvertUInt8(t: f)
9292

93+
// order 57%
9394
// x -> x where x is not a class.
9495
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8___TF37specialize_unconditional_checked_cast31ArchetypeToConcreteConvertUInt8{{.*}} : $@convention(thin) (@in UInt8) -> UInt8 {
9596
// CHECK: bb0
9697
// CHECK-NEXT: debug_value_addr
9798
// CHECK-NEXT: load
9899
// CHECK-NEXT: return
99100

100-
// x -> x where x is a class.
101-
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC{{.*}} : $@convention(thin) (@in C) -> @owned C {
101+
// order: 59%
102+
// x -> y where x,y are classes and x is a super class of y.
103+
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1D___TF37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC{{.*}} : $@convention(thin) (@in D) -> @owned C {
102104
// CHECK: bb0
103105
// CHECK-NEXT: debug_value_addr
104106
// CHECK-NEXT: load
107+
// CHECK-NEXT: upcast
105108
// CHECK-NEXT: return
106109

107-
// x -> y where x,y are classes and x is a super class of y.
108-
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1D___TF37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC{{.*}} : $@convention(thin) (@in D) -> @owned C {
110+
// order: 60%
111+
// x -> x where x is a class.
112+
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC{{.*}} : $@convention(thin) (@in C) -> @owned C {
109113
// CHECK: bb0
110114
// CHECK-NEXT: debug_value_addr
111115
// CHECK-NEXT: load
112-
// CHECK-NEXT: upcast
113116
// CHECK-NEXT: return
114117

115118

@@ -164,13 +167,12 @@ ConcreteToArchetypeConvertUInt8(t: b, t2: b)
164167
ConcreteToArchetypeConvertUInt8(t: b, t2: c)
165168
ConcreteToArchetypeConvertUInt8(t: b, t2: f)
166169

167-
// x -> x where x is not a class.
168-
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8___TF37specialize_unconditional_checked_cast31ConcreteToArchetypeConvertUInt8{{.*}} : $@convention(thin) (@out UInt8, UInt8, @in UInt8) -> () {
170+
// x -> y where x,y are different non class types.
171+
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs6UInt64___TF37specialize_unconditional_checked_cast31ConcreteToArchetypeConvertUInt8{{.*}} : $@convention(thin) (@out UInt64, UInt8, @in UInt64) -> () {
169172
// CHECK: bb0
170-
// CHECK-NEXT: debug_value
171-
// CHECK-NEXT: store
172-
// CHECK-NEXT: tuple
173-
// CHECK-NEXT: return
173+
// CHECK: builtin "int_trap"
174+
// CHECK: unreachable
175+
// CHECK-NEXT: }
174176

175177
// x -> y where x is not a class but y is a class.
176178
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast31ConcreteToArchetypeConvertUInt8{{.*}} : $@convention(thin) (@out C, UInt8, @in C) -> () {
@@ -179,12 +181,13 @@ ConcreteToArchetypeConvertUInt8(t: b, t2: f)
179181
// CHECK: unreachable
180182
// CHECK-NEXT: }
181183

182-
// x -> y where x,y are different non class types.
183-
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs6UInt64___TF37specialize_unconditional_checked_cast31ConcreteToArchetypeConvertUInt8{{.*}} : $@convention(thin) (@out UInt64, UInt8, @in UInt64) -> () {
184+
// x -> x where x is not a class.
185+
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8___TF37specialize_unconditional_checked_cast31ConcreteToArchetypeConvertUInt8{{.*}} : $@convention(thin) (@out UInt8, UInt8, @in UInt8) -> () {
184186
// CHECK: bb0
185-
// CHECK: builtin "int_trap"
186-
// CHECK: unreachable
187-
// CHECK-NEXT: }
187+
// CHECK-NEXT: debug_value
188+
// CHECK-NEXT: store
189+
// CHECK-NEXT: tuple
190+
// CHECK-NEXT: return
188191

189192
@inline(never)
190193
public func ConcreteToArchetypeConvertC<T>(t t: C, t2: T) -> T {
@@ -196,15 +199,26 @@ ConcreteToArchetypeConvertC(t: c, t2: b)
196199
ConcreteToArchetypeConvertC(t: c, t2: d)
197200
ConcreteToArchetypeConvertC(t: c, t2: e)
198201

202+
// x -> y where x and y are unrelated classes.
203+
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1E___TF37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertC{{.*}} : $@convention(thin) (@out E, @owned C, @in E) -> () {
204+
// CHECK: bb0
205+
// CHECK-NEXT: builtin "int_trap"
206+
// CHECK: unreachable
207+
// CHECK-NEXT: }
199208

200-
// x -> x where x is a class.
201-
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertC{{.*}} : $@convention(thin) (@out C, @owned C, @in C) -> () {
209+
// x -> y where x is a super class of y.
210+
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1D___TF37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertC{{.*}} : $@convention(thin) (@out D, @owned C, @in D) -> () {
202211
// CHECK: bb0
203212
// CHECK-NEXT: debug_value
204213
// CHECK-NEXT: debug_value_addr
214+
// CHECK-NEXT: alloc_stack
205215
// CHECK-NEXT: store
216+
// CHECK-NEXT: strong_retain
217+
// CHECK-NEXT: unconditional_checked_cast_addr take_always
218+
// CHECK-NEXT: dealloc_stack
206219
// CHECK-NEXT: load
207220
// CHECK-NEXT: strong_release
221+
// CHECK-NEXT: strong_release
208222
// CHECK-NEXT: tuple
209223
// CHECK-NEXT: return
210224

@@ -215,30 +229,17 @@ ConcreteToArchetypeConvertC(t: c, t2: e)
215229
// CHECK: unreachable
216230
// CHECK-NEXT: }
217231

218-
// x -> y where x is a super class of y.
219-
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1D___TF37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertC{{.*}} : $@convention(thin) (@out D, @owned C, @in D) -> () {
232+
// x -> x where x is a class.
233+
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertC{{.*}} : $@convention(thin) (@out C, @owned C, @in C) -> () {
220234
// CHECK: bb0
221235
// CHECK-NEXT: debug_value
222236
// CHECK-NEXT: debug_value_addr
223-
// CHECK-NEXT: alloc_stack
224237
// CHECK-NEXT: store
225-
// CHECK-NEXT: strong_retain
226-
// CHECK-NEXT: unconditional_checked_cast_addr take_always
227-
// CHECK-NEXT: dealloc_stack
228238
// CHECK-NEXT: load
229239
// CHECK-NEXT: strong_release
230-
// CHECK-NEXT: strong_release
231240
// CHECK-NEXT: tuple
232241
// CHECK-NEXT: return
233242

234-
// x -> y where x and y are unrelated classes.
235-
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1E___TF37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertC{{.*}} : $@convention(thin) (@out E, @owned C, @in E) -> () {
236-
// CHECK: bb0
237-
// CHECK-NEXT: builtin "int_trap"
238-
// CHECK-NEXT: store undef to %0 : $*E
239-
// CHECK: unreachable
240-
// CHECK-NEXT: }
241-
242243
@inline(never)
243244
public func ConcreteToArchetypeConvertD<T>(t t: D, t2: T) -> T {
244245
return t as! T
@@ -272,6 +273,17 @@ SuperToArchetypeC(c: c, t: c)
272273
SuperToArchetypeC(c: c, t: d)
273274
SuperToArchetypeC(c: c, t: b)
274275

276+
// x -> y where x is a class and y is not.
277+
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8___TF37specialize_unconditional_checked_cast17SuperToArchetypeC{{.*}} : $@convention(thin) (@out UInt8, @owned C, @in UInt8) -> () {
278+
// CHECK: bb0
279+
// CHECK: builtin "int_trap"
280+
// CHECK: unreachable
281+
// CHECK-NEXT: }
282+
283+
// x -> y where x is a super class of y.
284+
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1D___TF37specialize_unconditional_checked_cast17SuperToArchetypeC{{.*}} : $@convention(thin) (@out D, @owned C, @in D) -> () {
285+
// CHECK: bb0
286+
// CHECK: unconditional_checked_cast_addr take_always C in
275287

276288
// x -> x where x is a class.
277289
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast17SuperToArchetypeC{{.*}} : $@convention(thin) (@out C, @owned C, @in C) -> () {
@@ -284,18 +296,6 @@ SuperToArchetypeC(c: c, t: b)
284296
// CHECK-NEXT: tuple
285297
// CHECK-NEXT: return
286298

287-
// x -> y where x is a super class of y.
288-
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1D___TF37specialize_unconditional_checked_cast17SuperToArchetypeC{{.*}} : $@convention(thin) (@out D, @owned C, @in D) -> () {
289-
// CHECK: bb0
290-
// CHECK: unconditional_checked_cast_addr take_always C in
291-
292-
// x -> y where x is a class and y is not.
293-
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8___TF37specialize_unconditional_checked_cast17SuperToArchetypeC{{.*}} : $@convention(thin) (@out UInt8, @owned C, @in UInt8) -> () {
294-
// CHECK: bb0
295-
// CHECK: builtin "int_trap"
296-
// CHECK: unreachable
297-
// CHECK-NEXT: }
298-
299299
@inline(never)
300300
public func SuperToArchetypeD<T>(d d : D, t : T) -> T {
301301
return d as! T
@@ -304,13 +304,6 @@ public func SuperToArchetypeD<T>(d d : D, t : T) -> T {
304304
SuperToArchetypeD(d: d, t: c)
305305
SuperToArchetypeD(d: d, t: d)
306306

307-
// *NOTE* The frontend is smart enough to turn this into an upcast. When this
308-
// test is converted to SIL, this should be fixed appropriately.
309-
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast17SuperToArchetypeD{{.*}} : $@convention(thin) (@out C, @owned D, @in C) -> () {
310-
// CHECK-NOT: unconditional_checked_cast super_to_archetype
311-
// CHECK: upcast
312-
// CHECK-NOT: unconditional_checked_cast super_to_archetype
313-
314307
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1D___TF37specialize_unconditional_checked_cast17SuperToArchetypeD{{.*}} : $@convention(thin) (@out D, @owned D, @in D) -> () {
315308
// CHECK: bb0
316309
// CHECK-NEXT: debug_value
@@ -321,6 +314,13 @@ SuperToArchetypeD(d: d, t: d)
321314
// CHECK-NEXT: tuple
322315
// CHECK-NEXT: return
323316

317+
// *NOTE* The frontend is smart enough to turn this into an upcast. When this
318+
// test is converted to SIL, this should be fixed appropriately.
319+
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast17SuperToArchetypeD{{.*}} : $@convention(thin) (@out C, @owned D, @in C) -> () {
320+
// CHECK-NOT: unconditional_checked_cast super_to_archetype
321+
// CHECK: upcast
322+
// CHECK-NOT: unconditional_checked_cast super_to_archetype
323+
324324
//////////////////////////////
325325
// Existential To Archetype //
326326
//////////////////////////////
@@ -330,16 +330,6 @@ public func ExistentialToArchetype<T>(o o : AnyObject, t : T) -> T {
330330
return o as! T
331331
}
332332

333-
// AnyObject -> Class.
334-
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast22ExistentialToArchetype{{.*}} : $@convention(thin) (@out C, @owned AnyObject, @in C) -> () {
335-
// CHECK: unconditional_checked_cast_addr take_always AnyObject in {{%.*}} : $*AnyObject to C
336-
337-
// AnyObject -> Non Class (should always fail)
338-
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8___TF37specialize_unconditional_checked_cast22ExistentialToArchetype{{.*}} : $@convention(thin) (@out UInt8, @owned AnyObject, @in UInt8) -> () {
339-
// CHECK: builtin "int_trap"()
340-
// CHECK: unreachable
341-
// CHECK-NEXT: }
342-
343333
// AnyObject -> AnyObject
344334
// CHECK-LABEL: sil shared [noinline] @_TTSg5Ps9AnyObject____TF37specialize_unconditional_checked_cast22ExistentialToArchetype{{.*}} : $@convention(thin) (@out AnyObject, @owned AnyObject, @in AnyObject) -> () {
345335
// CHECK: bb0
@@ -351,6 +341,16 @@ public func ExistentialToArchetype<T>(o o : AnyObject, t : T) -> T {
351341
// CHECK-NEXT: tuple
352342
// CHECK-NEXT: return
353343

344+
// AnyObject -> Non Class (should always fail)
345+
// CHECK-LABEL: sil shared [noinline] @_TTSg5Vs5UInt8___TF37specialize_unconditional_checked_cast22ExistentialToArchetype{{.*}} : $@convention(thin) (@out UInt8, @owned AnyObject, @in UInt8) -> () {
346+
// CHECK: builtin "int_trap"()
347+
// CHECK: unreachable
348+
// CHECK-NEXT: }
349+
350+
// AnyObject -> Class.
351+
// CHECK-LABEL: sil shared [noinline] @_TTSg5C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast22ExistentialToArchetype{{.*}} : $@convention(thin) (@out C, @owned AnyObject, @in C) -> () {
352+
// CHECK: unconditional_checked_cast_addr take_always AnyObject in {{%.*}} : $*AnyObject to C
353+
354354
ExistentialToArchetype(o: o, t: c)
355355
ExistentialToArchetype(o: o, t: b)
356356
ExistentialToArchetype(o: o, t: o)
@@ -370,34 +370,39 @@ public func callGenericDownCast(c: C?) -> D {
370370
return genericDownCast(c, D.self)
371371
}
372372

373+
//order: -5
373374
// x -> y where y is a class but x is not.
374375
// CHECK-LABEL: sil shared [noinline] @_TTSf4d___TTSg5C37specialize_unconditional_checked_cast1C___TF37specialize_unconditional_checked_cast31ArchetypeToConcreteConvertUInt8
375376
// CHECK: bb0
376377
// CHECK: builtin "int_trap"
377378
// CHECK: unreachable
378379
// CHECK-NEXT: }
379380

381+
//order: -4
380382
// x -> y where x,y are not classes and x is a different type from y.
381383
// CHECK-LABEL: sil shared [noinline] @_TTSf4d___TTSg5Vs6UInt64___TF37specialize_unconditional_checked_cast31ArchetypeToConcreteConvertUInt8
382384
// CHECK: bb0
383385
// CHECK: builtin "int_trap"
384386
// CHECK: unreachable
385387
// CHECK-NEXT: }
386388

389+
// order -3
387390
// x -> y where x is a class but y is not.
388391
// CHECK-LABEL: sil shared [noinline] @_TTSf4d___TTSg5Vs5UInt8___TF37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC
389392
// CHECK: bb0
390393
// CHECK: builtin "int_trap"
391394
// CHECK: unreachable
392395
// CHECK-NEXT: }
393396

397+
// order -2
394398
// x -> y where x,y are classes, but x is unrelated to y.
395399
// CHECK-LABEL: sil shared [noinline] @_TTSf4d___TTSg5C37specialize_unconditional_checked_cast1E___TF37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC
396400
// CHECK: bb0
397401
// CHECK: builtin "int_trap"
398402
// CHECK: unreachable
399403
// CHECK-NEXT: }
400404

405+
// order -1
401406
// x -> y where x,y are classes, but y is unrelated to x. The idea is
402407
// to make sure that the fact that y is concrete does not affect the
403408
// result.

0 commit comments

Comments
 (0)