Skip to content

Commit d9ee3f4

Browse files
committed
Make behavior changes for addressable types unconditional.
With the other fixes, it is now possible to build the stdlib without conditionalizing these behaviors. This will allow libraries to adopt addressability as an experimental feature without breaking ABI when interacting with other code.
1 parent f9d9d75 commit d9ee3f4

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,20 +1779,17 @@ class DestructureInputs {
17791779
ParameterTypeFlags origFlags) {
17801780
assert(!isa<InOutType>(substType));
17811781

1782-
if (TC.Context.LangOpts.hasFeature(Feature::AddressableTypes)
1783-
|| TC.Context.LangOpts.hasFeature(Feature::AddressableParameters)) {
1784-
// If the parameter is marked addressable, lower it with maximal
1785-
// abstraction.
1786-
if (origFlags.isAddressable()) {
1782+
// If the parameter is marked addressable, lower it with maximal
1783+
// abstraction.
1784+
if (origFlags.isAddressable()) {
1785+
origType = AbstractionPattern::getOpaque();
1786+
} else if (hasScopedDependency) {
1787+
// If there is a scoped dependency on this parameter, and the parameter
1788+
// is addressable-for-dependencies, then lower it with maximal abstraction
1789+
// as well.
1790+
auto &initialSubstTL = TC.getTypeLowering(origType, substType, expansion);
1791+
if (initialSubstTL.getRecursiveProperties().isAddressableForDependencies()) {
17871792
origType = AbstractionPattern::getOpaque();
1788-
} else if (hasScopedDependency) {
1789-
// If there is a scoped dependency on this parameter, and the parameter
1790-
// is addressable-for-dependencies, then lower it with maximal abstraction
1791-
// as well.
1792-
auto &initialSubstTL = TC.getTypeLowering(origType, substType, expansion);
1793-
if (initialSubstTL.getRecursiveProperties().isAddressableForDependencies()) {
1794-
origType = AbstractionPattern::getOpaque();
1795-
}
17961793
}
17971794
}
17981795

lib/SILGen/SILGenProlog.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,7 @@ class EmitBBArguments : public CanTypeVisitor<EmitBBArguments,
210210
return handleInOut(origType, substType, pd->isAddressable());
211211
}
212212
// Addressability also suppresses exploding the parameter.
213-
if ((SGF.getASTContext().LangOpts.hasFeature(Feature::AddressableTypes)
214-
|| SGF.getASTContext().LangOpts.hasFeature(Feature::AddressableParameters))
215-
&& isAddressable) {
213+
if (isAddressable) {
216214
return handleScalar(claimNextParameter(),
217215
AbstractionPattern::getOpaque(), substType,
218216
/*emitInto*/ nullptr,
@@ -740,15 +738,12 @@ class ArgumentInitHelper {
740738
// addressability can be implied by a scoped dependency.
741739
bool isAddressable = false;
742740

743-
if (SGF.getASTContext().LangOpts.hasFeature(Feature::AddressableTypes)
744-
|| SGF.getASTContext().LangOpts.hasFeature(Feature::AddressableParameters)) {
745-
isAddressable = pd->isAddressable()
746-
|| (ScopedDependencies.contains(pd)
747-
&& SGF.getTypeLowering(origType, substType)
748-
.getRecursiveProperties().isAddressableForDependencies());
749-
if (isAddressable) {
750-
AddressableParams.insert(pd);
751-
}
741+
isAddressable = pd->isAddressable()
742+
|| (ScopedDependencies.contains(pd)
743+
&& SGF.getTypeLowering(origType, substType)
744+
.getRecursiveProperties().isAddressableForDependencies());
745+
if (isAddressable) {
746+
AddressableParams.insert(pd);
752747
}
753748
paramValue = argEmitter.handleParam(origType, substType, pd,
754749
isAddressable);

0 commit comments

Comments
 (0)