Skip to content

Commit a245391

Browse files
authored
Merge pull request #72265 from eeckstein/fix-mandatory-inlining
MandatoryInlining and ConstExpr: look through sendable function conversions
2 parents 11d7d53 + 3c76464 commit a245391

34 files changed

+101
-83
lines changed

include/swift/ABI/MetadataValues.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@ class TargetFunctionTypeFlags {
11191119
}
11201120

11211121
constexpr TargetFunctionTypeFlags<int_type>
1122-
withConcurrent(bool isSendable) const {
1122+
withSendable(bool isSendable) const {
11231123
return TargetFunctionTypeFlags<int_type>(
11241124
(Data & ~SendableMask) |
11251125
(isSendable ? SendableMask : 0));

include/swift/AST/ASTSynthesis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ ASTExtInfo synthesizeExtInfo(SynthesisContext &SC,
490490
template <class S>
491491
ASTExtInfo synthesizeExtInfo(SynthesisContext &SC,
492492
const SendableModSynthesizer<S> &s) {
493-
return synthesizeExtInfo(SC, s.sub).withConcurrent();
493+
return synthesizeExtInfo(SC, s.sub).withSendable();
494494
}
495495

496496
/// Synthesize a function type.

include/swift/AST/ExtInfo.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ class ASTExtInfoBuilder {
620620
clangTypeInfo, globalActor, thrownError, lifetimeDependenceInfo);
621621
}
622622
[[nodiscard]]
623-
ASTExtInfoBuilder withConcurrent(bool concurrent = true) const {
623+
ASTExtInfoBuilder withSendable(bool concurrent = true) const {
624624
return ASTExtInfoBuilder(
625625
concurrent ? (bits | SendableMask) : (bits & ~SendableMask),
626626
clangTypeInfo, globalActor, thrownError, lifetimeDependenceInfo);
@@ -808,10 +808,10 @@ class ASTExtInfo {
808808

809809
/// Helper method for changing only the concurrent field.
810810
///
811-
/// Prefer using \c ASTExtInfoBuilder::withConcurrent for chaining.
811+
/// Prefer using \c ASTExtInfoBuilder::withSendable for chaining.
812812
[[nodiscard]]
813-
ASTExtInfo withConcurrent(bool concurrent = true) const {
814-
return builder.withConcurrent(concurrent).build();
813+
ASTExtInfo withSendable(bool isSendable = true) const {
814+
return builder.withSendable(isSendable).build();
815815
}
816816

817817
/// Helper method for changing only the throws field.
@@ -1122,7 +1122,7 @@ class SILExtInfoBuilder {
11221122
clangTypeInfo, lifetimeDependenceInfo);
11231123
}
11241124
[[nodiscard]]
1125-
SILExtInfoBuilder withConcurrent(bool isSendable = true) const {
1125+
SILExtInfoBuilder withSendable(bool isSendable = true) const {
11261126
return SILExtInfoBuilder(isSendable ? (bits | SendableMask)
11271127
: (bits & ~SendableMask),
11281128
clangTypeInfo, lifetimeDependenceInfo);
@@ -1294,8 +1294,8 @@ class SILExtInfo {
12941294
return builder.withNoEscape(noEscape).build();
12951295
}
12961296

1297-
SILExtInfo withConcurrent(bool isSendable = true) const {
1298-
return builder.withConcurrent(isSendable).build();
1297+
SILExtInfo withSendable(bool isSendable = true) const {
1298+
return builder.withSendable(isSendable).build();
12991299
}
13001300

13011301
SILExtInfo withAsync(bool isAsync = true) const {

include/swift/Demangling/TypeDecoder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ class ImplFunctionTypeFlags {
311311
}
312312

313313
ImplFunctionTypeFlags
314-
withConcurrent() const {
314+
withSendable() const {
315315
return ImplFunctionTypeFlags(
316316
ImplFunctionRepresentation(Rep), Pseudogeneric, Escaping, true, Async,
317317
ErasedIsolation,
@@ -967,7 +967,7 @@ class TypeDecoder {
967967
++firstChildIdx;
968968
}
969969

970-
flags = flags.withConcurrent(isSendable)
970+
flags = flags.withSendable(isSendable)
971971
.withAsync(isAsync).withThrows(isThrow)
972972
.withDifferentiable(diffKind.isDifferentiable());
973973

@@ -1046,7 +1046,7 @@ class TypeDecoder {
10461046
if (!child->hasText())
10471047
return MAKE_NODE_TYPE_ERROR0(child, "expected text");
10481048
if (child->getText() == "@Sendable") {
1049-
flags = flags.withConcurrent();
1049+
flags = flags.withSendable();
10501050
} else if (child->getText() == "@async") {
10511051
flags = flags.withAsync();
10521052
}

include/swift/RemoteInspection/TypeRefBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ class TypeRefBuilder {
11621162
break;
11631163
}
11641164

1165-
funcFlags = funcFlags.withConcurrent(flags.isSendable());
1165+
funcFlags = funcFlags.withSendable(flags.isSendable());
11661166
funcFlags = funcFlags.withAsync(flags.isAsync());
11671167
funcFlags = funcFlags.withDifferentiable(flags.isDifferentiable());
11681168
extFuncFlags =

include/swift/SIL/SILInstruction.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5740,6 +5740,9 @@ class ConvertFunctionInst final
57405740
/// argument and return types, as well as all other attributes, after substitution,
57415741
/// such as converting `$<A, B> in (A) -> B for <Int, String>` to `(Int) -> String`.
57425742
bool onlyConvertsSubstitutions() const;
5743+
5744+
/// Returns true if the source and destination types only differ by `@Sendable`.
5745+
bool onlyConvertsSendable() const;
57435746
};
57445747

57455748
/// ConvertEscapeToNoEscapeInst - Change the type of a escaping function value

lib/AST/ASTDemangler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ Type ASTBuilder::createFunctionType(
475475
resultDiffKind, clangFunctionType, isolation,
476476
LifetimeDependenceInfo(), extFlags.hasTransferringResult())
477477
.withAsync(flags.isAsync())
478-
.withConcurrent(flags.isSendable())
478+
.withSendable(flags.isSendable())
479479
.build();
480480

481481
return FunctionType::get(funcParams, output, einfo);

lib/AST/Builtins.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,7 @@ static ValueDecl *getCreateAsyncTask(ASTContext &ctx, Identifier id,
15651565
builder.addParameter(makeConcrete(ctx.TheExecutorType)); // executor
15661566
}
15671567
auto extInfo = ASTExtInfoBuilder().withAsync().withThrows()
1568-
.withConcurrent(true).build();
1568+
.withSendable(true).build();
15691569
Type operationResultType;
15701570
if (isDiscarding) {
15711571
operationResultType = TupleType::getEmpty(ctx); // ()

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3377,7 +3377,7 @@ mapSignatureExtInfo(AnyFunctionType::ExtInfo info,
33773377
return AnyFunctionType::ExtInfo();
33783378
return AnyFunctionType::ExtInfoBuilder()
33793379
.withRepresentation(info.getRepresentation())
3380-
.withConcurrent(info.isSendable())
3380+
.withSendable(info.isSendable())
33813381
.withAsync(info.isAsync())
33823382
.withThrows(info.isThrowing(), info.getThrownError())
33833383
.withClangFunctionType(info.getClangTypeInfo().getType())

lib/AST/Type.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ Type TypeBase::stripConcurrency(bool recurse, bool dropGlobalActor) {
920920
// Strip off Sendable and (possibly) the global actor.
921921
ASTExtInfo extInfo =
922922
fnType->hasExtInfo() ? fnType->getExtInfo() : ASTExtInfo();
923-
extInfo = extInfo.withConcurrent(false);
923+
extInfo = extInfo.withSendable(false);
924924
if (dropGlobalActor)
925925
extInfo = extInfo.withoutIsolation();
926926

@@ -3156,12 +3156,12 @@ static bool matchesFunctionType(CanAnyFunctionType fn1, CanAnyFunctionType fn2,
31563156
// Removing '@Sendable' is ABI-compatible because there's nothing wrong with
31573157
// a function being sendable when it doesn't need to be.
31583158
if (!ext2.isSendable())
3159-
ext1 = ext1.withConcurrent(false);
3159+
ext1 = ext1.withSendable(false);
31603160
}
31613161

31623162
if (matchMode.contains(TypeMatchFlags::IgnoreFunctionSendability)) {
3163-
ext1 = ext1.withConcurrent(false);
3164-
ext2 = ext2.withConcurrent(false);
3163+
ext1 = ext1.withSendable(false);
3164+
ext2 = ext2.withSendable(false);
31653165
}
31663166

31673167
// If specified, allow an escaping function parameter to override a

0 commit comments

Comments
 (0)