Skip to content

Commit 6a7a8b8

Browse files
authored
Merge branch 'main' into wip-concurrency-assert-dispatch
2 parents f86cd1b + efbfeb5 commit 6a7a8b8

File tree

374 files changed

+5562
-1736
lines changed

Some content is hidden

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

374 files changed

+5562
-1736
lines changed

CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,18 @@ endif()
979979
set(SWIFT_USE_LINKER ${SWIFT_USE_LINKER_default} CACHE STRING
980980
"Build Swift with a non-default linker")
981981

982+
include(CheckLinkerFlag)
983+
984+
# Apple's linker complains about duplicate libraries, which CMake likes to do
985+
# to support ELF platforms. To silence that warning, we can use
986+
# -no_warn_duplicate_libraries, but only in versions of the linker that
987+
# support that flag.
988+
if(NOT LLVM_USE_LINKER AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
989+
check_linker_flag(C "-Wl,-no_warn_duplicate_libraries" SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
990+
else()
991+
set(SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES OFF CACHE INTERNAL "")
992+
endif()
993+
982994
#
983995
# Enable additional warnings.
984996
#

cmake/caches/Windows-x86_64.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,18 @@ set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR YES CACHE BOOL "")
2828
set(LLVM_ENABLE_PYTHON YES CACHE BOOL "")
2929
set(LLVM_RUNTIME_TARGETS
3030
x86_64-unknown-windows-msvc
31+
aarch64-unknown-windows-msvc
3132
CACHE STRING "")
3233
foreach(target ${LLVM_RUNTIME_TARGETS})
3334
set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES
3435
compiler-rt
3536
CACHE STRING "")
3637
set(RUNTIMES_${target}_CMAKE_MT mt CACHE STRING "")
37-
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
38+
if(${target} MATCHES windows-msvc)
39+
set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Windows CACHE STRING "")
40+
endif()
3841
set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
42+
set(RUNTIMES_${target}_COMPILER_RT_BUILD_BUILTINS YES CACHE BOOL "")
3943
set(RUNTIMES_${target}_COMPILER_RT_BUILD_CRT NO CACHE BOOL "")
4044
set(RUNTIMES_${target}_COMPILER_RT_BUILD_LIBFUZZER NO CACHE BOOL "")
4145
set(RUNTIMES_${target}_COMPILER_RT_BUILD_ORC NO CACHE BOOL "")

cmake/modules/AddSwift.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,12 @@ function(_add_host_variant_link_flags target)
441441
"SHELL:-Xlinker -dead_strip")
442442
endif()
443443
endif()
444+
445+
if(SWIFT_LINKER_SUPPORTS_NO_WARN_DUPLICATE_LIBRARIES)
446+
target_link_options(${target} PRIVATE
447+
"SHELL:-Xlinker -no_warn_duplicate_libraries")
448+
endif()
449+
444450
endfunction()
445451
446452
function(_add_swift_runtime_link_flags target relpath_to_lib_dir bootstrapping)

docs/EmbeddedSwift/EmbeddedSwiftStatus.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ This status table describes which of the following Swift features can be used in
4848

4949
| **Swift Feature** | **Currently Supported In Embedded Swift?** |
5050
|------------------------------------------------------------|-----------------------------------------------------|
51+
| Synchronization module | Yes |
5152
| Swift Concurrency | Partial, experimental (basics of actors and tasks work in single-threaded concurrency mode) |
5253
| C interop | Yes |
5354
| C++ interop | Yes |

docs/EmbeddedSwift/UserManual.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ For (2), external dependencies are also triggered by specific code needing them,
197197
- **atomics instrinsics**
198198
- on CPU architectures that don't have direct load-acquire/store-release support in the ISA, LLVM calls helper functions for atomic operations
199199
- needed by refcounting in the Embedded Swift runtime (so any class usage will trigger this dependency)
200+
- also needed when using atomics from the Synchronization module
200201
- **multiplication/division/modulo instrinsics**
201202
- on CPU architectures that don't have direct support for the math operations in the ISA
202203
- dependency (on Mach-O): `__divti3`

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/ABI/ObjectFile.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class SwiftObjectFileFormatMachO : public SwiftObjectFileFormat {
6060
}
6161

6262
bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
63-
return sectionName.startswith("__swift5_") || sectionName == "__const";
63+
return sectionName.starts_with("__swift5_") || sectionName == "__const";
6464
}
6565
};
6666

@@ -79,7 +79,7 @@ class SwiftObjectFileFormatELF : public SwiftObjectFileFormat {
7979
}
8080

8181
bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
82-
return sectionName.startswith("swift5_");
82+
return sectionName.starts_with("swift5_");
8383
}
8484
};
8585

@@ -98,7 +98,7 @@ class SwiftObjectFileFormatCOFF : public SwiftObjectFileFormat {
9898
}
9999

100100
bool sectionContainsReflectionData(llvm::StringRef sectionName) override {
101-
return sectionName.startswith(".sw5");
101+
return sectionName.starts_with(".sw5");
102102
}
103103
};
104104
} // namespace swift

include/swift/APIDigester/ModuleAnalyzerNodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ class SDKNodeDecl: public SDKNode {
382382
swift::ReferenceOwnership getReferenceOwnership() const {
383383
return swift::ReferenceOwnership(ReferenceOwnership);
384384
}
385-
bool isObjc() const { return Usr.startswith("c:"); }
385+
bool isObjc() const { return Usr.starts_with("c:"); }
386386
static bool classof(const SDKNode *N);
387387
DeclKind getDeclKind() const { return DKind; }
388388
void printFullyQualifiedName(llvm::raw_ostream &OS) const;

include/swift/AST/ASTBridging.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,12 @@ BridgedDeclNameRef
126126
BridgedDeclNameRef_createParsed(BridgedDeclBaseName cBaseName);
127127

128128
class BridgedDeclNameLoc {
129-
const void *_Nonnull LocationInfo;
129+
const void *_Nullable LocationInfo;
130130
size_t NumArgumentLabels;
131131

132132
public:
133+
BridgedDeclNameLoc() : LocationInfo(nullptr), NumArgumentLabels(0) {}
134+
133135
#ifdef USED_IN_CPP_SOURCE
134136
BridgedDeclNameLoc(swift::DeclNameLoc loc)
135137
: LocationInfo(loc.LocationInfo),
@@ -1033,6 +1035,10 @@ BridgedSubscriptDecl_asAbstractStorageDecl(BridgedSubscriptDecl decl);
10331035
// MARK: VarDecl
10341036
//===----------------------------------------------------------------------===//
10351037

1038+
SWIFT_NAME("BridgedVarDecl.createImplicitStringInterpolationVar(_:)")
1039+
BridgedVarDecl BridgedVarDec_createImplicitStringInterpolationVar(
1040+
BridgedDeclContext cDeclContext);
1041+
10361042
SWIFT_NAME("BridgedVarDecl.getSourceLocation(self:)")
10371043
BRIDGED_INLINE BridgedSourceLoc BridgedVarDecl_getSourceLocation(BridgedVarDecl decl);
10381044

@@ -1062,6 +1068,11 @@ struct BridgedCallArgument {
10621068
#endif
10631069
};
10641070

1071+
SWIFT_NAME("BridgedArgumentList.createImplicitUnlabeled(_:exprs:)")
1072+
BridgedArgumentList
1073+
BridgedArgumentList_createImplicitUnlabeled(BridgedASTContext cContext,
1074+
BridgedArrayRef cExprs);
1075+
10651076
SWIFT_NAME("BridgedArgumentList.createParsed(_:lParenLoc:args:rParenLoc:"
10661077
"firstTrailingClosureIndex:)")
10671078
BridgedArgumentList BridgedArgumentList_createParsed(
@@ -1137,6 +1148,12 @@ BridgedCopyExpr BridgedCopyExpr_createParsed(BridgedASTContext cContext,
11371148
BridgedSourceLoc cCopyLoc,
11381149
BridgedExpr cSubExpr);
11391150

1151+
SWIFT_NAME("BridgedDeclRefExpr.create(_:decl:loc:isImplicit:)")
1152+
BridgedDeclRefExpr BridgedDeclRefExpr_create(BridgedASTContext cContext,
1153+
BridgedDecl cDecl,
1154+
BridgedDeclNameLoc cLoc,
1155+
bool IsImplicit);
1156+
11401157
SWIFT_NAME("BridgedDictionaryExpr.createParsed(_:lBracketLoc:elements:"
11411158
"colonLocs:rBracketLoc:)")
11421159
BridgedDictionaryExpr BridgedDictionaryExpr_createParsed(
@@ -1173,6 +1190,13 @@ BridgedIntegerLiteralExpr_createParsed(BridgedASTContext cContext,
11731190
BridgedStringRef cStr,
11741191
BridgedSourceLoc cTokenLoc);
11751192

1193+
SWIFT_NAME("BridgedInterpolatedStringLiteralExpr.createParsed(_:loc:"
1194+
"literalCapacity:interpolationCount:appendingExpr:)")
1195+
BridgedInterpolatedStringLiteralExpr
1196+
BridgedInterpolatedStringLiteralExpr_createParsed(
1197+
BridgedASTContext cContext, BridgedSourceLoc cLoc, size_t literalCapacity,
1198+
size_t interpolationCount, BridgedTapExpr cAppendingExpr);
1199+
11761200
SWIFT_NAME("BridgedIsExpr.createParsed(_:isLoc:type:)")
11771201
BridgedIsExpr BridgedIsExpr_createParsed(BridgedASTContext cContext,
11781202
BridgedSourceLoc cIsLoc,
@@ -1226,6 +1250,10 @@ BridgedStringLiteralExpr_createParsed(BridgedASTContext cContext,
12261250
BridgedStringRef cStr,
12271251
BridgedSourceLoc cTokenLoc);
12281252

1253+
SWIFT_NAME("BridgedTapExpr.create(_:body:)")
1254+
BridgedTapExpr BridgedTapExpr_create(BridgedASTContext cContext,
1255+
BridgedBraceStmt cBody);
1256+
12291257
SWIFT_NAME("BridgedTernaryExpr.createParsed(_:questionLoc:thenExpr:colonLoc:)")
12301258
BridgedTernaryExpr BridgedTernaryExpr_createParsed(
12311259
BridgedASTContext cContext, BridgedSourceLoc cQuestionLoc,

include/swift/AST/ASTDemangler.h

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ class ASTBuilder {
8383
using BuiltProtocolDecl = swift::ProtocolDecl *;
8484
using BuiltGenericSignature = swift::GenericSignature;
8585
using BuiltRequirement = swift::Requirement;
86+
using BuiltInverseRequirement = swift::InverseRequirement;
8687
using BuiltSubstitutionMap = swift::SubstitutionMap;
8788

8889
static constexpr bool needsToPrecomputeParentGenericContextShapes = false;
@@ -161,8 +162,10 @@ class ASTBuilder {
161162

162163
Type createProtocolTypeFromDecl(ProtocolDecl *protocol);
163164

164-
Type createConstrainedExistentialType(Type base,
165-
ArrayRef<BuiltRequirement> constraints);
165+
Type createConstrainedExistentialType(
166+
Type base,
167+
ArrayRef<BuiltRequirement> constraints,
168+
ArrayRef<BuiltInverseRequirement> inverseRequirements);
166169

167170
Type createSymbolicExtendedExistentialType(NodePointer shapeNode,
168171
ArrayRef<Type> genArgs);
@@ -193,9 +196,11 @@ class ASTBuilder {
193196
using BuiltSILBoxField = llvm::PointerIntPair<Type, 1>;
194197
using BuiltSubstitution = std::pair<Type, Type>;
195198
using BuiltLayoutConstraint = swift::LayoutConstraint;
196-
Type createSILBoxTypeWithLayout(ArrayRef<BuiltSILBoxField> Fields,
197-
ArrayRef<BuiltSubstitution> Substitutions,
198-
ArrayRef<BuiltRequirement> Requirements);
199+
Type createSILBoxTypeWithLayout(
200+
ArrayRef<BuiltSILBoxField> Fields,
201+
ArrayRef<BuiltSubstitution> Substitutions,
202+
ArrayRef<BuiltRequirement> Requirements,
203+
ArrayRef<BuiltInverseRequirement> inverseRequirements);
199204

200205
bool isExistential(Type type) {
201206
return type->isExistentialType();
@@ -238,6 +243,9 @@ class ASTBuilder {
238243
unsigned size,
239244
unsigned alignment);
240245

246+
InverseRequirement createInverseRequirement(
247+
Type subject, InvertibleProtocolKind kind);
248+
241249
private:
242250
bool validateParentType(TypeDecl *decl, Type parent);
243251
CanGenericSignature demangleGenericSignature(

include/swift/AST/ASTMangler.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,12 +461,24 @@ class ASTMangler : public Mangler {
461461
bool innermostTypeDecl;
462462
bool extension;
463463
std::optional<unsigned> mangledDepth; // for inverses
464+
std::optional<unsigned> suppressedInnermostDepth;
464465
public:
465466
bool reachedInnermostTypeDecl() {
466467
bool answer = innermostTypeDecl;
467468
innermostTypeDecl = false;
468469
return answer;
469470
}
471+
472+
/// Whether inverses of the innermost declaration's generic parameters
473+
/// should be suppressed.
474+
///
475+
/// This makes sense only for entities that can only ever be defined
476+
/// within the primary type, such as enum cases and the stored properties
477+
/// of struct and class types.
478+
std::optional<unsigned> getSuppressedInnermostInversesDepth() const {
479+
return suppressedInnermostDepth;
480+
}
481+
470482
bool reachedExtension() const { return extension; }
471483
void setReachedExtension() { assert(!extension); extension = true; }
472484
GenericSignature getSignature() const { return sig; }

include/swift/AST/ASTPrinter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class ASTPrinter {
232232
void printKeyword(StringRef name,
233233
const PrintOptions &Opts,
234234
StringRef Suffix = "") {
235-
if (Opts.SkipUnderscoredKeywords && name.startswith("_"))
235+
if (Opts.SkipUnderscoredKeywords && name.starts_with("_"))
236236
return;
237237
assert(!name.empty() && "Tried to print empty keyword");
238238
callPrintNamePre(PrintNameContext::Keyword);

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/AnyFunctionRef.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,6 @@ class AnyFunctionRef {
115115
if (auto *AFD = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
116116
if (auto *FD = dyn_cast<FuncDecl>(AFD))
117117
return FD->mapTypeIntoContext(FD->getResultInterfaceType());
118-
if (auto *CD = dyn_cast<ConstructorDecl>(AFD)) {
119-
if (CD->hasLifetimeDependentReturn()) {
120-
return CD->mapTypeIntoContext(CD->getResultInterfaceType());
121-
}
122-
}
123118
return TupleType::getEmpty(AFD->getASTContext());
124119
}
125120
return TheFunction.get<AbstractClosureExpr *>()->getResultType();

include/swift/AST/Builtins.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ BUILTIN_MISC_OPERATION_WITH_SILGEN(GetCurrentAsyncTask, "getCurrentAsyncTask", "
884884
BUILTIN_MISC_OPERATION_WITH_SILGEN(CancelAsyncTask, "cancelAsyncTask", "", Special)
885885

886886
/// startAsyncLet()<T>: (
887-
/// __owned @Sendable @escaping () async throws -> T
887+
/// __owned @escaping () async throws -> transferring T
888888
/// ) -> Builtin.RawPointer
889889
///
890890
/// DEPRECATED. startAsyncLetWithLocalBuffer is used instead.
@@ -894,7 +894,7 @@ BUILTIN_MISC_OPERATION_WITH_SILGEN(CancelAsyncTask, "cancelAsyncTask", "", Speci
894894
BUILTIN_MISC_OPERATION(StartAsyncLet, "startAsyncLet", "", Special)
895895

896896
/// startAsyncLetWithLocalBuffer()<T>: (
897-
/// __owned @Sendable @escaping () async throws -> T,
897+
/// __owned @escaping () async throws -> transferring T,
898898
/// _ resultBuf: Builtin.RawPointer
899899
/// ) -> Builtin.RawPointer
900900
///

include/swift/AST/Decl.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6497,6 +6497,8 @@ class VarDecl : public AbstractStorageDecl {
64976497

64986498
clang::PointerAuthQualifier getPointerAuthQualifier() const;
64996499

6500+
static VarDecl *createImplicitStringInterpolationVar(DeclContext *DC);
6501+
65006502
// Implement isa/cast/dyncast/etc.
65016503
static bool classof(const Decl *D) {
65026504
return D->getKind() == DeclKind::Var || D->getKind() == DeclKind::Param;

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ ERROR(error_unknown_library_level, none,
4444
"unknown library level '%0', "
4545
"expected one of 'api', 'spi', 'ipi', or 'other'", (StringRef))
4646

47+
ERROR(error_old_spi_only_import_unsupported, none,
48+
"'-experimental-spi-imports' is unsupported in Swift 6, "
49+
"use '@_spiOnly' instead",
50+
())
51+
4752
ERROR(error_unknown_require_explicit_availability, none,
4853
"unknown argument '%0', passed to -require-explicit-availability, "
4954
"expected 'error', 'warn' or 'ignore'",

include/swift/AST/DiagnosticsParse.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,6 +1296,8 @@ ERROR(anon_closure_tuple_param_destructuring,none,
12961296
"closure tuple parameter does not support destructuring", ())
12971297
ERROR(expected_closure_parameter_name,none,
12981298
"expected the name of a closure parameter", ())
1299+
ERROR(nonisolated_closure_parameter_parentheses,none,
1300+
"the parameter list of a 'nonisolated' closure requires parentheses", ())
12991301
ERROR(expected_capture_specifier,none,
13001302
"expected 'weak', 'unowned', or no specifier in capture list", ())
13011303
ERROR(expected_capture_specifier_name,none,

include/swift/AST/DiagnosticsSIL.def

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -968,34 +968,21 @@ NOTE(regionbasedisolation_isolated_since_in_same_region_basename, none,
968968
ERROR(regionbasedisolation_named_transfer_yields_race, none,
969969
"transferring %0 may cause a race",
970970
(Identifier))
971-
ERROR(regionbasedisolation_stronglytransfer_assignment_yields_race_name, none,
972-
"assigning %0 to transferring parameter %1 may cause a race",
973-
(Identifier, Identifier))
974-
NOTE(regionbasedisolation_named_transfer_into_transferring_param, none,
975-
"%0 %1 is passed as a transferring parameter; Uses in callee may race with later %0 uses",
976-
(StringRef, Identifier))
977971

978972
NOTE(regionbasedisolation_named_info_transfer_yields_race, none,
979973
"%0 is transferred from %1 caller to %2 callee. Later uses in caller could race with potential uses in callee",
980974
(Identifier, ActorIsolation, ActorIsolation))
981-
NOTE(regionbasedisolation_transfer_non_transferrable_named_note, none,
975+
NOTE(regionbasedisolation_named_transfer_non_transferrable, none,
982976
"transferring %1 %0 to %2 callee could cause races between %2 and %1 uses",
983977
(Identifier, ActorIsolation, ActorIsolation))
984-
NOTE(regionbasedisolation_named_info_isolated_capture, none,
985-
"%1 value %0 is captured by %2 closure. Later local uses could race",
986-
(Identifier, ActorIsolation, ActorIsolation))
987-
NOTE(regionbasedisolation_named_arg_info, none,
988-
"Transferring task-isolated function argument %0 could yield races with caller uses",
989-
(Identifier))
990-
NOTE(regionbasedisolation_named_stronglytransferred_binding, none,
991-
"Cannot access a transferring parameter after the parameter has been transferred", ())
992-
NOTE(regionbasedisolation_note_arg_passed_to_strongly_transferred_param, none,
993-
"%0 value of type %1 passed as a strongly transferred parameter; later accesses could race",
994-
(StringRef, Identifier, Type))
995-
ERROR(regionbasedisolation_named_arg_passed_to_strongly_transferred_param, none,
996-
"%0 %1 passed as a strongly transferred parameter; Uses in callee could race with later %0 uses",
997-
(StringRef, Identifier))
978+
NOTE(regionbasedisolation_named_transfer_into_transferring_param, none,
979+
"%0 %1 is passed as a transferring parameter; Uses in callee may race with later %0 uses",
980+
(StringRef, Identifier))
981+
NOTE(regionbasedisolation_named_notransfer_transfer_into_result, none,
982+
"%0 %1 cannot be a transferring result. %0 uses may race with caller uses",
983+
(StringRef, Identifier))
998984

985+
// Misc Error.
999986
ERROR(regionbasedisolation_task_or_actor_isolated_transferred, none,
1000987
"task or actor isolated value cannot be transferred", ())
1001988

0 commit comments

Comments
 (0)