Skip to content

Commit 53403e2

Browse files
committed
[+0-all-args] Remove the SILOption EnableGuaranteedNormalArguments and minimally simplify code.
I made this change by removing the SILOption and then doing a compile, fix loop. I purposely did not move around the code to make the refactoring really easy to see.
1 parent 65738ea commit 53403e2

File tree

8 files changed

+15
-67
lines changed

8 files changed

+15
-67
lines changed

include/swift/AST/SILOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ class SILOptions {
9999
/// Should we use a pass pipeline passed in via a json file? Null by default.
100100
llvm::StringRef ExternalPassPipelineFilename;
101101

102-
/// Emit normal function arguments using the +0 guaranteed convention.
103-
bool EnableGuaranteedNormalArguments = true;
104-
105102
/// Don't generate code using partial_apply in SIL generation.
106103
bool DisableSILPartialApply = false;
107104

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
684684
Opts.EnableMandatorySemanticARCOpts |=
685685
!Args.hasArg(OPT_disable_mandatory_semantic_arc_opts);
686686
Opts.EnableLargeLoadableTypes |= Args.hasArg(OPT_enable_large_loadable_types);
687-
Opts.EnableGuaranteedNormalArguments &=
688-
!Args.hasArg(OPT_disable_guaranteed_normal_arguments);
689687

690688
if (const Arg *A = Args.getLastArg(OPT_save_optimization_record_path))
691689
Opts.OptRecordFile = A->getValue();

lib/SIL/SILFunctionType.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,9 +1306,7 @@ getSILFunctionTypeForAbstractCFunction(SILModule &M,
13061306
/// If EnableGuaranteedNormalArguments is set, return a default convention that
13071307
/// uses guaranteed.
13081308
static DefaultConventions getNormalArgumentConvention(SILModule &M) {
1309-
if (M.getOptions().EnableGuaranteedNormalArguments)
1310-
return DefaultConventions(NormalParameterConvention::Guaranteed);
1311-
return DefaultConventions(NormalParameterConvention::Owned);
1309+
return DefaultConventions(NormalParameterConvention::Guaranteed);
13121310
}
13131311

13141312
static CanSILFunctionType getNativeSILFunctionType(

lib/SIL/SILVerifier.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,7 @@ void verifyKeyPathComponent(SILModule &M,
241241
"component for subscript should have indices");
242242
}
243243

244-
ParameterConvention normalArgConvention;
245-
if (M.getOptions().EnableGuaranteedNormalArguments)
246-
normalArgConvention = ParameterConvention::Indirect_In_Guaranteed;
247-
else
248-
normalArgConvention = ParameterConvention::Indirect_In;
244+
auto normalArgConvention = ParameterConvention::Indirect_In_Guaranteed;
249245

250246
// Getter should be <Sig...> @convention(thin) (@in_guaranteed Base) -> @out Result
251247
{

lib/SILGen/SILGenBridging.cpp

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,16 +1144,9 @@ ManagedValue SILGenFunction::emitBridgedToNativeError(SILLocation loc,
11441144
== ResultConvention::Owned);
11451145
auto nativeErrorType = bridgeFnConv.getSILType(bridgeFnType->getResults()[0]);
11461146

1147-
SILValue arg;
1148-
if (SGM.M.getOptions().EnableGuaranteedNormalArguments) {
1149-
assert(bridgeFnType->getParameters()[0].getConvention() ==
1150-
ParameterConvention::Direct_Guaranteed);
1151-
arg = bridgedError.getValue();
1152-
} else {
1153-
assert(bridgeFnType->getParameters()[0].getConvention() ==
1154-
ParameterConvention::Direct_Owned);
1155-
arg = bridgedError.forward(*this);
1156-
}
1147+
assert(bridgeFnType->getParameters()[0].getConvention() ==
1148+
ParameterConvention::Direct_Guaranteed);
1149+
SILValue arg = bridgedError.getValue();
11571150

11581151
SILValue nativeError = B.createApply(loc, bridgeFn, bridgeFn->getType(),
11591152
nativeErrorType, {}, arg);
@@ -1200,16 +1193,9 @@ ManagedValue SILGenFunction::emitNativeToBridgedError(SILLocation loc,
12001193
auto loweredBridgedErrorType =
12011194
bridgeFnConv.getSILType(bridgeFnType->getResults()[0]);
12021195

1203-
SILValue arg;
1204-
if (SGM.M.getOptions().EnableGuaranteedNormalArguments) {
1205-
assert(bridgeFnType->getParameters()[0].getConvention() ==
1206-
ParameterConvention::Direct_Guaranteed);
1207-
arg = nativeError.getValue();
1208-
} else {
1209-
assert(bridgeFnType->getParameters()[0].getConvention() ==
1210-
ParameterConvention::Direct_Owned);
1211-
arg = nativeError.forward(*this);
1212-
}
1196+
assert(bridgeFnType->getParameters()[0].getConvention() ==
1197+
ParameterConvention::Direct_Guaranteed);
1198+
SILValue arg = nativeError.getValue();
12131199

12141200
SILValue bridgedError = B.createApply(loc, bridgeFn, bridgeFn->getType(),
12151201
loweredBridgedErrorType, {}, arg);

lib/SILGen/SILGenExpr.cpp

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2851,14 +2851,8 @@ emitKeyPathRValueBase(SILGenFunction &subSGF,
28512851
if (!storage->getDeclContext()->isTypeContext())
28522852
return ManagedValue();
28532853

2854-
ManagedValue paramOrigValue;
2855-
2856-
if (subSGF.SGM.M.getOptions().EnableGuaranteedNormalArguments) {
2857-
paramOrigValue =
2854+
auto paramOrigValue =
28582855
ManagedValue::forBorrowedRValue(paramArg).copy(subSGF, loc);
2859-
} else {
2860-
paramOrigValue = subSGF.emitManagedRValueWithCleanup(paramArg);
2861-
}
28622856
auto paramSubstValue = subSGF.emitOrigToSubstValue(loc, paramOrigValue,
28632857
AbstractionPattern::getOpaque(),
28642858
baseType);
@@ -2968,11 +2962,7 @@ static SILFunction *getOrCreateKeyPathGetter(SILGenModule &SGM,
29682962
propertyType);
29692963
}
29702964

2971-
ParameterConvention paramConvention;
2972-
if (SGM.M.getOptions().EnableGuaranteedNormalArguments)
2973-
paramConvention = ParameterConvention::Indirect_In_Guaranteed;
2974-
else
2975-
paramConvention = ParameterConvention::Indirect_In;
2965+
auto paramConvention = ParameterConvention::Indirect_In_Guaranteed;
29762966

29772967
SmallVector<SILParameterInfo, 2> params;
29782968
params.push_back({loweredBaseTy.getASTType(),
@@ -3087,11 +3077,7 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
30873077

30883078
auto &C = SGM.getASTContext();
30893079

3090-
ParameterConvention paramConvention;
3091-
if (SGM.M.getOptions().EnableGuaranteedNormalArguments)
3092-
paramConvention = ParameterConvention::Indirect_In_Guaranteed;
3093-
else
3094-
paramConvention = ParameterConvention::Indirect_In;
3080+
auto paramConvention = ParameterConvention::Indirect_In_Guaranteed;
30953081

30963082
SmallVector<SILParameterInfo, 3> params;
30973083
// property value
@@ -3166,12 +3152,8 @@ static SILFunction *getOrCreateKeyPathSetter(SILGenModule &SGM,
31663152
indexes,
31673153
indexPtrArg);
31683154

3169-
ManagedValue valueOrig;
3170-
if (SGM.M.getOptions().EnableGuaranteedNormalArguments)
3171-
valueOrig = ManagedValue::forBorrowedRValue(valueArg)
3155+
auto valueOrig = ManagedValue::forBorrowedRValue(valueArg)
31723156
.copy(subSGF, loc);
3173-
else
3174-
valueOrig = subSGF.emitManagedRValueWithCleanup(valueArg);
31753157
auto valueSubst = subSGF.emitOrigToSubstValue(loc, valueOrig,
31763158
AbstractionPattern::getOpaque(),
31773159
propertyType);

lib/SILOptimizer/Utils/CastOptimizer.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,14 +218,8 @@ SILInstruction *CastOptimizer::optimizeBridgedObjCToSwiftCast(
218218
}
219219

220220
(void)ParamTypes;
221-
if (M.getOptions().EnableGuaranteedNormalArguments) {
222-
assert(ParamTypes[0].getConvention() ==
223-
ParameterConvention::Direct_Guaranteed &&
224-
"Parameter should be @owned");
225-
} else {
226-
assert(ParamTypes[0].getConvention() == ParameterConvention::Direct_Owned &&
227-
"Parameter should be @owned");
228-
}
221+
assert(ParamTypes[0].getConvention() == ParameterConvention::Direct_Guaranteed &&
222+
"Parameter should be @guaranteed");
229223

230224
// Emit a retain.
231225
Builder.createRetainValue(Loc, SrcOp, Builder.getDefaultAtomicity());
@@ -239,9 +233,7 @@ SILInstruction *CastOptimizer::optimizeBridgedObjCToSwiftCast(
239233
// If we have guaranteed normal arguments, insert the destroy.
240234
//
241235
// TODO: Is it safe to just eliminate the initial retain?
242-
if (M.getOptions().EnableGuaranteedNormalArguments) {
243-
Builder.createReleaseValue(Loc, SrcOp, Builder.getDefaultAtomicity());
244-
}
236+
Builder.createReleaseValue(Loc, SrcOp, Builder.getDefaultAtomicity());
245237

246238
// If the source of a cast should be destroyed, emit a release.
247239
if (isa<UnconditionalCheckedCastAddrInst>(Inst)) {

tools/sil-opt/SILOpt.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,6 @@ int main(int argc, char **argv) {
336336
SILOpts.EnableSILOwnership = EnableSILOwnershipOpt;
337337
SILOpts.AssumeUnqualifiedOwnershipWhenParsing =
338338
AssumeUnqualifiedOwnershipWhenParsing;
339-
SILOpts.EnableGuaranteedNormalArguments &= !DisableGuaranteedNormalArguments;
340339

341340
SILOpts.VerifyExclusivity = VerifyExclusivity;
342341
if (EnforceExclusivity.getNumOccurrences() != 0) {

0 commit comments

Comments
 (0)