Skip to content

Commit 472787b

Browse files
committed
SIL: isNonThrowing parameter of SILBuilder::create{Begin,}Apply() defaults to false
Also remove the overload of createApply() that does not take a SubstitutionMap. It accomplishes nothing except creating ambiguity.
1 parent a0197b3 commit 472787b

20 files changed

+44
-51
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -452,22 +452,13 @@ class SILBuilder {
452452

453453
ApplyInst *createApply(
454454
SILLocation Loc, SILValue Fn, SubstitutionMap Subs,
455-
ArrayRef<SILValue> Args, bool isNonThrowing,
455+
ArrayRef<SILValue> Args, bool isNonThrowing = false,
456456
const GenericSpecializationInformation *SpecializationInfo = nullptr) {
457457
return insert(ApplyInst::create(getSILDebugLocation(Loc), Fn, Subs, Args,
458458
isNonThrowing, C.silConv, *F,
459459
C.OpenedArchetypes, SpecializationInfo));
460460
}
461461

462-
ApplyInst *createApply(
463-
SILLocation Loc, SILValue Fn, ArrayRef<SILValue> Args, bool isNonThrowing,
464-
const GenericSpecializationInformation *SpecializationInfo = nullptr) {
465-
SILFunctionConventions conventions(Fn->getType().castTo<SILFunctionType>(),
466-
getModule());
467-
return createApply(Loc, Fn, SubstitutionMap(), Args, isNonThrowing,
468-
SpecializationInfo);
469-
}
470-
471462
TryApplyInst *createTryApply(
472463
SILLocation Loc, SILValue fn, SubstitutionMap subs,
473464
ArrayRef<SILValue> args, SILBasicBlock *normalBB, SILBasicBlock *errorBB,
@@ -490,7 +481,7 @@ class SILBuilder {
490481

491482
BeginApplyInst *createBeginApply(
492483
SILLocation Loc, SILValue Fn, SubstitutionMap Subs,
493-
ArrayRef<SILValue> Args, bool isNonThrowing,
484+
ArrayRef<SILValue> Args, bool isNonThrowing = false,
494485
const GenericSpecializationInformation *SpecializationInfo = nullptr) {
495486
return insert(BeginApplyInst::create(
496487
getSILDebugLocation(Loc), Fn, Subs, Args, isNonThrowing, C.silConv, *F,

lib/SILGen/SILGenApply.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,15 +1785,15 @@ static void emitRawApply(SILGenFunction &SGF,
17851785
// If the function is a coroutine, we need to use 'begin_apply'.
17861786
if (substFnType->isCoroutine()) {
17871787
assert(!substFnType->hasErrorResult());
1788-
auto apply = SGF.B.createBeginApply(loc, fnValue, subs, argValues, false);
1788+
auto apply = SGF.B.createBeginApply(loc, fnValue, subs, argValues);
17891789
for (auto result : apply->getAllResults())
17901790
rawResults.push_back(result);
17911791
return;
17921792
}
17931793

17941794
// If we don't have an error result, we can make a simple 'apply'.
17951795
if (!substFnType->hasErrorResult()) {
1796-
auto result = SGF.B.createApply(loc, fnValue, subs, argValues, false);
1796+
auto result = SGF.B.createApply(loc, fnValue, subs, argValues);
17971797
rawResults.push_back(result);
17981798

17991799
// Otherwise, we need to create a try_apply.
@@ -4533,7 +4533,7 @@ SILValue SILGenFunction::emitApplyWithRethrow(SILLocation loc, SILValue fn,
45334533
SILType resultType = fnConv.getSILResultType();
45344534

45354535
if (!silFnType->hasErrorResult()) {
4536-
return B.createApply(loc, fn, subs, args, false);
4536+
return B.createApply(loc, fn, subs, args);
45374537
}
45384538

45394539
SILBasicBlock *errorBB = createBasicBlock();
@@ -4567,7 +4567,7 @@ SILGenFunction::emitBeginApplyWithRethrow(SILLocation loc, SILValue fn,
45674567
// TODO: adjust this to create try_begin_apply when appropriate.
45684568
assert(!substFnType.castTo<SILFunctionType>()->hasErrorResult());
45694569

4570-
auto beginApply = B.createBeginApply(loc, fn, subs, args, false);
4570+
auto beginApply = B.createBeginApply(loc, fn, subs, args);
45714571

45724572
auto yieldResults = beginApply->getYieldedValues();
45734573
yields.append(yieldResults.begin(), yieldResults.end());

lib/SILGen/SILGenBridging.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ emitBridgeNativeToObjectiveC(SILGenFunction &SGF,
156156
// Call the witness.
157157
SILValue bridgedValue =
158158
SGF.B.createApply(loc, witnessRef, typeSubMap,
159-
swiftValue.borrow(SGF, loc).getValue(), false);
159+
swiftValue.borrow(SGF, loc).getValue());
160160

161161
auto bridgedMV = SGF.emitManagedRValueWithCleanup(bridgedValue);
162162
bridgedMV = scope.popPreservingValue(bridgedMV);
@@ -252,7 +252,7 @@ static ManagedValue emitBridgeBoolToObjCBool(SILGenFunction &SGF,
252252
= SGF.emitGlobalFunctionRef(loc, SGF.SGM.getBoolToObjCBoolFn());
253253

254254
SILValue result = SGF.B.createApply(loc, boolToObjCBoolFn,
255-
{}, swiftBool.forward(SGF), false);
255+
{}, swiftBool.forward(SGF));
256256
return SGF.emitManagedRValueWithCleanup(result);
257257
}
258258

@@ -264,7 +264,7 @@ static ManagedValue emitBridgeBoolToDarwinBoolean(SILGenFunction &SGF,
264264
= SGF.emitGlobalFunctionRef(loc, SGF.SGM.getBoolToDarwinBooleanFn());
265265

266266
SILValue result = SGF.B.createApply(loc, boolToDarwinBooleanFn,
267-
{}, swiftBool.forward(SGF), false);
267+
{}, swiftBool.forward(SGF));
268268
return SGF.emitManagedRValueWithCleanup(result);
269269
}
270270

@@ -276,7 +276,7 @@ static ManagedValue emitBridgeForeignBoolToBool(SILGenFunction &SGF,
276276
SILValue bridgingFn = SGF.emitGlobalFunctionRef(loc, bridgingFnRef);
277277

278278
SILValue result = SGF.B.createApply(loc, bridgingFn, {},
279-
foreignBool.forward(SGF), false);
279+
foreignBool.forward(SGF));
280280
return SGF.emitManagedRValueWithCleanup(result);
281281
}
282282

@@ -1142,7 +1142,7 @@ ManagedValue SILGenFunction::emitBridgedToNativeError(SILLocation loc,
11421142

11431143
SILValue arg = bridgedError.getValue();
11441144

1145-
SILValue nativeError = B.createApply(loc, bridgeFn, {}, arg, false);
1145+
SILValue nativeError = B.createApply(loc, bridgeFn, {}, arg);
11461146
return emitManagedRValueWithCleanup(nativeError);
11471147
}
11481148

@@ -1188,7 +1188,7 @@ ManagedValue SILGenFunction::emitNativeToBridgedError(SILLocation loc,
11881188

11891189
SILValue arg = nativeError.getValue();
11901190

1191-
SILValue bridgedError = B.createApply(loc, bridgeFn, {}, arg, false);
1191+
SILValue bridgedError = B.createApply(loc, bridgeFn, {}, arg);
11921192
return emitManagedRValueWithCleanup(bridgedError);
11931193
}
11941194

@@ -1490,7 +1490,7 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) {
14901490
assert(foreignError.hasValue() == substTy->hasErrorResult());
14911491
if (!substTy->hasErrorResult()) {
14921492
// Create the apply.
1493-
result = B.createApply(loc, nativeFn, subs, args, false);
1493+
result = B.createApply(loc, nativeFn, subs, args);
14941494

14951495
if (substConv.hasIndirectSILResults()) {
14961496
assert(substTy->getNumResults() == 1);

lib/SILGen/SILGenDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ SILValue SILGenFunction::emitOSVersionRangeCheck(SILLocation loc,
12361236
loc, silDeclRef, getConstantInfo(silDeclRef));
12371237

12381238
SILValue args[] = {majorValue, minorValue, subminorValue};
1239-
return B.createApply(loc, availabilityGTEFn, args, false);
1239+
return B.createApply(loc, availabilityGTEFn, SubstitutionMap(), args);
12401240
}
12411241

12421242

lib/SILGen/SILGenDestructor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void SILGenFunction::emitDestroyingDestructor(DestructorDecl *dd) {
6969
= emitSiblingMethodRef(cleanupLoc, baseSelf, dtorConstant, subMap);
7070

7171
resultSelfValue = B.createApply(cleanupLoc, dtorValue.forward(*this),
72-
subMap, baseSelf, false);
72+
subMap, baseSelf);
7373
} else {
7474
resultSelfValue = selfValue;
7575
}
@@ -129,7 +129,7 @@ void SILGenFunction::emitDeallocatingDestructor(DestructorDecl *dd) {
129129
FullExpr CleanupScope(Cleanups, CleanupLocation::get(loc));
130130
ManagedValue borrowedSelf = emitManagedBeginBorrow(loc, initialSelfValue);
131131
selfForDealloc = B.createApply(loc, dtorValue.forward(*this), subMap,
132-
borrowedSelf.getUnmanagedValue(), false);
132+
borrowedSelf.getUnmanagedValue());
133133
}
134134

135135
// Balance out the +1 from the self argument using end_lifetime.
@@ -246,7 +246,7 @@ void SILGenFunction::emitObjCDestructor(SILDeclRef dtor) {
246246
= superclassTy->getContextSubstitutionMap(SGM.M.getSwiftModule(),
247247
superclass);
248248

249-
B.createApply(cleanupLoc, superclassDtorValue, subMap, superSelf, false);
249+
B.createApply(cleanupLoc, superclassDtorValue, subMap, superSelf);
250250

251251
// We know that the givne value came in at +1, but we pass the relevant value
252252
// as unowned to the destructor. Create a fake balance for the verifier to be

lib/SILGen/SILGenFunction.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
516516
SILType::getPrimitiveObjectType(anyObjectMetaTy),
517517
{});
518518
SILValue optNameValue = B.createApply(
519-
mainClass, NSStringFromClass, {}, metaTy, false);
519+
mainClass, NSStringFromClass, {}, metaTy);
520520
ManagedValue optName = emitManagedRValueWithCleanup(optNameValue);
521521

522522
// Fix up the string parameters to have the right type.
@@ -556,7 +556,7 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
556556
SILValue args[] = {argc, managedArgv.getValue(), nilValue,
557557
optName.getValue()};
558558

559-
B.createApply(mainClass, UIApplicationMain, SubstitutionMap{}, args, false);
559+
B.createApply(mainClass, UIApplicationMain, SubstitutionMap(), args);
560560
SILValue r = B.createIntegerLiteral(mainClass,
561561
SILType::getBuiltinIntegerType(32, ctx), 0);
562562
auto rType = F.getConventions().getSingleSILResultType();
@@ -601,7 +601,7 @@ void SILGenFunction::emitArtificialTopLevel(ClassDecl *mainClass) {
601601
auto NSApplicationMain = B.createFunctionRef(mainClass, NSApplicationMainFn);
602602
SILValue args[] = { argc, argv };
603603

604-
B.createApply(mainClass, NSApplicationMain, SubstitutionMap{}, args, false);
604+
B.createApply(mainClass, NSApplicationMain, SubstitutionMap(), args);
605605
SILValue r = B.createIntegerLiteral(mainClass,
606606
SILType::getBuiltinIntegerType(32, getASTContext()), 0);
607607
auto rType = F.getConventions().getSingleSILResultType();

lib/SILGen/SILGenGlobalVariable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ SILGenFunction::emitGlobalVariableRef(SILLocation loc, VarDecl *var) {
7575
SILDeclRef(var, SILDeclRef::Kind::GlobalAccessor),
7676
NotForDefinition);
7777
SILValue accessor = B.createFunctionRefFor(loc, accessorFn);
78-
SILValue addr = B.createApply(loc, accessor, SubstitutionMap{}, {}, false);
78+
SILValue addr = B.createApply(loc, accessor, SubstitutionMap(), {});
7979
// FIXME: It'd be nice if the result of the accessor was natively an
8080
// address.
8181
addr = B.createPointerToAddress(

lib/SILOptimizer/Analysis/ArraySemantic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ bool swift::ArraySemanticsCall::replaceByAppendingValues(
751751
Builder.createIntegerLiteral(Loc, BuiltinIntTy, Vals.size());
752752
StructInst *Capacity = Builder.createStruct(Loc,
753753
SILType::getPrimitiveObjectType(CanType(IntType)), {CapacityLiteral});
754-
Builder.createApply(Loc, ReserveFnRef, Subs, {Capacity, ArrRef}, false);
754+
Builder.createApply(Loc, ReserveFnRef, Subs, {Capacity, ArrRef});
755755
}
756756

757757
for (SILValue V : Vals) {
@@ -764,7 +764,7 @@ bool swift::ArraySemanticsCall::replaceByAppendingValues(
764764
IsInitialization_t::IsInitialization);
765765

766766
SILValue Args[] = {AllocStackInst, ArrRef};
767-
Builder.createApply(Loc, FnRef, Subs, Args, false);
767+
Builder.createApply(Loc, FnRef, Subs, Args);
768768
Builder.createDeallocStack(Loc, AllocStackInst);
769769
if (!isConsumedParameter(AppendFnTy->getParameters()[0].getConvention())) {
770770
ValLowering.emitDestroyValue(Builder, Loc, CopiedVal);

lib/SILOptimizer/FunctionSignatureTransforms/ExistentialTransform.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ void ExistentialTransform::populateThunkBody() {
475475
Builder.setInsertionPoint(NormalBlock);
476476
} else {
477477
/// Create the Apply with substitutions
478-
ReturnValue = Builder.createApply(Loc, FRI, SubMap, ApplyArgs, false);
478+
ReturnValue = Builder.createApply(Loc, FRI, SubMap, ApplyArgs);
479479
}
480480

481481
/// Set up the return results.

lib/SILOptimizer/FunctionSignatureTransforms/FunctionSignatureOpts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ void FunctionSignatureTransform::createFunctionSignatureOptimizedFunction() {
598598
Builder.createThrow(Loc, ErrorArg);
599599
Builder.setInsertionPoint(NormalBlock);
600600
} else {
601-
ReturnValue = Builder.createApply(Loc, FRI, Subs, ThunkArgs, false);
601+
ReturnValue = Builder.createApply(Loc, FRI, Subs, ThunkArgs);
602602
}
603603

604604
// Set up the return results.

0 commit comments

Comments
 (0)