Skip to content

Commit 3f8fea8

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents c51550f + e01f75a commit 3f8fea8

File tree

270 files changed

+52324
-2949
lines changed

Some content is hidden

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

270 files changed

+52324
-2949
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,10 @@ option(SWIFT_CHECK_INCREMENTAL_COMPILATION
397397
"Check if incremental compilation works when compiling the Swift libraries"
398398
FALSE)
399399

400+
option(SWIFT_ENABLE_ARRAY_COW_CHECKS
401+
"Compile the stdlib with Array COW checks enabled (only relevant for assert builds)"
402+
FALSE)
403+
400404
option(SWIFT_REPORT_STATISTICS
401405
"Create json files which contain internal compilation statistics"
402406
FALSE)
@@ -494,7 +498,7 @@ endif()
494498
# Use dispatch as the system scheduler by default.
495499
# For convenience, we set this to false when concurrency is disabled.
496500
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
497-
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND NOT SWIFT_STDLIB_SINGLE_THREADED_RUNTIME)
501+
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND "${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
498502
set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE)
499503
endif()
500504

docs/ABI/Mangling.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ Globals
137137
global ::= type assoc-type-list 'MXA' // generic parameter ref (HISTORICAL)
138138
global ::= protocol 'Mp' // protocol descriptor
139139

140+
global ::= protocol 'Hr' // protocol descriptor runtime record
141+
global ::= nominal-type 'Hn' // nominal type descriptor runtime record
142+
#if SWIFT_RUNTIME_VERSION >= 5.1
143+
global ::= opaque-type 'Ho' // opaque type descriptor runtime record
144+
#endif
145+
global ::= protocol-conformance 'Hc' // protocol conformance runtime record
146+
140147
global ::= nominal-type 'Mo' // class metadata immediate member base offset
141148

142149
global ::= type 'MF' // metadata for remote mirrors: field descriptor

docs/ReferenceGuides/UnderscoredAttributes.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,6 @@ library), instead of at an arbitrary point in time.
113113
For more details, see the forum post on
114114
[dynamic method replacement](https://forums.swift.org/t/dynamic-method-replacement/16619).
115115

116-
## `@_distributedActorIndependent`
117-
118-
Marks a specific property of a distributed actor to be available even if the
119-
actor is remote.
120-
121-
This only applies to two distributed actor properties `address` and `transport`.
122-
It cannot be safely declared on any properties defined by ordinary Swift code.
123-
124116
## `@_effects(effectname)`
125117

126118
Tells the compiler that the implementation of the defined function is limited

docs/SIL.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3842,7 +3842,7 @@ mark_function_escape
38423842

38433843
sil-instruction ::= 'mark_function_escape' sil-operand (',' sil-operand)
38443844

3845-
%2 = mark_function_escape %1 : $*T
3845+
mark_function_escape %1 : $*T
38463846

38473847
Indicates that a function definition closes over a symbolic memory location.
38483848
This instruction is variadic, and all of its operands must be addresses.

include/swift/AST/ASTContext.h

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "swift/AST/GenericSignature.h"
2323
#include "swift/AST/Identifier.h"
2424
#include "swift/AST/Import.h"
25+
#include "swift/AST/SILOptions.h"
2526
#include "swift/AST/SearchPathOptions.h"
2627
#include "swift/AST/Type.h"
2728
#include "swift/AST/TypeAlignments.h"
@@ -38,8 +39,8 @@
3839
#include "llvm/ADT/PointerIntPair.h"
3940
#include "llvm/ADT/SetVector.h"
4041
#include "llvm/ADT/SmallPtrSet.h"
41-
#include "llvm/ADT/StringSet.h"
4242
#include "llvm/ADT/StringMap.h"
43+
#include "llvm/ADT/StringSet.h"
4344
#include "llvm/ADT/TinyPtrVector.h"
4445
#include "llvm/Support/Allocator.h"
4546
#include "llvm/Support/DataTypes.h"
@@ -221,11 +222,10 @@ class ASTContext final {
221222
void operator=(const ASTContext&) = delete;
222223

223224
ASTContext(LangOptions &langOpts, TypeCheckerOptions &typeckOpts,
224-
SearchPathOptions &SearchPathOpts,
225+
SILOptions &silOpts, SearchPathOptions &SearchPathOpts,
225226
ClangImporterOptions &ClangImporterOpts,
226227
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
227-
SourceManager &SourceMgr,
228-
DiagnosticEngine &Diags);
228+
SourceManager &SourceMgr, DiagnosticEngine &Diags);
229229

230230
public:
231231
// Members that should only be used by ASTContext.cpp.
@@ -237,7 +237,7 @@ class ASTContext final {
237237
void operator delete(void *Data) throw();
238238

239239
static ASTContext *get(LangOptions &langOpts, TypeCheckerOptions &typeckOpts,
240-
SearchPathOptions &SearchPathOpts,
240+
SILOptions &silOpts, SearchPathOptions &SearchPathOpts,
241241
ClangImporterOptions &ClangImporterOpts,
242242
symbolgraphgen::SymbolGraphOptions &SymbolGraphOpts,
243243
SourceManager &SourceMgr, DiagnosticEngine &Diags);
@@ -255,6 +255,9 @@ class ASTContext final {
255255
/// The type checker options.
256256
const TypeCheckerOptions &TypeCheckerOpts;
257257

258+
/// Options for SIL.
259+
const SILOptions &SILOpts;
260+
258261
/// The search path options used by this AST context.
259262
SearchPathOptions &SearchPathOpts;
260263

@@ -347,6 +350,9 @@ class ASTContext final {
347350
/// Cache of module names that fail the 'canImport' test in this context.
348351
mutable llvm::SmallPtrSet<Identifier, 8> FailedModuleImportNames;
349352

353+
/// Mapping between aliases and real (physical) names of imported or referenced modules.
354+
mutable llvm::DenseMap<Identifier, Identifier> ModuleAliasMap;
355+
350356
/// Retrieve the allocator for the given arena.
351357
llvm::BumpPtrAllocator &
352358
getAllocator(AllocationArena arena = AllocationArena::Permanent) const;
@@ -471,6 +477,16 @@ class ASTContext final {
471477
/// specified string.
472478
Identifier getIdentifier(StringRef Str) const;
473479

480+
/// Convert a given alias map to a map of Identifiers between module aliases and their actual names.
481+
/// For example, if '-module-alias Foo=X -module-alias Bar=Y' input is passed in, the aliases Foo and Bar are
482+
/// the names of the imported or referenced modules in source files in the main module, and X and Y
483+
/// are the real (physical) module names on disk.
484+
void setModuleAliases(const llvm::StringMap<StringRef> &aliasMap);
485+
486+
/// Retrieve the actual module name if a module alias is used via '-module-alias Foo=X', where Foo is
487+
/// a module alias and X is the real (physical) name. Returns \p key if no aliasing is used.
488+
Identifier getRealModuleName(Identifier key) const;
489+
474490
/// Decide how to interpret two precedence groups.
475491
Associativity associateInfixOperators(PrecedenceGroupDecl *left,
476492
PrecedenceGroupDecl *right) const;

include/swift/AST/ASTMangler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ class ASTMangler : public Mangler {
252252
std::string mangleTypeForTypeName(Type type);
253253

254254
std::string mangleOpaqueTypeDescriptor(const OpaqueTypeDecl *decl);
255+
256+
std::string mangleOpaqueTypeDescriptorRecord(const OpaqueTypeDecl *decl);
255257

256258
std::string mangleDeclType(const ValueDecl *decl);
257259

include/swift/AST/Attr.def

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -658,12 +658,7 @@ CONTEXTUAL_SIMPLE_DECL_ATTR(distributed, DistributedActor,
658658
APIBreakingToAdd | APIBreakingToRemove,
659659
118)
660660

661-
SIMPLE_DECL_ATTR(_distributedActorIndependent, DistributedActorIndependent,
662-
OnFunc | OnVar |
663-
DistributedOnly | UserInaccessible |
664-
ABIStableToAdd | ABIStableToRemove |
665-
APIBreakingToAdd | APIBreakingToRemove,
666-
119)
661+
// 119 is unused
667662

668663
SIMPLE_DECL_ATTR(_assemblyVision, EmitAssemblyVisionRemarks,
669664
OnFunc | UserInaccessible | NotSerialized | OnNominalType |

include/swift/AST/Decl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2391,8 +2391,6 @@ class ValueDecl : public Decl {
23912391
/// Is this declaration marked with 'dynamic'?
23922392
bool isDynamic() const;
23932393

2394-
bool isDistributedActorIndependent() const;
2395-
23962394
private:
23972395
bool isObjCDynamic() const {
23982396
return isObjC() && isDynamic();
@@ -4790,8 +4788,6 @@ class AbstractStorageDecl : public ValueDecl {
47904788

47914789
bool hasAnyNativeDynamicAccessors() const;
47924790

4793-
bool isDistributedActorIndependent() const;
4794-
47954791
// Implement isa/cast/dyncast/etc.
47964792
static bool classof(const Decl *D) {
47974793
return D->getKind() >= DeclKind::First_AbstractStorageDecl &&

include/swift/AST/DiagnosticsSema.def

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4329,10 +4329,20 @@ NOTE(note_add_async_to_function,none,
43294329
NOTE(note_add_nonisolated_to_decl,none,
43304330
"add 'nonisolated' to %0 to make this %1 not isolated to the actor",
43314331
(DeclName, DescriptiveDeclKind))
4332+
NOTE(note_add_distributed_to_decl,none,
4333+
"add 'distributed' to %0 to make this %1 witness the protocol requirement",
4334+
(DeclName, DescriptiveDeclKind))
4335+
NOTE(note_distributed_requirement_defined_here,none,
4336+
"distributed function requirement %0 declared here",
4337+
(DeclName))
43324338
NOTE(note_add_globalactor_to_function,none,
43334339
"add '@%0' to make %1 %2 part of global actor %3",
43344340
(StringRef, DescriptiveDeclKind, DeclName, Type))
43354341
FIXIT(insert_globalactor_attr, "@%0 ", (Type))
4342+
4343+
ERROR(main_function_must_be_mainActor,none,
4344+
"main() must be '@MainActor'", ())
4345+
43364346
ERROR(not_objc_function_async,none,
43374347
"'async' %0 cannot be represented in Objective-C", (DescriptiveDeclKind))
43384348
NOTE(not_objc_function_type_async,none,
@@ -4398,8 +4408,8 @@ ERROR(actor_isolated_non_self_reference,none,
43984408
"from the main actor|from a non-isolated context}3",
43994409
(DescriptiveDeclKind, DeclName, unsigned, unsigned, Type))
44004410
ERROR(distributed_actor_isolated_non_self_reference,none,
4401-
"distributed actor-isolated %0 %1 can only be referenced "
4402-
"inside the distributed actor",
4411+
"distributed actor-isolated %0 %1 can only be referenced inside the "
4412+
"distributed actor",
44034413
(DescriptiveDeclKind, DeclName))
44044414
ERROR(distributed_actor_needs_explicit_distributed_import,none,
44054415
"'_Distributed' module not imported, required for 'distributed actor'",
@@ -4453,10 +4463,10 @@ NOTE(actor_isolated_sync_func,none,
44534463
"implicitly asynchronous",
44544464
(DescriptiveDeclKind, DeclName))
44554465
NOTE(distributed_actor_isolated_method_note,none,
4456-
"only 'distributed' functions can be called from outside the distributed actor", // TODO: improve error message
4466+
"only 'distributed' functions can be called from outside the distributed actor", // TODO(distributed): improve error message
44574467
())
44584468
ERROR(distributed_actor_isolated_method,none,
4459-
"only 'distributed' functions can be called from outside the distributed actor", // TODO: improve error message to be more like 'non-distributed' ... defined here
4469+
"only 'distributed' functions can be called from outside the distributed actor", // TODO(distributed): improve error message to be more like 'non-distributed' ... defined here
44604470
())
44614471
ERROR(distributed_actor_func_param_not_codable,none,
44624472
"distributed function parameter '%0' of type %1 does not conform to 'Codable'",
@@ -4610,9 +4620,6 @@ ERROR(distributed_actor_user_defined_special_property,none,
46104620
"property %0 cannot be defined explicitly, as it conflicts with "
46114621
"distributed actor synthesized stored property",
46124622
(DeclName))
4613-
ERROR(distributed_actor_independent_property_must_be_let,none,
4614-
"_distributedActorIndependent can be applied to properties, however they must be 'let'",
4615-
())
46164623
NOTE(distributed_actor_isolated_property,none,
46174624
"distributed actor state is only available within the actor instance", // TODO: reword in terms of isolation
46184625
())

include/swift/AST/Expr.h

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,12 +307,13 @@ class alignas(8) Expr : public ASTAllocated<Expr> {
307307
NumCaptures : 32
308308
);
309309

310-
SWIFT_INLINE_BITFIELD(ApplyExpr, Expr, 1+1+1+1+1,
310+
SWIFT_INLINE_BITFIELD(ApplyExpr, Expr, 1+1+1+1+1+1,
311311
ThrowsIsSet : 1,
312312
Throws : 1,
313313
ImplicitlyAsync : 1,
314314
ImplicitlyThrows : 1,
315-
NoAsync : 1
315+
NoAsync : 1,
316+
ShouldApplyDistributedThunk : 1
316317
);
317318

318319
SWIFT_INLINE_BITFIELD_EMPTY(CallExpr, ApplyExpr);
@@ -1206,7 +1207,9 @@ class DeclRefExpr : public Expr {
12061207
/// which are cross-actor invoked, because such calls actually go over the
12071208
/// transport/network, and may throw from this, rather than the function
12081209
/// implementation itself..
1209-
bool isImplicitlyThrows() const { return Bits.DeclRefExpr.IsImplicitlyThrows; }
1210+
bool isImplicitlyThrows() const {
1211+
return Bits.DeclRefExpr.IsImplicitlyThrows;
1212+
}
12101213

12111214
/// Set whether this reference must account for a `throw` occurring for reasons
12121215
/// other than the function implementation itself throwing, e.g. an
@@ -4335,6 +4338,7 @@ class ApplyExpr : public Expr {
43354338
Bits.ApplyExpr.ImplicitlyAsync = false;
43364339
Bits.ApplyExpr.ImplicitlyThrows = false;
43374340
Bits.ApplyExpr.NoAsync = false;
4341+
Bits.ApplyExpr.ShouldApplyDistributedThunk = false;
43384342
}
43394343

43404344
public:
@@ -4391,7 +4395,7 @@ class ApplyExpr : public Expr {
43914395
///
43924396
/// where the new closure is declared to be async.
43934397
///
4394-
/// When the application is implciitly async, the result describes
4398+
/// When the application is implicitly async, the result describes
43954399
/// the actor to which we need to need to hop.
43964400
Optional<ImplicitActorHopTarget> isImplicitlyAsync() const {
43974401
if (!Bits.ApplyExpr.ImplicitlyAsync)
@@ -4419,6 +4423,15 @@ class ApplyExpr : public Expr {
44194423
Bits.ApplyExpr.ImplicitlyThrows = flag;
44204424
}
44214425

4426+
/// Informs IRGen to that this expression should be applied as its distributed
4427+
/// thunk, rather than invoking the function directly.
4428+
bool shouldApplyDistributedThunk() const {
4429+
return Bits.ApplyExpr.ShouldApplyDistributedThunk;
4430+
}
4431+
void setShouldApplyDistributedThunk(bool flag) {
4432+
Bits.ApplyExpr.ShouldApplyDistributedThunk = flag;
4433+
}
4434+
44224435
ValueDecl *getCalledValue() const;
44234436

44244437
static bool classof(const Expr *E) {

include/swift/AST/IRGenOptions.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ class IRGenOptions {
361361

362362
unsigned WitnessMethodElimination : 1;
363363

364+
unsigned ConditionalRuntimeRecords : 1;
365+
364366
unsigned InternalizeAtLink : 1;
365367

366368
/// The number of threads for multi-threaded code generation.
@@ -422,7 +424,8 @@ class IRGenOptions {
422424
DisableRoundTripDebugTypes(false), DisableDebuggerShadowCopies(false),
423425
DisableConcreteTypeMetadataMangledNameAccessors(false),
424426
EnableGlobalISel(false), VirtualFunctionElimination(false),
425-
WitnessMethodElimination(false), InternalizeAtLink(false),
427+
WitnessMethodElimination(false), ConditionalRuntimeRecords(false),
428+
InternalizeAtLink(false),
426429
CmdArgs(),
427430
SanitizeCoverage(llvm::SanitizerCoverageOptions()),
428431
TypeInfoFilter(TypeInfoDumpFilter::All) {}

include/swift/AST/Module.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,15 @@ class ModuleDecl
366366
ModuleABIName = name;
367367
}
368368

369+
/// Retrieve the actual module name of an alias used for this module (if any).
370+
///
371+
/// For example, if '-module-alias Foo=Bar' is passed in when building the main module,
372+
/// and this module is (a) not the main module and (b) is named Foo, then it returns
373+
/// the real (physically on-disk) module name Bar.
374+
///
375+
/// If no module aliasing is set, it will return getName(), i.e. Foo.
376+
Identifier getRealName() const;
377+
369378
/// User-defined module version number.
370379
llvm::VersionTuple UserModuleVersion;
371380
void setUserModuleVersion(llvm::VersionTuple UserVer) {
@@ -374,6 +383,7 @@ class ModuleDecl
374383
llvm::VersionTuple getUserModuleVersion() const {
375384
return UserModuleVersion;
376385
}
386+
377387
private:
378388
/// A cache of this module's underlying module and required bystander if it's
379389
/// an underscored cross-import overlay.

include/swift/Basic/DAGNodeWorklist.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
///
2626
/// The primary API has two methods: intialize() and pop(). Others are provided
2727
/// for flexibility.
28+
///
29+
/// TODO: This also works well for cyclic graph traversal. Particularly CFG
30+
/// traversal. So we should probably just call it GraphNodeWorklist.
2831
template <typename T, unsigned SmallSize> struct DAGNodeWorklist {
2932
llvm::SmallPtrSet<T, SmallSize> nodeVisited;
3033
llvm::SmallVector<T, SmallSize> nodeVector;

include/swift/Basic/LangOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "llvm/Support/Regex.h"
3232
#include "llvm/Support/VersionTuple.h"
3333
#include "llvm/Support/raw_ostream.h"
34+
#include <atomic>
3435
#include <string>
3536
#include <vector>
3637

include/swift/Demangling/DemangleNodes.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ CONTEXT_NODE(NativeOwningMutableAddressor)
157157
CONTEXT_NODE(NativePinningAddressor)
158158
CONTEXT_NODE(NativePinningMutableAddressor)
159159
NODE(NominalTypeDescriptor)
160+
NODE(NominalTypeDescriptorRecord)
160161
NODE(NonObjCAttribute)
161162
NODE(Number)
162163
NODE(ObjCAsyncCompletionHandlerImpl)
@@ -182,7 +183,9 @@ NODE(ProtocolConformanceRefInTypeModule)
182183
NODE(ProtocolConformanceRefInProtocolModule)
183184
NODE(ProtocolConformanceRefInOtherModule)
184185
NODE(ProtocolDescriptor)
186+
NODE(ProtocolDescriptorRecord)
185187
NODE(ProtocolConformanceDescriptor)
188+
NODE(ProtocolConformanceDescriptorRecord)
186189
NODE(ProtocolList)
187190
NODE(ProtocolListWithClass)
188191
NODE(ProtocolListWithAnyObject)
@@ -289,6 +292,7 @@ NODE(AccessorFunctionReference)
289292
NODE(OpaqueType)
290293
NODE(OpaqueTypeDescriptorSymbolicReference)
291294
NODE(OpaqueTypeDescriptor)
295+
NODE(OpaqueTypeDescriptorRecord)
292296
NODE(OpaqueTypeDescriptorAccessor)
293297
NODE(OpaqueTypeDescriptorAccessorImpl)
294298
NODE(OpaqueTypeDescriptorAccessorKey)

0 commit comments

Comments
 (0)