Skip to content

Commit 489910e

Browse files
committed
[silgen] Only borrow args for coroutines rather than general applies and do not conditionalize based off of the ownership flag being set.
This is the last part of SILGen conditionalized on EnableSILOwnership being set. It also (as you can tell from the diff) eliminates a bunch of code from the tests. rdar://29791263
1 parent 1d551cb commit 489910e

30 files changed

+157
-281
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 44 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,19 @@ static ManagedValue borrowedCastToOriginalSelfType(SILGenFunction &SGF,
211211
originalSelfType);
212212
}
213213

214-
static ManagedValue convertOwnershipConventionGivenParamInfo(SILGenFunction &SGF,
215-
SILParameterInfo param,
216-
ManagedValue value,
217-
SILLocation loc) {
214+
static ManagedValue convertOwnershipConventionGivenParamInfo(
215+
SILGenFunction &SGF, SILParameterInfo param, ManagedValue value,
216+
SILLocation loc, bool isForCoroutine) {
218217
if (param.isConsumed() &&
219218
value.getOwnershipKind() == ValueOwnershipKind::Guaranteed) {
220219
return value.copyUnmanaged(SGF, loc);
221220
}
222221

223-
if (SGF.F.getModule().getOptions().EnableSILOwnership &&
224-
value.getOwnershipKind() == ValueOwnershipKind::Owned) {
222+
// If we are emitting arguments for a coroutine, we need to borrow owned
223+
// values to ensure that they are live over the entire closure invocation. If
224+
// we do not have a coroutine, then we have an immediate non-consuming use so
225+
// no borrow is necessary.
226+
if (isForCoroutine && value.getOwnershipKind() == ValueOwnershipKind::Owned) {
225227
if (param.isDirectGuaranteed() || (!SGF.silConv.useLoweredAddresses() &&
226228
param.isIndirectInGuaranteed())) {
227229
return value.borrow(SGF, loc);
@@ -232,16 +234,15 @@ static ManagedValue convertOwnershipConventionGivenParamInfo(SILGenFunction &SGF
232234
}
233235

234236
static void convertOwnershipConventionsGivenParamInfos(
235-
SILGenFunction &SGF,
236-
ArrayRef<SILParameterInfo> params,
237-
ArrayRef<ManagedValue> values,
238-
SILLocation loc,
237+
SILGenFunction &SGF, ArrayRef<SILParameterInfo> params,
238+
ArrayRef<ManagedValue> values, SILLocation loc, bool isForCoroutine,
239239
llvm::SmallVectorImpl<ManagedValue> &outVar) {
240240
assert(params.size() == values.size() &&
241241
"Different number of params from arguments");
242242
transform(indices(params), std::back_inserter(outVar),
243243
[&](unsigned i) -> ManagedValue {
244-
return convertOwnershipConventionGivenParamInfo(SGF, params[i], values[i], loc);
244+
return convertOwnershipConventionGivenParamInfo(
245+
SGF, params[i], values[i], loc, isForCoroutine);
245246
});
246247
}
247248

@@ -2571,6 +2572,7 @@ class ArgEmitter {
25712572
SILGenFunction &SGF;
25722573
SILFunctionTypeRepresentation Rep;
25732574
bool IsYield;
2575+
bool IsForCoroutine;
25742576
Optional<ForeignErrorConvention> ForeignError;
25752577
ImportAsMemberStatus ForeignSelf;
25762578
ClaimedParamsRef ParamInfos;
@@ -2583,16 +2585,16 @@ class ArgEmitter {
25832585
Optional<ArgSpecialDestArray> SpecialDests;
25842586
public:
25852587
ArgEmitter(SILGenFunction &SGF, SILFunctionTypeRepresentation Rep,
2586-
bool isYield, ClaimedParamsRef paramInfos,
2588+
bool isYield, bool isForCoroutine, ClaimedParamsRef paramInfos,
25872589
SmallVectorImpl<ManagedValue> &args,
25882590
SmallVectorImpl<DelayedArgument> &delayedArgs,
25892591
const Optional<ForeignErrorConvention> &foreignError,
25902592
ImportAsMemberStatus foreignSelf,
25912593
Optional<ArgSpecialDestArray> specialDests = None)
2592-
: SGF(SGF), Rep(Rep), IsYield(isYield), ForeignError(foreignError),
2593-
ForeignSelf(foreignSelf),
2594-
ParamInfos(paramInfos),
2595-
Args(args), DelayedArguments(delayedArgs), SpecialDests(specialDests) {
2594+
: SGF(SGF), Rep(Rep), IsYield(isYield), IsForCoroutine(isForCoroutine),
2595+
ForeignError(foreignError), ForeignSelf(foreignSelf),
2596+
ParamInfos(paramInfos), Args(args), DelayedArguments(delayedArgs),
2597+
SpecialDests(specialDests) {
25962598
assert(!specialDests || specialDests->size() == paramInfos.size());
25972599
}
25982600

@@ -2961,7 +2963,8 @@ class ArgEmitter {
29612963
auto loc = arg.getLocation();
29622964

29632965
auto convertOwnershipConvention = [&](ManagedValue value) {
2964-
return convertOwnershipConventionGivenParamInfo(SGF, param, value, loc);
2966+
return convertOwnershipConventionGivenParamInfo(SGF, param, value, loc,
2967+
IsForCoroutine);
29652968
};
29662969

29672970
auto contexts = getRValueEmissionContexts(loweredSubstArgType, param);
@@ -3224,11 +3227,11 @@ void DelayedArgument::emitDefaultArgument(SILGenFunction &SGF,
32243227
SmallVector<ManagedValue, 4> loweredArgs;
32253228
SmallVector<DelayedArgument, 4> delayedArgs;
32263229
Optional<ForeignErrorConvention> errorConvention = None;
3227-
auto emitter = ArgEmitter(SGF, info.functionRepresentation, /*yield*/ false,
3228-
info.paramsToEmit,
3229-
loweredArgs, delayedArgs,
3230-
errorConvention, ImportAsMemberStatus());
3231-
3230+
auto emitter =
3231+
ArgEmitter(SGF, info.functionRepresentation, /*yield*/ false,
3232+
/*coroutine*/ false, info.paramsToEmit, loweredArgs,
3233+
delayedArgs, errorConvention, ImportAsMemberStatus());
3234+
32323235
emitter.emitSingleArg(ArgumentSource(info.loc, std::move(value)),
32333236
info.origResultType);
32343237
assert(delayedArgs.empty());
@@ -3707,7 +3710,7 @@ void TupleShuffleArgEmitter::emit(ArgEmitter &parent) {
37073710

37083711
// Emit the inner expression.
37093712
if (!innerParams.empty()) {
3710-
ArgEmitter(parent.SGF, parent.Rep, parent.IsYield,
3713+
ArgEmitter(parent.SGF, parent.Rep, parent.IsYield, parent.IsForCoroutine,
37113714
ClaimedParamsRef(innerParams), innerArgs, innerDelayedArgs,
37123715
/*foreign error*/ None, /*foreign self*/ ImportAsMemberStatus(),
37133716
(innerSpecialDests ? ArgSpecialDestArray(*innerSpecialDests)
@@ -3965,16 +3968,17 @@ class CallSite {
39653968

39663969
/// Evaluate arguments and begin any inout formal accesses.
39673970
void emit(SILGenFunction &SGF, AbstractionPattern origFormalType,
3968-
ParamLowering &lowering, SmallVectorImpl<ManagedValue> &args,
3971+
CanSILFunctionType substFnType, ParamLowering &lowering,
3972+
SmallVectorImpl<ManagedValue> &args,
39693973
SmallVectorImpl<DelayedArgument> &delayedArgs,
39703974
const Optional<ForeignErrorConvention> &foreignError,
39713975
ImportAsMemberStatus foreignSelf) && {
39723976
auto params = lowering.claimParams(origFormalType, getParams(),
39733977
foreignError, foreignSelf);
39743978

39753979
ArgEmitter emitter(SGF, lowering.Rep, /*yield*/ false,
3976-
params, args, delayedArgs,
3977-
foreignError, foreignSelf);
3980+
/*isForCoroutine*/ substFnType->isCoroutine(), params,
3981+
args, delayedArgs, foreignError, foreignSelf);
39783982
emitter.emitPreparedArgs(std::move(Args), origFormalType);
39793983
}
39803984

@@ -4603,8 +4607,8 @@ ApplyOptions CallEmission::emitArgumentsForNormalApply(
46034607

46044608
bool isParamSite = &site == &uncurriedSites.back();
46054609

4606-
std::move(site).emit(SGF, origFormalType, paramLowering, args.back(),
4607-
delayedArgs,
4610+
std::move(site).emit(SGF, origFormalType, substFnType, paramLowering,
4611+
args.back(), delayedArgs,
46084612
// Claim the foreign error with the method
46094613
// formal params.
46104614
isParamSite ? foreignError : None,
@@ -4683,8 +4687,9 @@ RValue CallEmission::applyRemainingCallSites(RValue &&result,
46834687
ArgumentScope argScope(SGF, loc);
46844688

46854689
std::move(extraSites[i])
4686-
.emit(SGF, origFormalType, paramLowering, siteArgs, delayedArgs,
4687-
calleeTypeInfo.foreignError, calleeTypeInfo.foreignSelf);
4690+
.emit(SGF, origFormalType, substFnType, paramLowering, siteArgs,
4691+
delayedArgs, calleeTypeInfo.foreignError,
4692+
calleeTypeInfo.foreignSelf);
46884693
if (!delayedArgs.empty()) {
46894694
emitDelayedArguments(SGF, delayedArgs, siteArgs);
46904695
}
@@ -5049,10 +5054,9 @@ void SILGenFunction::emitYield(SILLocation loc,
50495054
}
50505055

50515056
ArgEmitter emitter(*this, fnType->getRepresentation(), /*yield*/ true,
5052-
ClaimedParamsRef(substYieldTys),
5057+
/*isForCoroutine*/ false, ClaimedParamsRef(substYieldTys),
50535058
yieldArgs, delayedArgs,
5054-
/*foreign error*/None,
5055-
ImportAsMemberStatus());
5059+
/*foreign error*/ None, ImportAsMemberStatus());
50565060

50575061
for (auto i : indices(valueSources)) {
50585062
emitter.emitSingleArg(std::move(valueSources[i]), origTypes[i]);
@@ -5234,8 +5238,9 @@ SILGenFunction::emitApplyOfLibraryIntrinsic(SILLocation loc,
52345238

52355239
SILFunctionConventions silConv(calleeTypeInfo.substFnType, getModule());
52365240
llvm::SmallVector<ManagedValue, 8> finalArgs;
5237-
convertOwnershipConventionsGivenParamInfos(*this, silConv.getParameters(),
5238-
args, loc, finalArgs);
5241+
convertOwnershipConventionsGivenParamInfos(
5242+
*this, silConv.getParameters(), args, loc,
5243+
/*isForCoroutine*/ calleeTypeInfo.substFnType->isCoroutine(), finalArgs);
52395244

52405245
ResultPlanPtr resultPlan =
52415246
ResultPlanBuilder::computeResultPlan(*this, calleeTypeInfo, loc, ctx);
@@ -5834,11 +5839,11 @@ SILGenFunction::prepareSubscriptIndices(SubscriptDecl *subscript,
58345839
SmallVector<ManagedValue, 4> argValues;
58355840
SmallVector<DelayedArgument, 2> delayedArgs;
58365841

5837-
ArgEmitter emitter(*this, SILFunctionTypeRepresentation::Thin, /*yield*/false,
5838-
ClaimedParamsRef(substParamTys),
5842+
ArgEmitter emitter(*this, SILFunctionTypeRepresentation::Thin,
5843+
/*yield*/ false,
5844+
/*isForCoroutine*/ false, ClaimedParamsRef(substParamTys),
58395845
argValues, delayedArgs,
5840-
/*foreign error*/None,
5841-
ImportAsMemberStatus());
5846+
/*foreign error*/ None, ImportAsMemberStatus());
58425847

58435848
emitter.emitTopLevel(indexExpr, AbstractionPattern(substFnType));
58445849

test/SILGen/assignment.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@ func test1() {
2121
// CHECK: [[T0:%.*]] = metatype $@thick D.Type
2222
// CHECK: [[CTOR:%.*]] = function_ref @$s10assignment1DC{{[_0-9a-zA-Z]*}}fC
2323
// CHECK: [[D:%.*]] = apply [[CTOR]]([[T0]])
24-
// CHECK: [[BORROWED_D:%.*]] = begin_borrow [[D]]
2524
// CHECK: [[T0:%.*]] = metatype $@thick C.Type
2625
// CHECK: [[CTOR:%.*]] = function_ref @$s10assignment1CC{{[_0-9a-zA-Z]*}}fC
2726
// CHECK: [[C:%.*]] = apply [[CTOR]]([[T0]]) : $@convention(method) (@thick C.Type) -> @owned C
28-
// CHECK: [[SETTER:%.*]] = class_method [[BORROWED_D]] : $D, #D.child!setter.1
29-
// CHECK: apply [[SETTER]]([[C]], [[BORROWED_D]])
30-
// CHECK: end_borrow [[BORROWED_D]]
27+
// CHECK: [[SETTER:%.*]] = class_method [[D]] : $D, #D.child!setter.1
28+
// CHECK: apply [[SETTER]]([[C]], [[D]])
3129
// CHECK: destroy_value [[D]]
3230
D().child = C()
3331
}

test/SILGen/borrow.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ func useD(_ d: D) {}
2525
// CHECK: [[LOADED_VALUE:%.*]] = load [copy] [[ACCESS]]
2626
// CHECK: end_borrow [[BORROWED_CLASS]]
2727
// CHECK: destroy_value [[CLASS]]
28-
// CHECK: [[BORROWED_LOADED_VALUE:%.*]] = begin_borrow [[LOADED_VALUE]]
2928
// CHECK: [[FUNC:%.*]] = function_ref @$s6borrow4useD{{.*}} : $@convention(thin) (@guaranteed D) -> ()
30-
// CHECK: apply [[FUNC]]([[BORROWED_LOADED_VALUE]])
29+
// CHECK: apply [[FUNC]]([[LOADED_VALUE]])
3130
// CHECK: destroy_value [[BOX]]
3231
// CHECK: } // end sil function '$s6borrow44lvalueBorrowShouldBeAtEndOfFormalAccessScope{{.*}}'
3332
func lvalueBorrowShouldBeAtEndOfFormalAccessScope() {

test/SILGen/class_bound_protocols.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,8 @@ func class_bound_method(x: ClassBound) {
132132
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[XBOX_PB]] : $*ClassBound
133133
// CHECK: [[X:%.*]] = load [copy] [[READ]] : $*ClassBound
134134
// CHECK: [[PROJ:%.*]] = open_existential_ref [[X]] : $ClassBound to $[[OPENED:@opened(.*) ClassBound]]
135-
// CHECK: [[BORROWED_PROJ:%.*]] = begin_borrow [[PROJ]]
136135
// CHECK: [[METHOD:%.*]] = witness_method $[[OPENED]], #ClassBound.classBoundMethod!1
137-
// CHECK: apply [[METHOD]]<[[OPENED]]>([[BORROWED_PROJ]])
136+
// CHECK: apply [[METHOD]]<[[OPENED]]>([[PROJ]])
138137
// CHECK: destroy_value [[PROJ]]
139138
// CHECK: destroy_value [[XBOX]]
140139
}

test/SILGen/closures.swift

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -443,9 +443,8 @@ class SuperSub : SuperBase {
443443
// CHECK: = apply [[CLASS_METHOD]]([[ARG]])
444444
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
445445
// CHECK: [[ARG_COPY_SUPER:%.*]] = upcast [[ARG_COPY]] : $SuperSub to $SuperBase
446-
// CHECK: [[BORROWED_ARG_COPY_SUPER:%.*]] = begin_borrow [[ARG_COPY_SUPER]]
447446
// CHECK: [[SUPER_METHOD:%[0-9]+]] = function_ref @$s8closures9SuperBaseC4boomyyF : $@convention(method) (@guaranteed SuperBase) -> ()
448-
// CHECK: = apply [[SUPER_METHOD]]([[BORROWED_ARG_COPY_SUPER]])
447+
// CHECK: = apply [[SUPER_METHOD]]([[ARG_COPY_SUPER]])
449448
// CHECK: destroy_value [[ARG_COPY_SUPER]]
450449
// CHECK: } // end sil function '[[INNER_FUNC_1]]'
451450
func a1() {
@@ -473,9 +472,8 @@ class SuperSub : SuperBase {
473472
// CHECK: = apply [[CLASS_METHOD]]([[ARG]]) : $@convention(method) (@guaranteed SuperSub) -> ()
474473
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
475474
// CHECK: [[ARG_COPY_SUPER:%.*]] = upcast [[ARG_COPY]] : $SuperSub to $SuperBase
476-
// CHECK: [[BORROWED_ARG_COPY_SUPER:%.*]] = begin_borrow [[ARG_COPY_SUPER]]
477475
// CHECK: [[SUPER_METHOD:%.*]] = function_ref @$s8closures9SuperBaseC4boomyyF : $@convention(method) (@guaranteed SuperBase) -> ()
478-
// CHECK: = apply [[SUPER_METHOD]]([[BORROWED_ARG_COPY_SUPER]]) : $@convention(method) (@guaranteed SuperBase)
476+
// CHECK: = apply [[SUPER_METHOD]]([[ARG_COPY_SUPER]]) : $@convention(method) (@guaranteed SuperBase)
479477
// CHECK: destroy_value [[ARG_COPY_SUPER]]
480478
// CHECK: } // end sil function '[[INNER_FUNC_2]]'
481479
func b2() {
@@ -508,9 +506,8 @@ class SuperSub : SuperBase {
508506
// CHECK: = apply [[CLASS_METHOD]]([[ARG]]) : $@convention(method) (@guaranteed SuperSub) -> ()
509507
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
510508
// CHECK: [[ARG_COPY_SUPER:%.*]] = upcast [[ARG_COPY]] : $SuperSub to $SuperBase
511-
// CHECK: [[BORROWED_ARG_COPY_SUPER:%.*]] = begin_borrow [[ARG_COPY_SUPER]]
512509
// CHECK: [[SUPER_METHOD:%[0-9]+]] = function_ref @$s8closures9SuperBaseC4boomyyF : $@convention(method) (@guaranteed SuperBase) -> ()
513-
// CHECK: = apply [[SUPER_METHOD]]([[BORROWED_ARG_COPY_SUPER]])
510+
// CHECK: = apply [[SUPER_METHOD]]([[ARG_COPY_SUPER]])
514511
// CHECK: destroy_value [[ARG_COPY_SUPER]]
515512
// CHECK: } // end sil function '[[INNER_FUNC_1]]'
516513
let c1 = { () -> Void in
@@ -545,9 +542,8 @@ class SuperSub : SuperBase {
545542
// CHECK: bb0([[ARG:%.*]] : @guaranteed $SuperSub):
546543
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
547544
// CHECK: [[ARG_COPY_SUPER:%.*]] = upcast [[ARG_COPY]] : $SuperSub to $SuperBase
548-
// CHECK: [[BORROWED_ARG_COPY_SUPER:%.*]] = begin_borrow [[ARG_COPY_SUPER]]
549545
// CHECK: [[SUPER_METHOD:%.*]] = function_ref @$s8closures9SuperBaseC4boomyyF : $@convention(method) (@guaranteed SuperBase) -> ()
550-
// CHECK: = apply [[SUPER_METHOD]]([[BORROWED_ARG_COPY_SUPER]])
546+
// CHECK: = apply [[SUPER_METHOD]]([[ARG_COPY_SUPER]])
551547
// CHECK: destroy_value [[ARG_COPY_SUPER]]
552548
// CHECK: } // end sil function '[[INNER_FUNC_2]]'
553549
func d2() {
@@ -583,9 +579,8 @@ class SuperSub : SuperBase {
583579
// CHECK: bb0([[ARG:%.*]] : @guaranteed $SuperSub):
584580
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
585581
// CHECK: [[ARG_COPY_SUPERCAST:%.*]] = upcast [[ARG_COPY]] : $SuperSub to $SuperBase
586-
// CHECK: [[BORROWED_ARG_COPY_SUPERCAST:%.*]] = begin_borrow [[ARG_COPY_SUPERCAST]]
587582
// CHECK: [[SUPER_METHOD:%.*]] = function_ref @$s8closures9SuperBaseC4boomyyF : $@convention(method) (@guaranteed SuperBase) -> ()
588-
// CHECK: = apply [[SUPER_METHOD]]([[BORROWED_ARG_COPY_SUPERCAST]])
583+
// CHECK: = apply [[SUPER_METHOD]]([[ARG_COPY_SUPERCAST]])
589584
// CHECK: destroy_value [[ARG_COPY_SUPERCAST]]
590585
// CHECK: return
591586
// CHECK: } // end sil function '[[INNER_FUNC_NAME2]]'
@@ -622,9 +617,8 @@ class SuperSub : SuperBase {
622617
// CHECK: bb0([[ARG:%.*]] : @guaranteed $SuperSub):
623618
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
624619
// CHECK: [[ARG_COPY_SUPER:%.*]] = upcast [[ARG_COPY]] : $SuperSub to $SuperBase
625-
// CHECK: [[BORROWED_ARG_COPY_SUPER:%.*]] = begin_borrow [[ARG_COPY_SUPER]]
626620
// CHECK: [[SUPER_METHOD:%.*]] = function_ref @$s8closures9SuperBaseC4boomyyF : $@convention(method) (@guaranteed SuperBase) -> ()
627-
// CHECK: = apply [[SUPER_METHOD]]([[BORROWED_ARG_COPY_SUPER]]) : $@convention(method) (@guaranteed SuperBase) -> ()
621+
// CHECK: = apply [[SUPER_METHOD]]([[ARG_COPY_SUPER]]) : $@convention(method) (@guaranteed SuperBase) -> ()
628622
// CHECK: destroy_value [[ARG_COPY_SUPER]]
629623
// CHECK: } // end sil function '[[INNER_FUNC_2]]'
630624
nil ?? super.boom()
@@ -654,9 +648,8 @@ class SuperSub : SuperBase {
654648
// CHECK: bb0([[ARG:%.*]] : @guaranteed $SuperSub):
655649
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
656650
// CHECK: [[ARG_COPY_SUPER:%.*]] = upcast [[ARG_COPY]] : $SuperSub to $SuperBase
657-
// CHECK: [[BORROWED_ARG_COPY_SUPER:%.*]] = begin_borrow [[ARG_COPY_SUPER]]
658651
// CHECK: [[SUPER_METHOD:%.*]] = function_ref @$s8closures9SuperBaseC4boomyyF : $@convention(method) (@guaranteed SuperBase) -> ()
659-
// CHECK: = apply [[SUPER_METHOD]]([[BORROWED_ARG_COPY_SUPER]])
652+
// CHECK: = apply [[SUPER_METHOD]]([[ARG_COPY_SUPER]])
660653
// CHECK: destroy_value [[ARG_COPY_SUPER]]
661654
// CHECK: } // end sil function '[[INNER_FUNC_2]]'
662655
nil ?? super.boom()
@@ -742,9 +735,8 @@ class ConcreteBase {
742735
// CHECK: bb0([[ARG:%.*]] : @guaranteed $GenericDerived<Ocean>):
743736
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
744737
// CHECK: [[ARG_COPY_SUPER:%.*]] = upcast [[ARG_COPY]] : $GenericDerived<Ocean> to $ConcreteBase
745-
// CHECK: [[BORROWED_ARG_COPY_SUPER:%.*]] = begin_borrow [[ARG_COPY_SUPER]]
746738
// CHECK: [[METHOD:%.*]] = function_ref @$s8closures12ConcreteBaseC4swimyyF
747-
// CHECK: apply [[METHOD]]([[BORROWED_ARG_COPY_SUPER]]) : $@convention(method) (@guaranteed ConcreteBase) -> ()
739+
// CHECK: apply [[METHOD]]([[ARG_COPY_SUPER]]) : $@convention(method) (@guaranteed ConcreteBase) -> ()
748740
// CHECK: destroy_value [[ARG_COPY_SUPER]]
749741
// CHECK: } // end sil function '$s8closures14GenericDerivedC4swimyyFyyXEfU_'
750742

test/SILGen/collection_subtype_downcast.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ struct S { var x, y: Int }
99
// CHECK-NEXT: [[ARG_COPY:%.*]] = copy_value [[ARG]]
1010
// CHECK-NEXT: // function_ref
1111
// CHECK-NEXT: [[FN:%.*]] = function_ref @$ss21_arrayConditionalCastySayq_GSgSayxGr0_lF
12-
// CHECK-NEXT: [[BORROWED_ARG_COPY:%.*]] = begin_borrow [[ARG_COPY]]
13-
// CHECK-NEXT: [[RESULT:%.*]] = apply [[FN]]<Any, S>([[BORROWED_ARG_COPY]]) : $@convention(thin) <τ_0_0, τ_0_1> (@guaranteed Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
14-
// CHECK-NEXT: end_borrow
12+
// CHECK-NEXT: [[RESULT:%.*]] = apply [[FN]]<Any, S>([[ARG_COPY]]) : $@convention(thin) <τ_0_0, τ_0_1> (@guaranteed Array<τ_0_0>) -> @owned Optional<Array<τ_0_1>>
1513
// CHECK-NEXT: destroy_value [[ARG_COPY]]
1614
// CHECK-NEXT: return [[RESULT]]
1715
func array_downcast(array: [Any]) -> [S]? {
@@ -34,9 +32,7 @@ func ==(lhs: S, rhs: S) -> Bool {
3432
// CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
3533
// CHECK: // function_ref
3634
// CHECK: [[FN:%.*]] = function_ref @$ss30_dictionaryDownCastConditionalySDyq0_q1_GSgSDyxq_GSHRzSHR0_r2_lF
37-
// CHECK: [[BORROWED_ARG_COPY:%.*]] = begin_borrow [[ARG_COPY]]
38-
// CHECK: [[RESULT:%.*]] = apply [[FN]]<S, Any, S, Int>([[BORROWED_ARG_COPY]]) : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@guaranteed Dictionary<τ_0_0, τ_0_1>) -> @owned Optional<Dictionary<τ_0_2, τ_0_3>>
39-
// CHECK: end_borrow [[BORROWED_ARG_COPY]]
35+
// CHECK: [[RESULT:%.*]] = apply [[FN]]<S, Any, S, Int>([[ARG_COPY]]) : $@convention(thin) <τ_0_0, τ_0_1, τ_0_2, τ_0_3 where τ_0_0 : Hashable, τ_0_2 : Hashable> (@guaranteed Dictionary<τ_0_0, τ_0_1>) -> @owned Optional<Dictionary<τ_0_2, τ_0_3>>
4036
// CHECK: destroy_value [[ARG_COPY]]
4137
// CHECK: return [[RESULT]]
4238
func dict_downcast(dict: [S: Any]) -> [S: Int]? {

0 commit comments

Comments
 (0)