Skip to content

Commit 6acd261

Browse files
authored
Merge pull request #6716 from gottesmm/eliminate_deallocating_convention
2 parents 2a3817f + d944930 commit 6acd261

29 files changed

+12
-115
lines changed

include/swift/AST/Attr.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ TYPE_ATTR(callee_owned)
5858
TYPE_ATTR(callee_guaranteed)
5959
TYPE_ATTR(objc_metatype)
6060
TYPE_ATTR(opened)
61-
TYPE_ATTR(deallocating)
6261
TYPE_ATTR(pseudogeneric)
6362

6463
// SIL metatype attributes.

include/swift/AST/Types.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,11 +2701,6 @@ enum class ParameterConvention {
27012701
/// validity is guaranteed only at the instant the call begins.
27022702
Direct_Unowned,
27032703

2704-
/// This argument is passed directly. Its type is non-trivial, and the callee
2705-
/// guarantees that the caller can treat the argument as being instantaneously
2706-
/// deallocated when the callee returns.
2707-
Direct_Deallocating,
2708-
27092704
/// This argument is passed directly. Its type is non-trivial, and the caller
27102705
/// guarantees its validity for the entirety of the call.
27112706
Direct_Guaranteed,
@@ -2722,7 +2717,6 @@ inline bool isIndirectParameter(ParameterConvention conv) {
27222717
case ParameterConvention::Direct_Unowned:
27232718
case ParameterConvention::Direct_Guaranteed:
27242719
case ParameterConvention::Direct_Owned:
2725-
case ParameterConvention::Direct_Deallocating:
27262720
return false;
27272721
}
27282722
llvm_unreachable("covered switch isn't covered?!");
@@ -2738,7 +2732,6 @@ inline bool isConsumedParameter(ParameterConvention conv) {
27382732
case ParameterConvention::Direct_Unowned:
27392733
case ParameterConvention::Direct_Guaranteed:
27402734
case ParameterConvention::Indirect_In_Guaranteed:
2741-
case ParameterConvention::Direct_Deallocating:
27422735
return false;
27432736
}
27442737
llvm_unreachable("bad convention kind");
@@ -2758,29 +2751,11 @@ inline bool isGuaranteedParameter(ParameterConvention conv) {
27582751
case ParameterConvention::Indirect_In:
27592752
case ParameterConvention::Direct_Unowned:
27602753
case ParameterConvention::Direct_Owned:
2761-
case ParameterConvention::Direct_Deallocating:
27622754
return false;
27632755
}
27642756
llvm_unreachable("bad convention kind");
27652757
}
27662758

2767-
inline bool isDeallocatingParameter(ParameterConvention conv) {
2768-
switch (conv) {
2769-
case ParameterConvention::Direct_Deallocating:
2770-
return true;
2771-
2772-
case ParameterConvention::Indirect_In:
2773-
case ParameterConvention::Indirect_Inout:
2774-
case ParameterConvention::Indirect_InoutAliasable:
2775-
case ParameterConvention::Indirect_In_Guaranteed:
2776-
case ParameterConvention::Direct_Unowned:
2777-
case ParameterConvention::Direct_Guaranteed:
2778-
case ParameterConvention::Direct_Owned:
2779-
return false;
2780-
}
2781-
llvm_unreachable("covered switch isn't covered?!");
2782-
}
2783-
27842759
/// A parameter type and the rules for passing it.
27852760
class SILParameterInfo {
27862761
CanType Ty;
@@ -2826,13 +2801,6 @@ class SILParameterInfo {
28262801
return isGuaranteedParameter(getConvention());
28272802
}
28282803

2829-
/// Returns true if this parameter is deallocating. This means that the
2830-
/// deallocating bit has been set on the parameter. This means that retains,
2831-
/// releases are inert for the duration of the lifetime of the function.
2832-
bool isDeallocating() const {
2833-
return isDeallocatingParameter(getConvention());
2834-
}
2835-
28362804
SILType getSILType() const; // in SILType.h
28372805

28382806
/// Return a version of this parameter info with the type replaced.

include/swift/SIL/SILArgumentConvention.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ struct SILArgumentConvention {
7272
case ParameterConvention::Direct_Owned:
7373
Value = SILArgumentConvention::Direct_Owned;
7474
return;
75-
case ParameterConvention::Direct_Deallocating:
76-
Value = SILArgumentConvention::Direct_Deallocating;
77-
return;
7875
}
7976
llvm_unreachable("covered switch isn't covered?!");
8077
}

include/swift/Serialization/ModuleFormat.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ enum class ParameterConvention : uint8_t {
199199
Direct_Unowned,
200200
Direct_Guaranteed,
201201
Indirect_In_Guaranteed,
202-
Direct_Deallocating,
203202
};
204203
using ParameterConventionField = BCFixed<4>;
205204

lib/AST/ASTMangler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,6 @@ static char getParamConvention(ParameterConvention conv) {
818818
case ParameterConvention::Direct_Owned: return 'x';
819819
case ParameterConvention::Direct_Unowned: return 'y';
820820
case ParameterConvention::Direct_Guaranteed: return 'g';
821-
case ParameterConvention::Direct_Deallocating: return 'e';
822821
}
823822
llvm_unreachable("bad parameter convention");
824823
};

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3784,9 +3784,6 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
37843784
case ParameterConvention::Direct_Guaranteed:
37853785
Printer << "@callee_guaranteed ";
37863786
return;
3787-
case ParameterConvention::Direct_Deallocating:
3788-
// Closures do not have destructors.
3789-
llvm_unreachable("callee convention cannot be deallocating");
37903787
case ParameterConvention::Indirect_In:
37913788
case ParameterConvention::Indirect_Inout:
37923789
case ParameterConvention::Indirect_InoutAliasable:
@@ -4099,7 +4096,6 @@ static StringRef getStringForParameterConvention(ParameterConvention conv) {
40994096
case ParameterConvention::Direct_Owned: return "@owned ";
41004097
case ParameterConvention::Direct_Unowned: return "";
41014098
case ParameterConvention::Direct_Guaranteed: return "@guaranteed ";
4102-
case ParameterConvention::Direct_Deallocating: return "@deallocating ";
41034099
}
41044100
llvm_unreachable("bad parameter convention");
41054101
}

lib/AST/Mangle.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,6 @@ void Mangler::mangleType(Type type, unsigned uncurryLevel) {
10001000
case ParameterConvention::Direct_Owned: return 'o';
10011001
case ParameterConvention::Direct_Unowned: return 'd';
10021002
case ParameterConvention::Direct_Guaranteed: return 'g';
1003-
case ParameterConvention::Direct_Deallocating: return 'e';
10041003
}
10051004
llvm_unreachable("bad parameter convention");
10061005
};

lib/IRGen/GenCall.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,6 @@ void SignatureExpansion::expand(SILParameterInfo param) {
876876
case ParameterConvention::Direct_Owned:
877877
case ParameterConvention::Direct_Unowned:
878878
case ParameterConvention::Direct_Guaranteed:
879-
case ParameterConvention::Direct_Deallocating:
880879
switch (FnType->getLanguage()) {
881880
case SILFunctionLanguage::C: {
882881
llvm_unreachable("Unexpected C/ObjC method in parameter expansion!");

lib/IRGen/GenClangType.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,6 @@ clang::CanQualType GenClangType::visitSILFunctionType(CanSILFunctionType type) {
554554
switch (paramTy.getConvention()) {
555555
case ParameterConvention::Direct_Guaranteed:
556556
case ParameterConvention::Direct_Unowned:
557-
case ParameterConvention::Direct_Deallocating:
558557
// OK.
559558
break;
560559

lib/IRGen/GenFunc.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,6 @@ static llvm::Function *emitPartialApplicationForwarder(IRGenModule &IGM,
794794
case ParameterConvention::Direct_Guaranteed:
795795
consumesContext = false;
796796
break;
797-
case ParameterConvention::Direct_Deallocating:
798-
llvm_unreachable("callables do not have destructors");
799797
case ParameterConvention::Indirect_Inout:
800798
case ParameterConvention::Indirect_InoutAliasable:
801799
case ParameterConvention::Indirect_In:
@@ -889,7 +887,6 @@ static llvm::Function *emitPartialApplicationForwarder(IRGenModule &IGM,
889887
dependsOnContextLifetime = true;
890888
break;
891889

892-
case ParameterConvention::Direct_Deallocating:
893890
case ParameterConvention::Indirect_Inout:
894891
case ParameterConvention::Indirect_InoutAliasable:
895892
llvm_unreachable("should never happen!");
@@ -986,15 +983,9 @@ static llvm::Function *emitPartialApplicationForwarder(IRGenModule &IGM,
986983
// depends on the context to not be deallocated.
987984
if (!fieldTI.isPOD(ResilienceExpansion::Maximal))
988985
dependsOnContextLifetime = true;
989-
SWIFT_FALLTHROUGH;
990-
case ParameterConvention::Direct_Deallocating:
986+
991987
// Load these parameters directly. We can "take" since the parameter is
992-
// +0. This can happen due to either:
993-
//
994-
// 1. The context keeping the parameter alive.
995-
// 2. The object being a deallocating object. This means retains and
996-
// releases do not affect the object since we do not support object
997-
// resurrection.
988+
// +0. This can happen since the context will keep the parameter alive.
998989
cast<LoadableTypeInfo>(fieldTI).loadAsTake(subIGF, fieldAddr, param);
999990
break;
1000991
case ParameterConvention::Direct_Owned:
@@ -1194,7 +1185,6 @@ void irgen::emitFunctionPartialApplication(IRGenFunction &IGF,
11941185
case ParameterConvention::Direct_Owned:
11951186
case ParameterConvention::Direct_Unowned:
11961187
case ParameterConvention::Direct_Guaranteed:
1197-
case ParameterConvention::Direct_Deallocating:
11981188
argLoweringTy = argType.getSwiftRValueType();
11991189
break;
12001190

@@ -1401,7 +1391,6 @@ void irgen::emitFunctionPartialApplication(IRGenFunction &IGF,
14011391
case ParameterConvention::Direct_Unowned:
14021392
case ParameterConvention::Direct_Owned:
14031393
case ParameterConvention::Direct_Guaranteed:
1404-
case ParameterConvention::Direct_Deallocating:
14051394
case ParameterConvention::Indirect_Inout:
14061395
case ParameterConvention::Indirect_InoutAliasable:
14071396
cast<LoadableTypeInfo>(fieldLayout.getType())

lib/IRGen/GenObjC.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ static llvm::Function *emitObjCPartialApplicationForwarder(IRGenModule &IGM,
802802
bool retainsSelf;
803803
switch (origMethodType->getParameters().back().getConvention()) {
804804
case ParameterConvention::Direct_Unowned:
805-
case ParameterConvention::Direct_Deallocating:
806805
retainsSelf = false;
807806
break;
808807
case ParameterConvention::Direct_Guaranteed:

lib/IRGen/GenProto.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ void PolymorphicConvention::considerParameter(SILParameterInfo param,
351351
case ParameterConvention::Direct_Owned:
352352
case ParameterConvention::Direct_Unowned:
353353
case ParameterConvention::Direct_Guaranteed:
354-
case ParameterConvention::Direct_Deallocating:
355354
// Classes are sources of metadata.
356355
if (type->getClassOrBoundGenericClass()) {
357356
considerNewTypeSource(MetadataSource::Kind::ClassPointer,

lib/Parse/ParseDecl.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,6 @@ bool Parser::parseTypeAttribute(TypeAttributes &Attributes, bool justChecking) {
14891489
case TAK_owned:
14901490
case TAK_unowned_inner_pointer:
14911491
case TAK_guaranteed:
1492-
case TAK_deallocating:
14931492
case TAK_autoreleased:
14941493
case TAK_callee_owned:
14951494
case TAK_callee_guaranteed:

lib/SIL/SILFunctionType.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,6 @@ namespace {
18371837
case ParameterConvention::Direct_Guaranteed:
18381838
if (isTrivial) return ParameterConvention::Direct_Unowned;
18391839
SWIFT_FALLTHROUGH;
1840-
case ParameterConvention::Direct_Deallocating:
18411840
case ParameterConvention::Direct_Unowned:
18421841
case ParameterConvention::Indirect_Inout:
18431842
case ParameterConvention::Indirect_InoutAliasable:

lib/SIL/SILOwnershipVerifier.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,6 @@ OwnershipUseCheckerResult OwnershipCompatibilityUseChecker::visitCallee(
434434
case ParameterConvention::Indirect_In_Guaranteed:
435435
case ParameterConvention::Indirect_Inout:
436436
case ParameterConvention::Indirect_InoutAliasable:
437-
case ParameterConvention::Direct_Deallocating:
438437
llvm_unreachable("Illegal convention for callee");
439438
case ParameterConvention::Direct_Unowned:
440439
return {compatibleWithOwnership(ValueOwnershipKind::Trivial), false};

lib/SIL/SILPrinter.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,6 @@ class SILPrinter : public SILVisitor<SILPrinter> {
934934

935935
// Should not apply to callees.
936936
case ParameterConvention::Direct_Unowned:
937-
case ParameterConvention::Direct_Deallocating:
938937
case ParameterConvention::Indirect_In:
939938
case ParameterConvention::Indirect_Inout:
940939
case ParameterConvention::Indirect_In_Guaranteed:

lib/SILGen/SILGenApply.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,11 +2361,6 @@ RValue SILGenFunction::emitApply(
23612361
}
23622362
break;
23632363

2364-
// If self is already deallocating, self does not need to be retained or
2365-
// released since the deallocating bit has been set.
2366-
case ParameterConvention::Direct_Deallocating:
2367-
break;
2368-
23692364
case ParameterConvention::Indirect_In_Guaranteed:
23702365
case ParameterConvention::Indirect_In:
23712366
case ParameterConvention::Indirect_Inout:
@@ -5051,7 +5046,6 @@ ArgumentSource SILGenFunction::prepareAccessorBaseArg(SILLocation loc,
50515046
case ParameterConvention::Direct_Owned:
50525047
case ParameterConvention::Direct_Unowned:
50535048
case ParameterConvention::Direct_Guaranteed:
5054-
case ParameterConvention::Direct_Deallocating:
50555049
return true;
50565050
}
50575051
llvm_unreachable("bad convention");

lib/SILGen/SILGenBridging.cpp

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,7 @@ static void buildFuncToBlockInvokeBody(SILGenFunction &gen,
269269
case ParameterConvention::Direct_Owned:
270270
gen.emitManagedRValueWithCleanup(v);
271271
break;
272-
273-
case ParameterConvention::Direct_Deallocating:
272+
274273
case ParameterConvention::Direct_Guaranteed:
275274
case ParameterConvention::Direct_Unowned:
276275
break;
@@ -297,12 +296,6 @@ static void buildFuncToBlockInvokeBody(SILGenFunction &gen,
297296
mv = gen.emitManagedRetain(loc, v);
298297
break;
299298

300-
case ParameterConvention::Direct_Deallocating:
301-
// We do not need to retain the value since the value is already being
302-
// deallocated.
303-
mv = ManagedValue::forUnmanaged(v);
304-
break;
305-
306299
case ParameterConvention::Indirect_In_Guaranteed:
307300
case ParameterConvention::Indirect_In:
308301
case ParameterConvention::Indirect_Inout:
@@ -935,14 +928,6 @@ static SILFunctionType *emitObjCThunkArguments(SILGenFunction &gen,
935928
continue;
936929
}
937930

938-
// If this parameter is deallocating, emit an unmanaged rvalue and
939-
// continue. The object has the deallocating bit set so retain, release is
940-
// irrelevant.
941-
if (inputs[i].isDeallocating()) {
942-
bridgedArgs.push_back(ManagedValue::forUnmanaged(arg));
943-
continue;
944-
}
945-
946931
// If the argument is a block, copy it.
947932
if (argTy.isBlockPointerCompatible()) {
948933
auto copy = gen.B.createCopyBlock(loc, arg);
@@ -1260,9 +1245,6 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) {
12601245
case ParameterConvention::Direct_Unowned:
12611246
param = emitManagedRetain(fd, paramValue);
12621247
break;
1263-
case ParameterConvention::Direct_Deallocating:
1264-
param = ManagedValue::forUnmanaged(paramValue);
1265-
break;
12661248
case ParameterConvention::Indirect_Inout:
12671249
case ParameterConvention::Indirect_InoutAliasable:
12681250
param = ManagedValue::forLValue(paramValue);

lib/SILGen/SILGenPoly.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,9 +730,6 @@ static ManagedValue manageParam(SILGenFunction &gen,
730730
SILParameterInfo info,
731731
bool allowPlusZero) {
732732
switch (info.getConvention()) {
733-
// A deallocating parameter can always be accessed directly.
734-
case ParameterConvention::Direct_Deallocating:
735-
return ManagedValue::forUnmanaged(paramValue);
736733
case ParameterConvention::Direct_Guaranteed:
737734
if (allowPlusZero)
738735
return ManagedValue::forUnmanaged(paramValue);
@@ -1235,7 +1232,6 @@ namespace {
12351232
// Direct translation is relatively easy.
12361233
case ParameterConvention::Direct_Owned:
12371234
case ParameterConvention::Direct_Unowned:
1238-
case ParameterConvention::Direct_Deallocating:
12391235
case ParameterConvention::Direct_Guaranteed: {
12401236
auto output = translatePrimitive(inputOrigType, inputSubstType,
12411237
outputOrigType, outputSubstType,

lib/SILGen/SILGenProlog.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ class EmitBBArguments : public CanTypeVisitor<EmitBBArguments,
8888
ManagedValue getManagedValue(SILValue arg, CanType t,
8989
SILParameterInfo parameterInfo) const {
9090
switch (parameterInfo.getConvention()) {
91-
case ParameterConvention::Direct_Deallocating:
92-
// If we have a deallocating parameter, it is passed in at +0 and will not
93-
// be deallocated since we do not allow for resurrection.
94-
return ManagedValue::forUnmanaged(arg);
95-
9691
case ParameterConvention::Direct_Guaranteed:
9792
case ParameterConvention::Indirect_In_Guaranteed:
9893
// If we have a guaranteed parameter, it is passed in at +0, and its

lib/SILOptimizer/Mandatory/DIMemoryUseCollector.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,6 @@ void ElementUseCollector::collectUses(SILValue Pointer, unsigned BaseEltNo) {
748748
case ParameterConvention::Direct_Owned:
749749
case ParameterConvention::Direct_Unowned:
750750
case ParameterConvention::Direct_Guaranteed:
751-
case ParameterConvention::Direct_Deallocating:
752751
llvm_unreachable("address value passed to indirect parameter");
753752

754753
// If this is an in-parameter, it is like a load.

lib/SILOptimizer/SILCombiner/SILCombinerApplyVisitors.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,6 @@ bool SILCombiner::eraseApply(FullApplySite FAS, const UserListTy &Users) {
521521
case ParameterConvention::Indirect_Inout:
522522
case ParameterConvention::Indirect_InoutAliasable:
523523
case ParameterConvention::Direct_Unowned:
524-
case ParameterConvention::Direct_Deallocating:
525524
case ParameterConvention::Direct_Guaranteed:
526525
break;
527526
}

lib/SILOptimizer/Utils/Local.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,8 +1737,6 @@ optimizeBridgedSwiftToObjCCast(SILInstruction *Inst,
17371737
case ParameterConvention::Indirect_InoutAliasable:
17381738
// TODO handle remaining indirect argument types
17391739
return nullptr;
1740-
case ParameterConvention::Direct_Deallocating:
1741-
llvm_unreachable("unsupported convention for bridging conversion");
17421740
}
17431741

17441742
if (needRetainBeforeCall)

lib/Sema/TypeCheckType.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,8 +2379,6 @@ SILParameterInfo TypeResolver::resolveSILParameter(
23792379
checkFor(TypeAttrKind::TAK_owned, ParameterConvention::Direct_Owned);
23802380
checkFor(TypeAttrKind::TAK_guaranteed,
23812381
ParameterConvention::Direct_Guaranteed);
2382-
checkFor(TypeAttrKind::TAK_deallocating,
2383-
ParameterConvention::Direct_Deallocating);
23842382

23852383
type = resolveAttributedType(attrs, attrRepr->getTypeRepr(), options);
23862384
} else {

lib/Serialization/Deserialization.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3478,7 +3478,6 @@ Optional<swift::ParameterConvention> getActualParameterConvention(uint8_t raw) {
34783478
CASE(Direct_Owned)
34793479
CASE(Direct_Unowned)
34803480
CASE(Direct_Guaranteed)
3481-
CASE(Direct_Deallocating)
34823481
#undef CASE
34833482
}
34843483
return None;

lib/Serialization/Serialization.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2903,7 +2903,6 @@ static uint8_t getRawStableParameterConvention(swift::ParameterConvention pc) {
29032903
SIMPLE_CASE(ParameterConvention, Direct_Owned)
29042904
SIMPLE_CASE(ParameterConvention, Direct_Unowned)
29052905
SIMPLE_CASE(ParameterConvention, Direct_Guaranteed)
2906-
SIMPLE_CASE(ParameterConvention, Direct_Deallocating)
29072906
}
29082907
llvm_unreachable("bad parameter convention kind");
29092908
}

0 commit comments

Comments
 (0)