Skip to content

Commit 0556ae6

Browse files
authored
Merge pull request #3996 from swiftwasm/main
2 parents 29bc6a5 + cfce85b commit 0556ae6

File tree

290 files changed

+104792
-27832
lines changed

Some content is hidden

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

290 files changed

+104792
-27832
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -560,16 +560,24 @@ function(add_swift_host_library name)
560560
561561
if(NOT ${CMAKE_C_COMPILER_ID} STREQUAL MSVC)
562562
swift_windows_get_sdk_vfs_overlay(ASHL_VFS_OVERLAY)
563-
target_compile_options(${name} PRIVATE
564-
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:"SHELL:-Xclang -ivfsoverlay -Xclang ${ASHL_VFS_OVERLAY}">)
565-
566-
# MSVC doesn't support -Xclang. We don't need to manually specify
567-
# the dependent libraries as `cl` does so.
568-
target_compile_options(${name} PRIVATE
569-
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:"SHELL:-Xclang --dependent-lib=oldnames">
570-
# TODO(compnerd) handle /MT, /MTd
571-
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:"SHELL:-Xclang --dependent-lib=msvcrt$<$<CONFIG:Debug>:d>">
572-
)
563+
# Both clang and clang-cl on Windows set CMAKE_C_SIMULATE_ID to MSVC.
564+
# We are using CMAKE_C_COMPILER_FRONTEND_VARIANT to detect the correct
565+
# way to pass -Xclang arguments.
566+
if ("${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC")
567+
target_compile_options(${name} PRIVATE
568+
$<$<COMPILE_LANGUAGE:C,CXX>:SHELL:/clang:-Xclang /clang:-ivfsoverlay /clang:-Xclang /clang:${ASHL_VFS_OVERLAY}>)
569+
else()
570+
target_compile_options(${name} PRIVATE
571+
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:"SHELL:-Xclang -ivfsoverlay -Xclang ${ASHL_VFS_OVERLAY}">)
572+
573+
# MSVC doesn't support -Xclang. We don't need to manually specify
574+
# the dependent libraries as `cl`/`clang-cl` does so.
575+
target_compile_options(${name} PRIVATE
576+
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:"SHELL:-Xclang --dependent-lib=oldnames">
577+
# TODO(compnerd) handle /MT, /MTd
578+
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:"SHELL:-Xclang --dependent-lib=msvcrt$<$<CONFIG:Debug>:d>">
579+
)
580+
endif()
573581
endif()
574582
575583
set_target_properties(${name} PROPERTIES
@@ -980,9 +988,12 @@ function(add_swift_host_tool executable)
980988
target_include_directories(${executable} SYSTEM PRIVATE
981989
${${SWIFT_HOST_VARIANT_ARCH}_INCLUDE})
982990
983-
if(NOT ${CMAKE_C_COMPILER_ID} STREQUAL MSVC)
991+
# On Windows both clang-cl and clang simulate MSVC.
992+
# We are using CMAKE_C_COMPILER_FRONTEND_VARIANT to distinguish
993+
# clang from clang-cl.
994+
if(NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" AND NOT "${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC")
984995
# MSVC doesn't support -Xclang. We don't need to manually specify
985-
# the dependent libraries as `cl` does so.
996+
# the dependent libraries as `cl`/`clang-cl` does so.
986997
target_compile_options(${executable} PRIVATE
987998
$<$<COMPILE_LANGUAGE:C,CXX,OBJC,OBJCXX>:"SHELL:-Xclang --dependent-lib=oldnames">
988999
# TODO(compnerd) handle /MT, /MTd

cmake/modules/SwiftWindowsSupport.cmake

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,17 @@ macro(swift_swap_compiler_if_needed target)
9292
if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC")
9393
set(CMAKE_C_COMPILER ${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
9494
set(CMAKE_CXX_COMPILER ${CLANG_LOCATION}/clang-cl${CMAKE_EXECUTABLE_SUFFIX})
95+
set(CMAKE_C_COMPILER_ID Clang)
96+
set(CMAKE_C_SIMULATE_ID MSVC)
97+
set(CMAKE_C_COMPILER_FRONTEND_VARIANT MSVC)
98+
set(CMAKE_CXX_COMPILER_ID Clang)
99+
set(CMAKE_CXX_SIMULATE_ID MSVC)
100+
set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT MSVC)
95101
else()
96102
set(CMAKE_C_COMPILER ${CLANG_LOCATION}/clang${CMAKE_EXECUTABLE_SUFFIX})
97103
set(CMAKE_CXX_COMPILER ${CLANG_LOCATION}/clang++${CMAKE_EXECUTABLE_SUFFIX})
104+
set(CMAKE_C_COMPILER_ID Clang)
105+
set(CMAKE_CXX_COMPILER_ID Clang)
98106
endif()
99107
else()
100108
message(SEND_ERROR "${target} requires a clang based compiler")

include/swift/ABI/TaskGroup.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class alignas(Alignment_TaskGroup) TaskGroup {
4242

4343
/// Checks the cancellation status of the group.
4444
bool isCancelled();
45+
46+
// Add a child task to the group. Always called with the status record lock of
47+
// the parent task held
48+
void addChildTask(AsyncTask *task);
4549
};
4650

4751
} // end namespace swift

include/swift/AST/Decl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3309,6 +3309,9 @@ class NominalTypeDecl : public GenericTypeDecl, public IterableDeclContext {
33093309
/// If the passed in function is not distributed this function returns null.
33103310
AbstractFunctionDecl* lookupDirectRemoteFunc(AbstractFunctionDecl *func);
33113311

3312+
/// Find, or potentially synthesize, the implicit 'id' property of this actor.
3313+
ValueDecl *getDistributedActorIDProperty() const;
3314+
33123315
/// Collect the set of protocols to which this type should implicitly
33133316
/// conform, such as AnyObject (for classes).
33143317
void getImplicitProtocols(SmallVectorImpl<ProtocolDecl *> &protocols);

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4681,13 +4681,13 @@ ERROR(distributed_actor_func_static,none,
46814681
ERROR(distributed_actor_func_not_in_distributed_actor,none,
46824682
"'distributed' method can only be declared within 'distributed actor'",
46834683
())
4684-
ERROR(distributed_actor_designated_ctor_must_have_one_transport_param,none,
4684+
ERROR(distributed_actor_designated_ctor_must_have_one_distributedactorsystem_param,none,
46854685
"designated distributed actor initializer %0 must accept exactly one "
4686-
"ActorTransport parameter, found %1",
4686+
"DistributedActorSystem parameter, found %1",
46874687
(DeclName, int))
46884688
ERROR(distributed_actor_designated_ctor_missing_transport_param,none,
46894689
"designated distributed actor initializer %0 is missing required "
4690-
"ActorTransport parameter",
4690+
"DistributedActorSystem parameter",
46914691
(DeclName))
46924692
ERROR(distributed_actor_user_defined_special_property,none,
46934693
"property %0 cannot be defined explicitly, as it conflicts with "

include/swift/AST/Expr.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ class DeclRefExpr : public Expr {
12391239

12401240
/// Set whether this reference must account for a `throw` occurring for reasons
12411241
/// other than the function implementation itself throwing, e.g. an
1242-
/// `ActorTransport` implementing a `distributed func` call throwing a
1242+
/// `DistributedActorSystem` implementing a `distributed func` call throwing a
12431243
/// networking error.
12441244
void setImplicitlyThrows(bool isImplicitlyThrows) {
12451245
Bits.DeclRefExpr.IsImplicitlyThrows = isImplicitlyThrows;
@@ -1619,7 +1619,7 @@ class LookupExpr : public Expr {
16191619

16201620
/// Set whether this reference must account for a `throw` occurring for reasons
16211621
/// other than the function implementation itself throwing, e.g. an
1622-
/// `ActorTransport` implementing a `distributed func` call throwing a
1622+
/// `DistributedActorSystem` implementing a `distributed func` call throwing a
16231623
/// networking error.
16241624
void setImplicitlyThrows(bool isImplicitlyThrows) {
16251625
Bits.LookupExpr.IsImplicitlyThrows = isImplicitlyThrows;
@@ -3615,6 +3615,9 @@ class AbstractClosureExpr : public DeclContext, public Expr {
36153615
/// \brief Return whether this closure is async when fully applied.
36163616
bool isBodyAsync() const;
36173617

3618+
/// Whether this closure is Sendable.
3619+
bool isSendable() const;
3620+
36183621
/// Whether this closure consists of a single expression.
36193622
bool hasSingleExpressionBody() const;
36203623

include/swift/AST/KnownIdentifiers.def

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ IDENTIFIER(decode)
6565
IDENTIFIER(decodeIfPresent)
6666
IDENTIFIER(Decoder)
6767
IDENTIFIER(decoder)
68-
IDENTIFIER(DefaultActorTransport)
68+
IDENTIFIER(DefaultDistributedActorSystem)
6969
IDENTIFIER_(Differentiation)
7070
IDENTIFIER_WITH_NAME(PatternMatchVar, "$match")
7171
IDENTIFIER(dynamicallyCall)
@@ -142,7 +142,6 @@ IDENTIFIER_WITH_NAME(SwiftObject, "_TtCs12_SwiftObject")
142142
IDENTIFIER(SwiftNativeNSObject)
143143
IDENTIFIER(to)
144144
IDENTIFIER(toRaw)
145-
IDENTIFIER(Transport)
146145
IDENTIFIER(Type)
147146
IDENTIFIER(type)
148147
IDENTIFIER(typeMismatch)
@@ -256,18 +255,20 @@ IDENTIFIER_(regexString)
256255
IDENTIFIER_(StringProcessing)
257256

258257
// Distributed actors
259-
IDENTIFIER(transport)
260-
IDENTIFIER(using)
261258
IDENTIFIER(actor)
262-
IDENTIFIER(actorTransport)
263-
IDENTIFIER(actorType)
264259
IDENTIFIER(actorReady)
265-
IDENTIFIER(assignIdentity)
266-
IDENTIFIER(resignIdentity)
260+
IDENTIFIER(ActorSystem)
261+
IDENTIFIER(actorSystem)
262+
IDENTIFIER(ActorID)
263+
IDENTIFIER(actorType)
264+
IDENTIFIER(using)
265+
IDENTIFIER(assignID)
266+
IDENTIFIER(resignID)
267267
IDENTIFIER(resolve)
268+
IDENTIFIER(system)
269+
IDENTIFIER(ID)
268270
IDENTIFIER(id)
269-
IDENTIFIER(identity)
270-
IDENTIFIER(identifier)
271+
IDENTIFIER(Invocation)
271272
IDENTIFIER(_distributedActorRemoteInitialize)
272273
IDENTIFIER(_distributedActorDestroy)
273274
IDENTIFIER(__isRemoteActor)

include/swift/AST/KnownProtocols.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ PROTOCOL(Differentiable)
9898
// Distributed Actors
9999
PROTOCOL(DistributedActor)
100100
PROTOCOL(ActorIdentity)
101-
PROTOCOL(ActorTransport)
101+
PROTOCOL(DistributedActorSystem)
102102

103103
PROTOCOL(AsyncSequence)
104104
PROTOCOL(AsyncIteratorProtocol)

include/swift/AST/KnownSDKDecls.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# define KNOWN_SDK_FUNC_DECL(Module, Name, Id)
2020
#endif
2121

22-
KNOWN_SDK_FUNC_DECL(Distributed, MissingDistributedActorTransport, "_missingDistributedActorTransport")
22+
KNOWN_SDK_FUNC_DECL(Distributed, MissingDistributedActorSystem, "_missingDistributedActorSystem")
2323
KNOWN_SDK_FUNC_DECL(Distributed, IsRemoteDistributedActor, "__isRemoteActor")
2424

2525
#undef KNOWN_SDK_FUNC_DECL

include/swift/AST/PrintOptions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ class AnyAttrKind {
9595
static_assert(DAK_Count < UINT_MAX, "DeclAttrKind is > 31 bits");
9696
}
9797
AnyAttrKind() : kind(TAK_Count), isType(1) {}
98-
AnyAttrKind(const AnyAttrKind &) = default;
9998

10099
/// Returns the TypeAttrKind, or TAK_Count if this is not a type attribute.
101100
TypeAttrKind type() const {

include/swift/AST/SILOptions.h

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,31 @@
3131
namespace swift {
3232

3333
enum class LexicalLifetimesOption : uint8_t {
34-
// Do not insert any lexical lifetimes.
34+
// Do not insert lexical markers.
3535
Off = 0,
3636

37-
// Insert lexical lifetimes in SILGen, but remove them before leaving Raw SIL.
38-
Early,
37+
// Insert lexical markers via lexical borrow scopes and the lexical flag on
38+
// alloc_stacks produced from alloc_boxes, but strip them when lowering out of
39+
// Raw SIL.
40+
DiagnosticMarkersOnly,
3941

40-
// Insert lexical lifetimes and do not remove them until OSSA is lowered. This
41-
// is experimental.
42-
ExperimentalLate,
42+
// Insert lexical markers and use them to lengthen object lifetime based on
43+
// lexical scope.
44+
On,
45+
};
46+
47+
enum class CopyPropagationOption : uint8_t {
48+
// Do not add any copy propagation passes.
49+
Off = 0,
50+
51+
// Only add the copy propagation passes requested by other flags, currently
52+
// just -enable-ossa-modules.
53+
RequestedPassesOnly,
54+
55+
// Add all relevant copy propagation passes. If a setting, e.g.
56+
// -enable-ossa-modules, requests to add copy propagation to the pipeline, do
57+
// so.
58+
On
4359
};
4460

4561
class SILModule;
@@ -59,17 +75,15 @@ class SILOptions {
5975
bool RemoveRuntimeAsserts = false;
6076

6177
/// Enable experimental support for emitting defined borrow scopes.
62-
LexicalLifetimesOption LexicalLifetimes = LexicalLifetimesOption::Early;
63-
64-
/// Force-run SIL copy propagation to shorten object lifetime in whatever
65-
/// optimization pipeline is currently used.
66-
/// When this is 'false' the pipeline has default behavior.
67-
bool EnableCopyPropagation = false;
78+
LexicalLifetimesOption LexicalLifetimes =
79+
LexicalLifetimesOption::DiagnosticMarkersOnly;
6880

69-
/// Disable SIL copy propagation to preserve object lifetime in whatever
81+
/// Whether to run SIL copy propagation to shorten object lifetime in whatever
7082
/// optimization pipeline is currently used.
71-
/// When this is 'false' the pipeline has default behavior.
72-
bool DisableCopyPropagation = false;
83+
///
84+
/// When this is 'RequestedPassesOnly' the pipeline has default behavior.
85+
CopyPropagationOption CopyPropagation =
86+
CopyPropagationOption::RequestedPassesOnly;
7387

7488
/// Controls whether the SIL ARC optimizations are run.
7589
bool EnableARCOptimizations = true;

include/swift/AST/TypeCheckRequests.h

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,24 @@ class GetDistributedRemoteFuncRequest :
10351035
bool isCached() const { return true; }
10361036
};
10371037

1038+
/// Obtain the 'id' property of a 'distributed actor'.
1039+
class GetDistributedActorIDPropertyRequest :
1040+
public SimpleRequest<GetDistributedActorIDPropertyRequest,
1041+
ValueDecl *(NominalTypeDecl *),
1042+
RequestFlags::Cached> {
1043+
public:
1044+
using SimpleRequest::SimpleRequest;
1045+
1046+
private:
1047+
friend SimpleRequest;
1048+
1049+
ValueDecl *evaluate(Evaluator &evaluator, NominalTypeDecl *actor) const;
1050+
1051+
public:
1052+
// Caching
1053+
bool isCached() const { return true; }
1054+
};
1055+
10381056
/// Retrieve the static "shared" property within a global actor that provides
10391057
/// the actor instance representing the global actor.
10401058
///
@@ -2215,8 +2233,8 @@ enum class ImplicitMemberAction : uint8_t {
22152233
ResolveEncodable,
22162234
ResolveDecodable,
22172235
ResolveDistributedActor,
2218-
ResolveDistributedActorIdentity,
2219-
ResolveDistributedActorTransport,
2236+
ResolveDistributedActorID,
2237+
ResolveDistributedActorSystem,
22202238
};
22212239

22222240
class ResolveImplicitMemberRequest
@@ -3173,6 +3191,23 @@ class RenamedDeclRequest
31733191
bool isCached() const { return true; }
31743192
};
31753193

3194+
class ClosureEffectsRequest
3195+
: public SimpleRequest<ClosureEffectsRequest,
3196+
FunctionType::ExtInfo(ClosureExpr *),
3197+
RequestFlags::Cached> {
3198+
public:
3199+
using SimpleRequest::SimpleRequest;
3200+
3201+
private:
3202+
friend SimpleRequest;
3203+
3204+
FunctionType::ExtInfo evaluate(
3205+
Evaluator &evaluator, ClosureExpr *closure) const;
3206+
3207+
public:
3208+
bool isCached() const { return true; }
3209+
};
3210+
31763211
void simple_display(llvm::raw_ostream &out, Type value);
31773212
void simple_display(llvm::raw_ostream &out, const TypeRepr *TyR);
31783213
void simple_display(llvm::raw_ostream &out, ImplicitMemberAction action);

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ SWIFT_REQUEST(TypeChecker, IsDistributedActorRequest, bool(NominalTypeDecl *),
107107
Cached, NoLocationInfo)
108108
SWIFT_REQUEST(TypeChecker, GetDistributedRemoteFuncRequest, AbstractFunctionDecl *(AbstractFunctionDecl *),
109109
Cached, NoLocationInfo)
110+
SWIFT_REQUEST(TypeChecker, GetDistributedActorIDPropertyRequest, ValueDecl *(NominalTypeDecl *),
111+
Cached, NoLocationInfo)
110112
SWIFT_REQUEST(TypeChecker, GlobalActorInstanceRequest,
111113
VarDecl *(NominalTypeDecl *),
112114
Cached, NoLocationInfo)
@@ -361,3 +363,6 @@ SWIFT_REQUEST(TypeChecker, GetImplicitSendableRequest,
361363
SWIFT_REQUEST(TypeChecker, RenamedDeclRequest,
362364
ValueDecl *(const ValueDecl *),
363365
Cached, NoLocationInfo)
366+
SWIFT_REQUEST(TypeChecker, ClosureEffectsRequest,
367+
FunctionType::ExtInfo(ClosureExpr *),
368+
Cached, NoLocationInfo)

include/swift/Basic/SupplementaryOutputPaths.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ struct SupplementaryOutputPaths {
156156
std::string BitstreamOptRecordPath;
157157

158158
SupplementaryOutputPaths() = default;
159-
SupplementaryOutputPaths(const SupplementaryOutputPaths &) = default;
160159

161160
/// Apply a given function for each existing (non-empty string) supplementary output
162161
void forEachSetOutput(llvm::function_ref<void(const std::string&)> fn) const {

include/swift/Frontend/Frontend.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@ class CompilerInvocation {
351351
if (FrontendOpts.InputMode == FrontendOptions::ParseInputMode::SIL) {
352352
return ImplicitStdlibKind::None;
353353
}
354+
if (FrontendOpts.InputsAndOutputs.shouldTreatAsLLVM()) {
355+
return ImplicitStdlibKind::None;
356+
}
354357
if (getParseStdlib()) {
355358
return ImplicitStdlibKind::Builtin;
356359
}
@@ -572,7 +575,7 @@ class CompilerInstance {
572575
}
573576

574577
/// Returns true if there was an error during setup.
575-
bool setup(const CompilerInvocation &Invocation);
578+
bool setup(const CompilerInvocation &Invocation, std::string &Error);
576579

577580
const CompilerInvocation &getInvocation() const { return Invocation; }
578581

include/swift/Frontend/ModuleInterfaceLoader.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ struct ModuleInterfaceLoaderOptions {
313313
case FrontendOptions::ActionType::TypecheckModuleFromInterface:
314314
requestedAction = FrontendOptions::ActionType::Typecheck;
315315
break;
316+
case FrontendOptions::ActionType::ScanDependencies:
317+
requestedAction = Opts.RequestedAction;
318+
break;
316319
default:
317320
requestedAction = FrontendOptions::ActionType::EmitModuleOnly;
318321
break;

include/swift/IDE/Utils.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "swift/AST/Effects.h"
2121
#include "swift/AST/Module.h"
2222
#include "swift/AST/ASTPrinter.h"
23+
#include "swift/Frontend/FrontendOptions.h"
2324
#include "swift/IDE/SourceEntityWalker.h"
2425
#include "swift/Parse/Token.h"
2526
#include "llvm/ADT/StringRef.h"
@@ -85,7 +86,8 @@ SourceCompleteResult isSourceInputComplete(StringRef Text, SourceFileKind SFKind
8586

8687
bool initCompilerInvocation(
8788
CompilerInvocation &Invocation, ArrayRef<const char *> OrigArgs,
88-
DiagnosticEngine &Diags, StringRef UnresolvedPrimaryFile,
89+
FrontendOptions::ActionType Action, DiagnosticEngine &Diags,
90+
StringRef UnresolvedPrimaryFile,
8991
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FileSystem,
9092
const std::string &runtimeResourcePath,
9193
const std::string &diagnosticDocumentationPath, time_t sessionTimestamp,

0 commit comments

Comments
 (0)