Skip to content

Commit a00f252

Browse files
authored
Merge pull request swiftlang#15646 from gottesmm/pr-3a87b9bc7f815f7952b698d3f63f36dd1fb9bbde
[generic-specializer] Promote non-trivial in_guaranteed => guaranteed.
2 parents 7673d66 + 510381e commit a00f252

7 files changed

+210
-180
lines changed

lib/SILOptimizer/Utils/Generics.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,12 +684,19 @@ void ReabstractionInfo::createSubstitutedAndSpecializedTypes() {
684684
if (!substConv.getSILType(PI).isLoadable(M)) {
685685
continue;
686686
}
687-
if (PI.getConvention() == ParameterConvention::Indirect_In) {
688-
Conversions.set(IdxToInsert);
689-
}
690-
if ((PI.getConvention() == ParameterConvention::Indirect_In_Guaranteed) &&
691-
substConv.getSILType(PI).isTrivial(M)) {
687+
688+
switch (PI.getConvention()) {
689+
case ParameterConvention::Indirect_In:
690+
case ParameterConvention::Indirect_In_Guaranteed:
692691
Conversions.set(IdxToInsert);
692+
break;
693+
case ParameterConvention::Indirect_In_Constant:
694+
case ParameterConvention::Indirect_Inout:
695+
case ParameterConvention::Indirect_InoutAliasable:
696+
case ParameterConvention::Direct_Owned:
697+
case ParameterConvention::Direct_Unowned:
698+
case ParameterConvention::Direct_Guaranteed:
699+
break;
693700
}
694701
}
695702

test/SILOptimizer/array_contentof_opt.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// RUN: %target-swift-frontend -O -sil-verify-all -emit-sil %s | %FileCheck %s
22
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
33

4-
// XFAIL: plus_zero_runtime
5-
64
// This is an end-to-end test of the array(contentsOf) -> array(Element) optimization
75

86
// CHECK-LABEL: sil @{{.*}}testInt

test/SILOptimizer/devirt_witness_method_conformance.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ protocol X {
1414
func foo()
1515
}
1616
extension X {
17+
@_optimize(none)
1718
func foo() {}
1819
}
1920
public class Base: X {}

test/SILOptimizer/spec_archetype_method.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func useFoo<T>(x x: T) {
3232
//CHECK-LABEL: sil @$S21spec_archetype_method21interesting_code_hereyyF
3333
//CHECK: function_ref @$S21spec_archetype_method12generic_call{{[_0-9a-zA-Z]*}}FAA3ABCC_Tg5
3434
//CHECK-NEXT: apply
35-
//CHECK: function_ref @$S21spec_archetype_method6useFoo{{[_0-9a-zA-Z]*}}FAA3ABCC_Tg5 : $@convention(thin) (@in_guaranteed ABC) -> ()
35+
//CHECK: function_ref @$S21spec_archetype_method6useFoo{{[_0-9a-zA-Z]*}}FAA3ABCC_Tg5 : $@convention(thin) (@guaranteed ABC) -> ()
3636
//CHECK-NEXT: apply
3737
//CHECK: return
3838
public

test/SILOptimizer/specialize_checked_cast_branch.swift

Lines changed: 153 additions & 130 deletions
Large diffs are not rendered by default.

test/SILOptimizer/specialize_inherited_multifile.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// Make sure the ConcreteDerived : Base conformance is available here.
1111

12-
// CHECK-LABEL: sil shared [noinline] @$S30specialize_inherited_multifile17takesHasAssocType1tyx_tAA0efG0RzlFAA08ConcreteefG0C_Tg5 : $@convention(thin) (@in_guaranteed ConcreteHasAssocType) -> ()
12+
// CHECK-LABEL: sil shared [noinline] @$S30specialize_inherited_multifile17takesHasAssocType1tyx_tAA0efG0RzlFAA08ConcreteefG0C_Tg5 : $@convention(thin) (@guaranteed ConcreteHasAssocType) -> ()
1313
// CHECK: [[FN:%.*]] = function_ref @$S30specialize_inherited_multifile9takesBase1tyx_tAA0E0RzlF
1414
// CHECK: apply [[FN]]<ConcreteDerived>({{%.*}})
1515
// CHECK: return

test/SILOptimizer/specialize_unconditional_checked_cast.swift

Lines changed: 42 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -42,36 +42,36 @@ ArchetypeToArchetype(t: b, t2: f)
4242
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
4343

4444
// x -> x where x is a class.
45-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast011ArchetypeToE0{{[_0-9a-zA-Z]*}}FAA1CC{{.*}}Tg5 : $@convention(thin) (@in_guaranteed C, @in_guaranteed C) -> @owned C {
45+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast011ArchetypeToE0{{[_0-9a-zA-Z]*}}FAA1CC{{.*}}Tg5 : $@convention(thin) (@guaranteed C, @guaranteed C) -> @owned C {
4646
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
4747

4848
// x -> y where x is not a class but y is.
49-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast011ArchetypeToE0{{[_0-9a-zA-Z]*}}FAA8NotUInt8V_AA1CCTg5 : $@convention(thin) (NotUInt8, @in_guaranteed C) -> @owned C {
49+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast011ArchetypeToE0{{[_0-9a-zA-Z]*}}FAA8NotUInt8V_AA1CCTg5 : $@convention(thin) (NotUInt8, @guaranteed C) -> @owned C {
5050
// CHECK-NOT: unconditional_checked_cast_addr
5151
// CHECK-NOT: unconditional_checked_cast_addr
5252
// CHECK: builtin "int_trap"
5353
// CHECK-NOT: unconditional_checked_cast_addr
5454

5555
// y -> x where x is not a class but y is.
56-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast011ArchetypeToE0{{[_0-9a-zA-Z]*}}FAA1CC_AA8NotUInt8VTg5 : $@convention(thin) (@in_guaranteed C, NotUInt8) -> NotUInt8 {
56+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast011ArchetypeToE0{{[_0-9a-zA-Z]*}}FAA1CC_AA8NotUInt8VTg5 : $@convention(thin) (@guaranteed C, NotUInt8) -> NotUInt8 {
5757
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
5858
// CHECK: builtin "int_trap"
5959
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
6060

6161
// x -> y where x is a super class of y.
62-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast011ArchetypeToE0{{[_0-9a-zA-Z]*}}FAA1CC_AA1DCTg5 : $@convention(thin) (@in_guaranteed C, @in_guaranteed D) -> @owned D {
62+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast011ArchetypeToE0{{[_0-9a-zA-Z]*}}FAA1CC_AA1DCTg5 : $@convention(thin) (@guaranteed C, @guaranteed D) -> @owned D {
6363
// CHECK: [[STACK:%[0-9]+]] = alloc_stack $C
6464
// TODO: This should be optimized to an unconditional_checked_cast without the need of alloc_stack: rdar://problem/24775038
6565
// CHECK: unconditional_checked_cast_addr C in [[STACK]] : $*C to D in
6666

6767
// y -> x where x is a super class of y.
68-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast011ArchetypeToE0{{[_0-9a-zA-Z]*}}FAA1DC_AA1CCTg5 : $@convention(thin) (@in_guaranteed D, @in_guaranteed C) -> @owned C {
68+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast011ArchetypeToE0{{[_0-9a-zA-Z]*}}FAA1DC_AA1CCTg5 : $@convention(thin) (@guaranteed D, @guaranteed C) -> @owned C {
6969
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
7070
// CHECK: upcast {{%[0-9]+}} : $D to $C
7171
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
7272

7373
// x -> y where x and y are unrelated classes.
74-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast011ArchetypeToE0{{[_0-9a-zA-Z]*}}FAA1CC_AA1ECTg5 : $@convention(thin) (@in_guaranteed C, @in_guaranteed E) -> @owned E {
74+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast011ArchetypeToE0{{[_0-9a-zA-Z]*}}FAA1CC_AA1ECTg5 : $@convention(thin) (@guaranteed C, @guaranteed E) -> @owned E {
7575
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
7676
// CHECK: builtin "int_trap"
7777
// CHECK-NOT: unconditional_checked_cast archetype_to_archetype
@@ -117,11 +117,12 @@ ArchetypeToConcreteConvertUInt8(t: f)
117117
// CHECK-NEXT: }
118118

119119
// x -> x where x is a class.
120-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC{{[_0-9a-zA-Z]*}}Tg5 : $@convention(thin) (@in_guaranteed C) -> @owned C {
121-
// CHECK: bb0
122-
// CHECK-NEXT: debug_value_addr %0
123-
// CHECK-NEXT: %2 = load %0 : $*C
124-
// CHECK: return %2
120+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC{{[_0-9a-zA-Z]*}}Tg5 : $@convention(thin) (@guaranteed C) -> @owned C {
121+
// CHECK: bb0([[ARG:%.*]] : $C)
122+
// CHECK-NEXT: debug_value [[ARG]]
123+
// CHECK-NEXT: debug_value [[ARG]]
124+
// CHECK-NEXT: strong_retain [[ARG]]
125+
// CHECK-NEXT: return [[ARG]]
125126

126127
// x -> y where x is a class but y is not.
127128
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC{{[_0-9a-zA-Z]*}}FAA8NotUInt8V_Tg5
@@ -131,12 +132,12 @@ ArchetypeToConcreteConvertUInt8(t: f)
131132
// CHECK-NEXT: }
132133

133134
// x -> y where x,y are classes and x is a super class of y.
134-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC{{[_0-9a-zA-Z]*}}FAA1DC_Tg5 : $@convention(thin) (@in_guaranteed D) -> @owned C {
135-
// CHECK: bb0
136-
// CHECK-NEXT: debug_value_addr %0
137-
// CHECK-NEXT: %2 = load %0 : $*D
138-
// CHECK: [[UC:%[0-9]+]] = upcast %2
139-
// CHECK: return [[UC]]
135+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC{{[_0-9a-zA-Z]*}}FAA1DC_Tg5 : $@convention(thin) (@guaranteed D) -> @owned C {
136+
// CHECK: bb0([[ARG:%.*]] : $D):
137+
// CHECK: [[UPCAST:%.*]] = upcast [[ARG]] : $D to $C
138+
// CHECK: strong_retain [[ARG]]
139+
// CHECK: return [[UPCAST]]
140+
// CHECK: } // end sil function '$S37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC{{[_0-9a-zA-Z]*}}FAA1DC_Tg5'
140141

141142
// x -> y where x,y are classes, but x is unrelated to y.
142143
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertC{{[_0-9a-zA-Z]*}}FAA1EC_Tg5
@@ -163,8 +164,8 @@ public func ArchetypeToConcreteConvertD<T>(t t: T) -> D {
163164
ArchetypeToConcreteConvertD(t: c)
164165

165166
// x -> y where x,y are classes and x is a sub class of y.
166-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertD{{[_0-9a-zA-Z]*}}FAA1CC_Tg5 : $@convention(thin) (@in_guaranteed C) -> @owned D {
167-
// CHECK: bb0(%0 : $*C):
167+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ArchetypeToConcreteConvertD{{[_0-9a-zA-Z]*}}FAA1CC_Tg5 : $@convention(thin) (@guaranteed C) -> @owned D {
168+
// CHECK: bb0(%0 : $C):
168169
// CHECK-DAG: [[STACK_C:%[0-9]+]] = alloc_stack $C
169170
// CHECK-DAG: store {{.*}} to [[STACK_C]]
170171
// CHECK-DAG: [[STACK_D:%[0-9]+]] = alloc_stack $D
@@ -210,7 +211,7 @@ ConcreteToArchetypeConvertUInt8(t: b, t2: f)
210211
// CHECK-NEXT: return %0
211212

212213
// x -> y where x is not a class but y is a class.
213-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast31ConcreteToArchetypeConvertUInt8{{[_0-9a-zA-Z]*}}FAA1CC_Tg5 : $@convention(thin) (NotUInt8, @in_guaranteed C) -> @owned C {
214+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast31ConcreteToArchetypeConvertUInt8{{[_0-9a-zA-Z]*}}FAA1CC_Tg5 : $@convention(thin) (NotUInt8, @guaranteed C) -> @owned C {
214215
// CHECK: bb0
215216
// CHECK: builtin "int_trap"
216217
// CHECK: unreachable
@@ -235,8 +236,8 @@ ConcreteToArchetypeConvertC(t: c, t2: e)
235236

236237

237238
// x -> x where x is a class.
238-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertC{{[_0-9a-zA-Z]*}}Tg5 : $@convention(thin) (@guaranteed C, @in_guaranteed C) -> @owned C {
239-
// CHECK: bb0(%0 : $C, %1 : $*C):
239+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertC{{[_0-9a-zA-Z]*}}Tg5 : $@convention(thin) (@guaranteed C, @guaranteed C) -> @owned C {
240+
// CHECK: bb0(%0 : $C, %1 : $C):
240241
// CHECK: return %0
241242

242243
// x -> y where x is a class but y is not.
@@ -247,8 +248,8 @@ ConcreteToArchetypeConvertC(t: c, t2: e)
247248
// CHECK-NEXT: }
248249

249250
// x -> y where x is a super class of y.
250-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertC{{[_0-9a-zA-Z]*}}FAA1DC_Tg5 : $@convention(thin) (@guaranteed C, @in_guaranteed D) -> @owned D {
251-
// CHECK: bb0(%0 : $C, %1 : $*D):
251+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertC{{[_0-9a-zA-Z]*}}FAA1DC_Tg5 : $@convention(thin) (@guaranteed C, @guaranteed D) -> @owned D {
252+
// CHECK: bb0(%0 : $C, %1 : $D):
252253
// CHECK-DAG: [[STACK_C:%[0-9]+]] = alloc_stack $C
253254
// CHECK-DAG: store %0 to [[STACK_C]]
254255
// CHECK-DAG: [[STACK_D:%[0-9]+]] = alloc_stack $D
@@ -258,8 +259,8 @@ ConcreteToArchetypeConvertC(t: c, t2: e)
258259
// CHECK: return [[LOAD]]
259260

260261
// x -> y where x and y are unrelated classes.
261-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertC{{[_0-9a-zA-Z]*}}FAA1EC_Tg5 : $@convention(thin) (@guaranteed C, @in_guaranteed E) -> @owned E {
262-
// CHECK: bb0(%0 : $C, %1 : $*E):
262+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertC{{[_0-9a-zA-Z]*}}FAA1EC_Tg5 : $@convention(thin) (@guaranteed C, @guaranteed E) -> @owned E {
263+
// CHECK: bb0(%0 : $C, %1 : $E):
263264
// CHECK-NEXT: builtin "int_trap"
264265
// CHECK-NEXT: unreachable
265266
// CHECK-NEXT: }
@@ -272,8 +273,8 @@ public func ConcreteToArchetypeConvertD<T>(t t: D, t2: T) -> T {
272273
ConcreteToArchetypeConvertD(t: d, t2: c)
273274

274275
// x -> y where x is a subclass of y.
275-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertD{{[_0-9a-zA-Z]*}}FAA1CC_Tg5 : $@convention(thin) (@guaranteed D, @in_guaranteed C) -> @owned C {
276-
// CHECK: bb0(%0 : $D, %1 : $*C):
276+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast27ConcreteToArchetypeConvertD{{[_0-9a-zA-Z]*}}FAA1CC_Tg5 : $@convention(thin) (@guaranteed D, @guaranteed C) -> @owned C {
277+
// CHECK: bb0(%0 : $D, %1 : $C):
277278
// CHECK-DAG: [[UC:%[0-9]+]] = upcast %0
278279
// CHECK: return [[UC]]
279280

@@ -293,12 +294,12 @@ SuperToArchetypeC(c: c, t: b)
293294

294295

295296
// x -> x where x is a class.
296-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast17SuperToArchetypeC{{[_0-9a-zA-Z]*}}Tg5 : $@convention(thin) (@guaranteed C, @in_guaranteed C) -> @owned C {
297-
// CHECK: bb0(%0 : $C, %1 : $*C):
297+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast17SuperToArchetypeC{{[_0-9a-zA-Z]*}}Tg5 : $@convention(thin) (@guaranteed C, @guaranteed C) -> @owned C {
298+
// CHECK: bb0(%0 : $C, %1 : $C):
298299
// CHECK: return %0
299300

300301
// x -> y where x is a super class of y.
301-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast17SuperToArchetypeC{{[_0-9a-zA-Z]*}}FAA1DC_Tg5 : $@convention(thin) (@guaranteed C, @in_guaranteed D) -> @owned D {
302+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast17SuperToArchetypeC{{[_0-9a-zA-Z]*}}FAA1DC_Tg5 : $@convention(thin) (@guaranteed C, @guaranteed D) -> @owned D {
302303
// CHECK: bb0
303304
// CHECK: unconditional_checked_cast_addr C in
304305

@@ -319,13 +320,13 @@ SuperToArchetypeD(d: d, t: d)
319320

320321
// *NOTE* The frontend is smart enough to turn this into an upcast. When this
321322
// test is converted to SIL, this should be fixed appropriately.
322-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast17SuperToArchetypeD{{[_0-9a-zA-Z]*}}FAA1CC_Tg5 : $@convention(thin) (@guaranteed D, @in_guaranteed C) -> @owned C {
323+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast17SuperToArchetypeD{{[_0-9a-zA-Z]*}}FAA1CC_Tg5 : $@convention(thin) (@guaranteed D, @guaranteed C) -> @owned C {
323324
// CHECK-NOT: unconditional_checked_cast super_to_archetype
324325
// CHECK: upcast
325326
// CHECK-NOT: unconditional_checked_cast super_to_archetype
326327

327-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast17SuperToArchetypeD{{[_0-9a-zA-Z]*}}Tg5 : $@convention(thin) (@guaranteed D, @in_guaranteed D) -> @owned D {
328-
// CHECK: bb0(%0 : $D, %1 : $*D):
328+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast17SuperToArchetypeD{{[_0-9a-zA-Z]*}}Tg5 : $@convention(thin) (@guaranteed D, @guaranteed D) -> @owned D {
329+
// CHECK: bb0(%0 : $D, %1 : $D):
329330
// CHECK: return %0
330331

331332
//////////////////////////////
@@ -338,7 +339,7 @@ public func ExistentialToArchetype<T>(o o : AnyObject, t : T) -> T {
338339
}
339340

340341
// AnyObject -> Class.
341-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast22ExistentialToArchetype{{[_0-9a-zA-Z]*}}FAA1CC_Tg5 : $@convention(thin) (@guaranteed AnyObject, @in_guaranteed C) -> @owned C {
342+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast22ExistentialToArchetype{{[_0-9a-zA-Z]*}}FAA1CC_Tg5 : $@convention(thin) (@guaranteed AnyObject, @guaranteed C) -> @owned C {
342343
// CHECK: unconditional_checked_cast_addr AnyObject in {{%.*}} : $*AnyObject to C
343344

344345
// AnyObject -> Non Class (should always fail)
@@ -348,8 +349,8 @@ public func ExistentialToArchetype<T>(o o : AnyObject, t : T) -> T {
348349
// CHECK: return
349350

350351
// AnyObject -> AnyObject
351-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast22ExistentialToArchetype{{[_0-9a-zA-Z]*}}yXl{{.*}}Tg5 : $@convention(thin) (@guaranteed AnyObject, @in_guaranteed AnyObject) -> @owned AnyObject {
352-
// CHECK: bb0(%0 : $AnyObject, %1 : $*AnyObject):
352+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast22ExistentialToArchetype{{[_0-9a-zA-Z]*}}yXl{{.*}}Tg5 : $@convention(thin) (@guaranteed AnyObject, @guaranteed AnyObject) -> @owned AnyObject {
353+
// CHECK: bb0(%0 : $AnyObject, %1 : $AnyObject):
353354
// CHECK: return %0
354355

355356
ExistentialToArchetype(o: o, t: c)
@@ -360,12 +361,12 @@ ExistentialToArchetype(o: o, t: o)
360361
// value cast. We could do the promotion, but the optimizer would need
361362
// to insert the Optional unwrapping logic before the cast.
362363
//
363-
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast15genericDownCastyq_x_q_mtr0_lFAA1CCSg_AA1DCTg5 : $@convention(thin) (@in_guaranteed Optional<C>, @thick D.Type) -> @owned D {
364-
// CHECK: bb0(%0 : $*Optional<C>, %1 : $@thick D.Type):
364+
// CHECK-LABEL: sil shared [noinline] @$S37specialize_unconditional_checked_cast15genericDownCastyq_x_q_mtr0_lFAA1CCSg_AA1DCTg5 : $@convention(thin) (@guaranteed Optional<C>, @thick D.Type) -> @owned D {
365+
// CHECK: bb0(%0 : $Optional<C>, %1 : $@thick D.Type):
365366
// CHECK-DAG: [[STACK_D:%[0-9]+]] = alloc_stack $D
366367
// CHECK-DAG: [[STACK_C:%[0-9]+]] = alloc_stack $Optional<C>
367-
// CHECK-DAG: %5 = load %0 : $*Optional<C>
368-
// CHECK-DAG: store %5 to [[STACK_C]]
368+
// CHECK-DAG: store [[ARG]] to [[STACK_C]]
369+
// CHECK-DAG: retain_value [[ARG]]
369370
// TODO: This should be optimized to an unconditional_checked_cast without the need of alloc_stack: rdar://problem/24775038
370371
// CHECK-DAG: unconditional_checked_cast_addr Optional<C> in [[STACK_C]] : $*Optional<C> to D in [[STACK_D]] : $*D
371372
// CHECK-DAG: [[LOAD:%[0-9]+]] = load [[STACK_D]]

0 commit comments

Comments
 (0)