Skip to content

Commit f7fcab0

Browse files
authored
Merge branch 'release/6.0' into release/6.0-more-fixes
2 parents 99fee4e + 19da726 commit f7fcab0

File tree

195 files changed

+688
-548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+688
-548
lines changed

SwiftCompilerSources/Sources/Optimizer/FunctionPasses/ComputeSideEffects.swift

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ private struct CollectedEffects {
215215
}
216216

217217
mutating func addEffectsForEscapingArgument(argument: FunctionArgument) {
218-
var escapeWalker = ArgumentEscapingWalker()
218+
var escapeWalker = ArgumentEscapingWalker(context)
219219

220220
if escapeWalker.hasUnknownUses(argument: argument) {
221221
// Worst case: we don't know anything about how the argument escapes.
@@ -414,13 +414,18 @@ private func defaultPath(for value: Value) -> SmallProjectionPath {
414414
/// Checks if an argument escapes to some unknown user.
415415
private struct ArgumentEscapingWalker : ValueDefUseWalker, AddressDefUseWalker {
416416
var walkDownCache = WalkerCache<UnusedWalkingPath>()
417+
private let calleeAnalysis: CalleeAnalysis
417418

418419
/// True if the argument escapes to a load which (potentially) "takes" the memory location.
419420
private(set) var foundTakingLoad = false
420421

421422
/// True, if the argument escapes to a closure context which might be destroyed when called.
422423
private(set) var foundConsumingPartialApply = false
423424

425+
init(_ context: FunctionPassContext) {
426+
self.calleeAnalysis = context.calleeAnalysis
427+
}
428+
424429
mutating func hasUnknownUses(argument: FunctionArgument) -> Bool {
425430
if argument.type.isAddress {
426431
return walkDownUses(ofAddress: argument, path: UnusedWalkingPath()) == .abortWalk
@@ -444,14 +449,23 @@ private struct ArgumentEscapingWalker : ValueDefUseWalker, AddressDefUseWalker {
444449
return .continueWalk
445450

446451
case let apply as ApplySite:
447-
if apply.isCallee(operand: value) {
448-
// `CollectedEffects.handleApply` only handles argument operands of an apply, but not the callee operand.
449-
return .abortWalk
450-
}
451452
if let pa = apply as? PartialApplyInst, !pa.isOnStack {
452453
foundConsumingPartialApply = true
453454
}
454-
return .continueWalk
455+
// `CollectedEffects.handleApply` only handles argument operands of an apply, but not the callee operand.
456+
if let calleeArgIdx = apply.calleeArgumentIndex(of: value),
457+
let callees = calleeAnalysis.getCallees(callee: apply.callee)
458+
{
459+
// If an argument escapes in a called function, we don't know anything about the argument's side effects.
460+
// For example, it could escape to the return value and effects might occur in the caller.
461+
for callee in callees {
462+
if callee.effects.escapeEffects.canEscape(argumentIndex: calleeArgIdx, path: SmallProjectionPath.init(.anyValueFields)) {
463+
return .abortWalk
464+
}
465+
}
466+
return .continueWalk
467+
}
468+
return .abortWalk
455469
default:
456470
return .abortWalk
457471
}

include/swift/AST/DiagnosticsParse.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ ERROR(extra_var_in_multiple_pattern_list,none,
984984
ERROR(let_pattern_in_immutable_context,none,
985985
"'let' pattern cannot appear nested in an already immutable context", ())
986986
WARNING(borrowing_syntax_change,none,
987-
"'_borrowing' spelling is deprecated; use 'borrowing' without the underscore", ())
987+
"'borrowing' in pattern matches is deprecated; use 'let'", ())
988988
ERROR(borrowing_subpattern_unsupported,none,
989989
"'borrowing' pattern modifier must be directly applied to pattern variable name", ())
990990
ERROR(specifier_must_have_type,none,

include/swift/Basic/Features.def

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ LANGUAGE_FEATURE(MoveOnlyPartialConsumption, 429, "Partial consumption of noncop
179179
LANGUAGE_FEATURE(BitwiseCopyable, 426, "BitwiseCopyable protocol")
180180
SUPPRESSIBLE_LANGUAGE_FEATURE(ConformanceSuppression, 426, "Suppressible inferred conformances")
181181
SUPPRESSIBLE_LANGUAGE_FEATURE(BitwiseCopyable2, 426, "BitwiseCopyable feature")
182+
SUPPRESSIBLE_LANGUAGE_FEATURE(NoncopyableGenerics, 427, "Noncopyable generics")
182183

183184
// Swift 6
184185
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
@@ -196,6 +197,7 @@ UPCOMING_FEATURE(RegionBasedIsolation, 414, 6)
196197
UPCOMING_FEATURE(DynamicActorIsolation, 423, 6)
197198
UPCOMING_FEATURE(NonfrozenEnumExhaustivity, 192, 6)
198199
UPCOMING_FEATURE(GlobalActorIsolatedTypesUsability, 0434, 6)
200+
UPCOMING_FEATURE(BorrowingSwitch, 432, 6)
199201

200202
// Swift 7
201203
UPCOMING_FEATURE(ExistentialAny, 335, 7)
@@ -322,9 +324,6 @@ EXPERIMENTAL_FEATURE(RawLayout, true)
322324
/// Enables the "embedded" swift mode (no runtime).
323325
EXPERIMENTAL_FEATURE(Embedded, true)
324326

325-
/// Enables noncopyable generics
326-
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(NoncopyableGenerics, true)
327-
328327
// Alias for NoncopyableGenerics
329328
EXPERIMENTAL_FEATURE(NoncopyableGenerics2, true)
330329

@@ -353,9 +352,6 @@ EXPERIMENTAL_FEATURE(GroupActorErrors, true)
353352
// Allow for the 'transferring' keyword to be applied to arguments and results.
354353
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(TransferringArgsAndResults, true)
355354

356-
// Allow for `switch` of noncopyable values to be borrowing or consuming.
357-
EXPERIMENTAL_FEATURE(BorrowingSwitch, true)
358-
359355
// Enable explicit isolation of closures.
360356
EXPERIMENTAL_FEATURE(ClosureIsolation, true)
361357

include/swift/Runtime/EnvironmentVariables.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ SWIFT_RUNTIME_STDLIB_SPI bool concurrencyEnableJobDispatchIntegration();
5353
// Concurrency library can call.
5454
SWIFT_RUNTIME_STDLIB_SPI bool concurrencyValidateUncheckedContinuations();
5555

56+
// Wrapper around SWIFT_IS_CURRENT_EXECUTOR_LEGACY_MODE_OVERRIDE that the
57+
// Concurrency library can call.
58+
SWIFT_RUNTIME_STDLIB_SPI const char *concurrencyIsCurrentExecutorLegacyModeOverride();
59+
5660
} // end namespace environment
5761
} // end namespace runtime
5862
} // end namespace swift

lib/ASTGen/Sources/ASTGen/SourceFile.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ extension Parser.ExperimentalFeatures {
6060
mapFeature(.DoExpressions, to: .doExpressions)
6161
mapFeature(.NonescapableTypes, to: .nonescapableTypes)
6262
mapFeature(.TransferringArgsAndResults, to: .transferringArgsAndResults)
63-
mapFeature(.BorrowingSwitch, to: .borrowingSwitch)
6463
}
6564
}
6665

lib/Basic/LangOptions.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ LangOptions::LangOptions() {
4747
#endif
4848

4949
// Note: Introduce default-on language options here.
50+
Features.insert(Feature::NoncopyableGenerics);
51+
Features.insert(Feature::BorrowingSwitch);
52+
Features.insert(Feature::MoveOnlyPartialConsumption);
5053

5154
// Enable any playground options that are enabled by default.
5255
#define PLAYGROUND_OPTION(OptionName, Description, DefaultOn, HighPerfOn) \

lib/ClangImporter/ClangImporter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5778,16 +5778,16 @@ cloneBaseMemberDecl(ValueDecl *decl, DeclContext *newContext) {
57785778
if (auto var = dyn_cast<VarDecl>(decl)) {
57795779
auto oldContext = var->getDeclContext();
57805780
auto oldTypeDecl = oldContext->getSelfNominalTypeDecl();
5781-
// If the base type is non-copyable, and non-copyable generics are disabled,
5782-
// we cannot synthesize the accessor, because its implementation would use
5783-
// `UnsafePointer<BaseTy>`.
5781+
// If the base type is non-copyable, we cannot synthesize the accessor,
5782+
// because its implementation would use `UnsafePointer<BaseTy>`, and that
5783+
// triggers a bug when building SwiftCompilerSources. (rdar://128013193)
5784+
//
57845785
// We cannot use `ty->isNoncopyable()` here because that would create a
57855786
// cyclic dependency between ModuleQualifiedLookupRequest and
57865787
// LookupConformanceInModuleRequest, so we check for the presence of
57875788
// move-only attribute that is implicitly added to non-copyable C++ types by
57885789
// ClangImporter.
5789-
if (oldTypeDecl->getAttrs().hasAttribute<MoveOnlyAttr>() &&
5790-
!context.LangOpts.hasFeature(Feature::NoncopyableGenerics))
5790+
if (oldTypeDecl->getAttrs().hasAttribute<MoveOnlyAttr>())
57915791
return nullptr;
57925792

57935793
auto rawMemory = allocateMemoryForDecl<VarDecl>(var->getASTContext(),

lib/ClangImporter/ImportType.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,10 @@ namespace {
509509
return importFunctionPointerLikeType(*type, pointeeType);
510510
}
511511

512-
// If non-copyable generics are disabled, we cannot specify
513-
// UnsafePointer<T> with a non-copyable type T.
512+
// We cannot specify UnsafePointer<T> with a non-copyable type T just yet,
513+
// because it triggers a bug when building SwiftCompilerSources.
514+
// (rdar://128013193)
515+
//
514516
// We cannot use `ty->isNoncopyable()` here because that would create a
515517
// cyclic dependency between ModuleQualifiedLookupRequest and
516518
// LookupConformanceInModuleRequest, so we check for the presence of
@@ -519,9 +521,7 @@ namespace {
519521
if (pointeeType && pointeeType->getAnyNominal() &&
520522
pointeeType->getAnyNominal()
521523
->getAttrs()
522-
.hasAttribute<MoveOnlyAttr>() &&
523-
!Impl.SwiftContext.LangOpts.hasFeature(
524-
Feature::NoncopyableGenerics)) {
524+
.hasAttribute<MoveOnlyAttr>()) {
525525
auto opaquePointerDecl = Impl.SwiftContext.getOpaquePointerDecl();
526526
if (!opaquePointerDecl)
527527
return Type();

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,13 +470,6 @@ static void SaveModuleInterfaceArgs(ModuleInterfaceOptions &Opts,
470470
interleave(RenderedArgs,
471471
[&](const char *Argument) { PrintArg(OS, Argument, StringRef()); },
472472
[&] { OS << " "; });
473-
474-
// Backward-compatibility hack: disable availability checking in the
475-
// _Concurrency module, so that older (Swift 5.5) compilers that did not
476-
// support back deployment of concurrency do not complain about 'async'
477-
// with older availability.
478-
if (FOpts.ModuleName == "_Concurrency")
479-
OS << " -disable-availability-checking";
480473
}
481474
{
482475
llvm::raw_string_ostream OS(Opts.IgnorablePrivateFlags);

lib/IRGen/LoadableByAddress.cpp

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
//===----------------------------------------------------------------------===//
1818

1919
#define DEBUG_TYPE "loadable-address"
20-
#include "Explosion.h"
2120
#include "FixedTypeInfo.h"
2221
#include "IRGenMangler.h"
2322
#include "IRGenModule.h"
@@ -3432,29 +3431,6 @@ class AddressAssignment {
34323431
toDeleteBlockArg.push_back(std::make_pair(b, argIdx));
34333432
}
34343433

3435-
bool isPotentiallyCArray(SILType ty) {
3436-
if (ty.isAddress() || ty.isClassOrClassMetatype()) {
3437-
return false;
3438-
}
3439-
3440-
auto canType = ty.getASTType();
3441-
if (canType->hasTypeParameter()) {
3442-
assert(genEnv && "Expected a GenericEnv");
3443-
canType = genEnv->mapTypeIntoContext(canType)->getCanonicalType();
3444-
}
3445-
3446-
if (canType.getAnyGeneric() || isa<TupleType>(canType)) {
3447-
assert(ty.isObject() &&
3448-
"Expected only two categories: address and object");
3449-
assert(!canType->hasTypeParameter());
3450-
const TypeInfo &TI = irgenModule->getTypeInfoForLowered(canType);
3451-
auto explosionSchema = TI.getSchema();
3452-
if (explosionSchema.size() > 15)
3453-
return true;
3454-
}
3455-
return false;
3456-
}
3457-
34583434
bool isLargeLoadableType(SILType ty) {
34593435
if (ty.isAddress() || ty.isClassOrClassMetatype()) {
34603436
return false;
@@ -3472,11 +3448,7 @@ class AddressAssignment {
34723448
assert(!canType->hasTypeParameter());
34733449
const TypeInfo &TI = irgenModule->getTypeInfoForLowered(canType);
34743450
auto &nativeSchemaOrigParam = TI.nativeParameterValueSchema(*irgenModule);
3475-
if (nativeSchemaOrigParam.size() > 15)
3476-
return true;
3477-
auto explosionSchema = TI.getSchema();
3478-
if (explosionSchema.size() > 15)
3479-
return true;
3451+
return nativeSchemaOrigParam.size() > 15;
34803452
}
34813453
return false;
34823454
}
@@ -3489,7 +3461,7 @@ class AddressAssignment {
34893461
auto it = valueToAddressMap.find(v);
34903462

34913463
// This can happen if we deem a container type small but a contained type
3492-
// big.
3464+
// big or if we lower an undef value.
34933465
if (it == valueToAddressMap.end()) {
34943466
if (auto *sv = dyn_cast<SingleValueInstruction>(v)) {
34953467
auto addr = createAllocStack(v->getType());
@@ -3499,6 +3471,11 @@ class AddressAssignment {
34993471
mapValueToAddress(v, addr);
35003472
return addr;
35013473
}
3474+
if (isa<SILUndef>(v)) {
3475+
auto undefAddr = createAllocStack(v->getType());
3476+
mapValueToAddress(v, undefAddr);
3477+
return undefAddr;
3478+
}
35023479
}
35033480
assert(it != valueToAddressMap.end());
35043481

@@ -3794,6 +3771,7 @@ class AssignAddressToDef : SILInstructionVisitor<AssignAddressToDef> {
37943771
StoreOwnershipQualifier::Unqualified);
37953772
assignment.mapValueToAddress(origValue, addr);
37963773
assignment.markForDeletion(bc);
3774+
37973775
return;
37983776
}
37993777
auto opdAddr = assignment.getAddressForValue(bc->getOperand());
@@ -3955,9 +3933,7 @@ class RewriteUser : SILInstructionVisitor<RewriteUser> {
39553933
}
39563934

39573935
void visitDebugValueInst(DebugValueInst *dbg) {
3958-
if (!dbg->hasAddrVal() &&
3959-
(assignment.isPotentiallyCArray(dbg->getOperand()->getType()) ||
3960-
overlapsWithOnStackDebugLoc(dbg->getOperand()))) {
3936+
if (!dbg->hasAddrVal() && overlapsWithOnStackDebugLoc(dbg->getOperand())) {
39613937
assignment.markForDeletion(dbg);
39623938
return;
39633939
}

lib/Macros/Sources/SwiftMacros/DistributedResolvableMacro.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,6 @@ extension DistributedResolvableMacro {
133133
var isGenericStub = false
134134
var specificActorSystemRequirement: TypeSyntax?
135135

136-
if proto.genericWhereClause == nil {
137-
throw DiagnosticsError(
138-
syntax: node,
139-
message: """
140-
Distributed protocol must declare actor system with SerializationRequirement, for example:
141-
protocol Greeter<ActorSystem>: DistributedActor where ActorSystem: DistributedActorSystem<any Codable>
142-
""", id: .invalidApplication)
143-
}
144-
145136
let accessModifiers = proto.accessControlModifiers
146137

147138
for req in proto.genericWhereClause?.requirements ?? [] {

lib/Option/SanitizerOptions.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ llvm::SanitizerCoverageOptions swift::parseSanitizerCoverageArgValue(
9292
} else if (StringRef(A->getValue(i)) == "trace-pc-guard") {
9393
opts.TracePCGuard = true;
9494
continue;
95+
} else if (StringRef(A->getValue(i)) == "inline-8bit-counters") {
96+
opts.Inline8bitCounters = true;
97+
continue;
98+
} else if (StringRef(A->getValue(i)) == "pc-table") {
99+
opts.PCTable = true;
100+
continue;
95101
}
96102

97103
// Argument is not supported.

0 commit comments

Comments
 (0)