Skip to content

Commit d7758f8

Browse files
authored
Merge pull request #3531 from swiftwasm/main
2 parents 46de0a0 + be98f6b commit d7758f8

File tree

68 files changed

+1421
-241
lines changed

Some content is hidden

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

68 files changed

+1421
-241
lines changed

benchmark/single-source/SetTests.swift

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ let setAB = Set(0 ..< size) // 0 ..< 400
2525
let setCD = Set(size ..< 2 * size) // 400 ..< 800
2626
let setBC = Set(size - quarter ..< 2 * size - quarter) // 300 ..< 700
2727
let setB = Set(size - quarter ..< size) // 300 ..< 400
28+
let setCDS = Set(size ..< (size + (size/4))) // 400 ..< 500
2829

2930
let setOAB = Set(setAB.map(Box.init))
3031
let setOCD = Set(setCD.map(Box.init))
3132
let setOBC = Set(setBC.map(Box.init))
3233
let setOB = Set(setB.map(Box.init))
34+
let setOCDS = Set(setCDS.map(Box.init))
3335

3436
let countA = size - quarter // 300
3537
let countB = quarter // 100
@@ -368,6 +370,16 @@ public let SetTests = [
368370
runFunction: { n in run_SetIsDisjointBox(setOAB, setOCD, true, 50 * n) },
369371
tags: [.validation, .api, .Set],
370372
setUpFunction: { blackHole([setOAB, setOCD]) }),
373+
BenchmarkInfo(
374+
name: "Set.isDisjoint.Smaller.Int0",
375+
runFunction: { n in run_SetIsDisjointIntCommutative(setAB, setCDS, true, 50 * n) },
376+
tags: [.validation, .api, .Set],
377+
setUpFunction: { blackHole([setAB, setCDS]) }),
378+
BenchmarkInfo(
379+
name: "Set.isDisjoint.Smaller.Box0",
380+
runFunction: { n in run_SetIsDisjointBoxCommutative(setOAB, setOCDS, true, 50 * n) },
381+
tags: [.validation, .api, .Set],
382+
setUpFunction: { blackHole([setOAB, setOCDS]) }),
371383
BenchmarkInfo(
372384
name: "Set.isDisjoint.Int25",
373385
runFunction: { n in run_SetIsDisjointInt(setB, setAB, false, 5000 * n) },
@@ -891,6 +903,22 @@ public func run_SetIsDisjointInt(
891903
}
892904
}
893905

906+
// Run isDisjoint Int switching the order of the two sets.
907+
@inline(never)
908+
public func run_SetIsDisjointIntCommutative(
909+
_ a: Set<Int>,
910+
_ b: Set<Int>,
911+
_ r: Bool,
912+
_ n: Int) {
913+
for _ in 0 ..< n {
914+
let isDisjointA = a.isDisjoint(with: identity(b))
915+
CheckResults(isDisjointA == r)
916+
917+
let isDisjointB = b.isDisjoint(with: identity(a))
918+
CheckResults(isDisjointB == r)
919+
}
920+
}
921+
894922
@inline(never)
895923
public func run_SetIsDisjointSeqInt(
896924
_ a: Set<Int>,
@@ -1091,6 +1119,22 @@ func run_SetIsDisjointBox(
10911119
}
10921120
}
10931121

1122+
// Run isDisjoint Box switching the order of the two sets.
1123+
@inline(never)
1124+
func run_SetIsDisjointBoxCommutative(
1125+
_ a: Set<Box<Int>>,
1126+
_ b: Set<Box<Int>>,
1127+
_ r: Bool,
1128+
_ n: Int) {
1129+
for _ in 0 ..< n {
1130+
let isDisjointA = a.isDisjoint(with: identity(b))
1131+
CheckResults(isDisjointA == r)
1132+
1133+
let isDisjointB = b.isDisjoint(with: identity(a))
1134+
CheckResults(isDisjointB == r)
1135+
}
1136+
}
1137+
10941138
@inline(never)
10951139
func run_SetIsDisjointSeqBox(
10961140
_ a: Set<Box<Int>>,

docs/HowToGuides/GettingStarted.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ toolchain as a one-off, there are a couple of differences:
1616
- [Troubleshooting cloning issues](#troubleshooting-cloning-issues)
1717
- [Installing dependencies](#installing-dependencies)
1818
- [macOS](#macOS)
19-
- [Ubuntu Linux](#ubuntu-linux)
19+
- [Linux](#linux)
2020
- [Building the project for the first time](#building-the-project-for-the-first-time)
2121
- [Spot check dependencies](#spot-check-dependencies)
2222
- [The roles of different tools](#the-roles-of-different-tools)

docs/SIL.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3079,7 +3079,7 @@ alloc_stack
30793079
```````````
30803080
::
30813081

3082-
sil-instruction ::= 'alloc_stack' '[dynamic_lifetime]'? sil-type (',' debug-var-attr)*
3082+
sil-instruction ::= 'alloc_stack' '[dynamic_lifetime]'? '[lexical]'? sil-type (',' debug-var-attr)*
30833083

30843084
%1 = alloc_stack $T
30853085
// %1 has type $*T
@@ -3102,6 +3102,9 @@ The ``dynamic_lifetime`` attribute specifies that the initialization and
31023102
destruction of the stored value cannot be verified at compile time.
31033103
This is the case, e.g. for conditionally initialized objects.
31043104

3105+
The optional ``lexical`` attribute specifies that the operand corresponds to a
3106+
local variable in the Swift source.
3107+
31053108
The memory is not retainable. To allocate a retainable box for a value
31063109
type, use ``alloc_box``.
31073110

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,9 @@ ERROR(serialization_name_mismatch_repl,none,
782782
ERROR(serialization_target_incompatible,Fatal,
783783
"module %0 was created for incompatible target %1: %2",
784784
(Identifier, StringRef, StringRef))
785+
ERROR(serialization_sdk_mismatch,Fatal,
786+
"cannot load module %0 built with SDK '%1' when using SDK '%2': %3",
787+
(Identifier, StringRef, StringRef, StringRef))
785788
ERROR(serialization_target_incompatible_repl,none,
786789
"module %0 was created for incompatible target %1: %2",
787790
(Identifier, StringRef, StringRef))

include/swift/AST/IRGenOptions.h

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

346346
unsigned EnableGlobalISel : 1;
347347

348+
unsigned VirtualFunctionElimination : 1;
349+
348350
/// The number of threads for multi-threaded code generation.
349351
unsigned NumThreads = 0;
350352

@@ -401,7 +403,8 @@ class IRGenOptions {
401403
GenerateProfile(false), EnableDynamicReplacementChaining(false),
402404
DisableRoundTripDebugTypes(false), DisableDebuggerShadowCopies(false),
403405
DisableConcreteTypeMetadataMangledNameAccessors(false),
404-
EnableGlobalISel(false), CmdArgs(),
406+
EnableGlobalISel(false), VirtualFunctionElimination(false),
407+
CmdArgs(),
405408
SanitizeCoverage(llvm::SanitizerCoverageOptions()),
406409
TypeInfoFilter(TypeInfoDumpFilter::All) {}
407410

include/swift/AST/SearchPathOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ class SearchPathOptions {
8282
/// would for a non-system header.
8383
bool DisableModulesValidateSystemDependencies = false;
8484

85+
/// Enforce loading only serialized modules built with the same SDK
86+
/// as the context loading it.
87+
bool EnableSameSDKCheck = true;
88+
8589
/// A set of compiled modules that may be ready to use.
8690
std::vector<std::string> CandidateCompiledModules;
8791

include/swift/Basic/LangOptions.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ namespace swift {
127127
/// The target variant SDK version, if known.
128128
Optional<llvm::VersionTuple> VariantSDKVersion;
129129

130+
/// The SDK canonical name, if known.
131+
std::string SDKName;
132+
130133
/// The alternate name to use for the entry point instead of main.
131134
std::string entryPointFunctionName = "main";
132135

@@ -301,6 +304,9 @@ namespace swift {
301304
/// Enable experimental concurrency model.
302305
bool EnableExperimentalConcurrency = false;
303306

307+
/// Enable experimental support for emitting defined borrow scopes.
308+
bool EnableExperimentalDefinedLifetimes = false;
309+
304310
/// Enable experimental support for named opaque result types, e.g.
305311
/// `func f() -> <T> T`.
306312
bool EnableExperimentalNamedOpaqueTypes = false;

include/swift/Option/FrontendOptions.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ def enable_experimental_concurrency :
247247
Flag<["-"], "enable-experimental-concurrency">,
248248
HelpText<"Enable experimental concurrency model">;
249249

250+
def enable_experimental_defined_lifetimes :
251+
Flag<["-"], "enable-experimental-defined-lifetimes">,
252+
HelpText<"Enable experimental defined lifetimes">;
253+
250254
def enable_experimental_distributed :
251255
Flag<["-"], "enable-experimental-distributed">,
252256
HelpText<"Enable experimental 'distributed' actors and functions">;
@@ -489,6 +493,10 @@ def enable_implicit_dynamic : Flag<["-"], "enable-implicit-dynamic">,
489493
Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>,
490494
HelpText<"Add 'dynamic' to all declarations">;
491495

496+
def enable_llvm_vfe : Flag<["-"], "enable-llvm-vfe">,
497+
Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>,
498+
HelpText<"Use LLVM Virtual Function Elimination on Swift class virtual tables">;
499+
492500
def disable_previous_implementation_calls_in_dynamic_replacements :
493501
Flag<["-"], "disable-previous-implementation-calls-in-dynamic-replacements">,
494502
Flags<[FrontendOption, NoInteractiveOption, HelpHidden]>,
@@ -823,6 +831,9 @@ def target_sdk_version : Separate<["-"], "target-sdk-version">,
823831
def target_variant_sdk_version : Separate<["-"], "target-variant-sdk-version">,
824832
HelpText<"The version of target variant SDK used for compilation">;
825833

834+
def target_sdk_name : Separate<["-"], "target-sdk-name">,
835+
HelpText<"Canonical name of the target SDK used for compilation">;
836+
826837
def extra_clang_options_only : Flag<["-"], "only-use-extra-clang-opts">,
827838
HelpText<"Options passed via -Xcc are sufficient for Clang configuration">;
828839

include/swift/Runtime/RuntimeFunctions.def

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,24 @@ FUNCTION(GetFunctionMetadataGlobalActor,
634634
TypeMetadataPtrTy),
635635
ATTRS(NoUnwind, ReadOnly))
636636

637+
// Metadata *
638+
// swift_getFunctionTypeMetadataGlobalActorBackDeploy(unsigned long flags,
639+
// unsigned long diffKind,
640+
// const Metadata **parameters,
641+
// const uint32_t *parameterFlags,
642+
// const Metadata *result,
643+
// const Metadata *globalActor);
644+
FUNCTION(GetFunctionMetadataGlobalActorBackDeploy,
645+
swift_getFunctionTypeMetadataGlobalActorBackDeploy,
646+
C_CC, OpaqueTypeAvailability,
647+
RETURNS(TypeMetadataPtrTy),
648+
ARGS(SizeTy,
649+
SizeTy,
650+
TypeMetadataPtrTy->getPointerTo(0),
651+
Int32Ty->getPointerTo(0),
652+
TypeMetadataPtrTy,
653+
TypeMetadataPtrTy),
654+
ATTRS(NoUnwind, ReadOnly))
637655

638656
// Metadata *swift_getFunctionTypeMetadata0(unsigned long flags,
639657
// const Metadata *resultMetadata);

include/swift/SIL/SILBuilder.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,14 @@ class SILBuilder {
365365

366366
AllocStackInst *createAllocStack(SILLocation Loc, SILType elementType,
367367
Optional<SILDebugVariable> Var = None,
368-
bool hasDynamicLifetime = false) {
368+
bool hasDynamicLifetime = false,
369+
bool isLexical = false) {
369370
Loc.markAsPrologue();
370371
assert((!dyn_cast_or_null<VarDecl>(Loc.getAsASTNode<Decl>()) || Var) &&
371372
"location is a VarDecl, but SILDebugVariable is empty");
372373
return insert(AllocStackInst::create(getSILDebugLocation(Loc), elementType,
373-
getFunction(),
374-
Var, hasDynamicLifetime));
374+
getFunction(), Var, hasDynamicLifetime,
375+
isLexical));
375376
}
376377

377378
AllocRefInst *createAllocRef(SILLocation Loc, SILType ObjectType,

0 commit comments

Comments
 (0)