Skip to content

[rebranch] Merge branch 'main' into rebranch #39322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
c3c1e6d
[Benchmarks][stdlib] Adding an extra benchmark for set isDisjoint for…
LucianoPAlmeida Sep 13, 2021
d002471
Added -enable-experimental-defined-lifetimes.
nate-chandler Sep 11, 2021
a0c47cb
[SILGen] Emitted [defined] borrow scopes for lets.
nate-chandler Sep 13, 2021
9ea48da
Shouldn't this be labeled as a C++ file?
CashMan3000 Sep 13, 2021
ddf210b
Disabling arm64e testing in two tests
etcwilde Sep 13, 2021
3053e6d
Fix TOC entry for Linux in GettingStarted
neonichu Sep 13, 2021
c38d177
[Serialization] Restrict loading swiftmodule files to the builder's SDK
xymus Jun 1, 2021
bccea96
[Test] Use -parse-stdlib to avoid loading an incompatible stdlib
xymus Jun 3, 2021
51cec86
[APIDigester] Don't check whether the stdlib was built for a differen…
xymus Jun 3, 2021
b57b222
[SIL] Added lexical flag to alloc_stack.
nate-chandler Sep 14, 2021
4fb2d07
Refactor IsBindableVisitor's handling of generic nominals.
jckarter Aug 17, 2021
85c7228
Have IsBindableVisitor consider conditional conformances.
jckarter Aug 19, 2021
2feb76d
Run type_lowering_subst_function_type_conditional_conformance.swift t…
slavapestov Sep 13, 2021
eeae6cf
SIL: Fix for when conditional requirements reference nested type para…
slavapestov Sep 14, 2021
e68b6a7
Merge pull request #39283 from nate-chandler/lexical_lifetimes/let/in…
nate-chandler Sep 14, 2021
c3e7626
Merge pull request #39291 from nate-chandler/lexical_lifetimes/alloc_…
nate-chandler Sep 14, 2021
2cd0d5e
Merge pull request #37768 from xymus/swiftmodule-sdk
xymus Sep 14, 2021
55c4e74
Merge pull request #39294 from slavapestov/hack-up-joes-type-lowering…
slavapestov Sep 14, 2021
ec37074
Merge pull request #39290 from apple/neonichu-patch-1
CodaFi Sep 14, 2021
7e0eaf7
Remove metadata section functions from the stdlib (#39236)
Azoy Sep 14, 2021
e1e3824
Merge pull request #39265 from LucianoPAlmeida/set-disjoint-benchmarks
lorentey Sep 14, 2021
2381233
Add flag -swift-async-framepointer=auto,never,always to
aschwaighofer Sep 14, 2021
a1a9dd1
Change the logic to exclude extended frame info on all platforms but …
aschwaighofer Sep 14, 2021
a93f777
Default to SwiftAsyncFramePointerKind::Always for now
aschwaighofer Sep 11, 2021
00cb1c5
[stdlib] Improve set isDisjoint by iterating on smaller set
LucianoPAlmeida Sep 11, 2021
2e916a6
Merge pull request #39285 from TotallyNotThomas/patch-1
swift-ci Sep 14, 2021
7e52fb5
SIL: Use correct SILFunctionConventions when computing method self ty…
slavapestov Sep 14, 2021
3680f9c
Merge pull request #39279 from etcwilde/ewilde/disable-failing-arm64e…
etcwilde Sep 14, 2021
be98f6b
Merge pull request #39310 from slavapestov/sil-verifier-method-self-t…
slavapestov Sep 15, 2021
50a1817
Merge pull request #39263 from LucianoPAlmeida/set-improvements
LucianoPAlmeida Sep 15, 2021
680fb6a
[Swift CI] Re-enable sanitizer symbolication tests (#38489)
yln Sep 15, 2021
cffc1b2
Merge pull request #39245 from aschwaighofer/swift_async_function_poi…
aschwaighofer Sep 15, 2021
8256846
Avoid using strcasecmp and unroll the comparison to 'snan' instead (#…
kubamracek Sep 15, 2021
a723e6d
CMake: disable libdispatch when targeting Wasm/WASI (#39274)
MaxDesiatov Sep 15, 2021
feece9d
Revert "[Swift CI] Re-enable sanitizer symbolication tests (#38489)" …
natecook1000 Sep 15, 2021
b429191
Merge branch 'main' into rebranch
nate-chandler Sep 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions benchmark/single-source/SetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ let setAB = Set(0 ..< size) // 0 ..< 400
let setCD = Set(size ..< 2 * size) // 400 ..< 800
let setBC = Set(size - quarter ..< 2 * size - quarter) // 300 ..< 700
let setB = Set(size - quarter ..< size) // 300 ..< 400
let setCDS = Set(size ..< (size + (size/4))) // 400 ..< 500

let setOAB = Set(setAB.map(Box.init))
let setOCD = Set(setCD.map(Box.init))
let setOBC = Set(setBC.map(Box.init))
let setOB = Set(setB.map(Box.init))
let setOCDS = Set(setCDS.map(Box.init))

let countA = size - quarter // 300
let countB = quarter // 100
Expand Down Expand Up @@ -368,6 +370,16 @@ public let SetTests = [
runFunction: { n in run_SetIsDisjointBox(setOAB, setOCD, true, 50 * n) },
tags: [.validation, .api, .Set],
setUpFunction: { blackHole([setOAB, setOCD]) }),
BenchmarkInfo(
name: "Set.isDisjoint.Smaller.Int0",
runFunction: { n in run_SetIsDisjointIntCommutative(setAB, setCDS, true, 50 * n) },
tags: [.validation, .api, .Set],
setUpFunction: { blackHole([setAB, setCDS]) }),
BenchmarkInfo(
name: "Set.isDisjoint.Smaller.Box0",
runFunction: { n in run_SetIsDisjointBoxCommutative(setOAB, setOCDS, true, 50 * n) },
tags: [.validation, .api, .Set],
setUpFunction: { blackHole([setOAB, setOCDS]) }),
BenchmarkInfo(
name: "Set.isDisjoint.Int25",
runFunction: { n in run_SetIsDisjointInt(setB, setAB, false, 5000 * n) },
Expand Down Expand Up @@ -891,6 +903,22 @@ public func run_SetIsDisjointInt(
}
}

// Run isDisjoint Int switching the order of the two sets.
@inline(never)
public func run_SetIsDisjointIntCommutative(
_ a: Set<Int>,
_ b: Set<Int>,
_ r: Bool,
_ n: Int) {
for _ in 0 ..< n {
let isDisjointA = a.isDisjoint(with: identity(b))
CheckResults(isDisjointA == r)

let isDisjointB = b.isDisjoint(with: identity(a))
CheckResults(isDisjointB == r)
}
}

@inline(never)
public func run_SetIsDisjointSeqInt(
_ a: Set<Int>,
Expand Down Expand Up @@ -1091,6 +1119,22 @@ func run_SetIsDisjointBox(
}
}

// Run isDisjoint Box switching the order of the two sets.
@inline(never)
func run_SetIsDisjointBoxCommutative(
_ a: Set<Box<Int>>,
_ b: Set<Box<Int>>,
_ r: Bool,
_ n: Int) {
for _ in 0 ..< n {
let isDisjointA = a.isDisjoint(with: identity(b))
CheckResults(isDisjointA == r)

let isDisjointB = b.isDisjoint(with: identity(a))
CheckResults(isDisjointB == r)
}
}

@inline(never)
func run_SetIsDisjointSeqBox(
_ a: Set<Box<Int>>,
Expand Down
3 changes: 2 additions & 1 deletion cmake/modules/Libdispatch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ endif()
# Build any target libdispatch if needed.
foreach(sdk ${SWIFT_SDKS})
# Darwin targets have libdispatch available, do not build it.
if(NOT "${sdk}" IN_LIST SWIFT_DARWIN_PLATFORMS)
# Wasm/WASI doesn't support libdispatch yet. See https://bugs.swift.org/browse/SR-12097 for more details.
if(NOT "${sdk}" IN_LIST SWIFT_DARWIN_PLATFORMS AND NOT "${sdk}" STREQUAL WASI)
list(APPEND DISPATCH_SDKS "${sdk}")
endif()
endforeach()
Expand Down
2 changes: 1 addition & 1 deletion docs/HowToGuides/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ toolchain as a one-off, there are a couple of differences:
- [Troubleshooting cloning issues](#troubleshooting-cloning-issues)
- [Installing dependencies](#installing-dependencies)
- [macOS](#macOS)
- [Ubuntu Linux](#ubuntu-linux)
- [Linux](#linux)
- [Building the project for the first time](#building-the-project-for-the-first-time)
- [Spot check dependencies](#spot-check-dependencies)
- [The roles of different tools](#the-roles-of-different-tools)
Expand Down
5 changes: 4 additions & 1 deletion docs/SIL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3079,7 +3079,7 @@ alloc_stack
```````````
::

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

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

The optional ``lexical`` attribute specifies that the operand corresponds to a
local variable in the Swift source.

The memory is not retainable. To allocate a retainable box for a value
type, use ``alloc_box``.

Expand Down
3 changes: 3 additions & 0 deletions include/swift/AST/DiagnosticsSema.def
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,9 @@ ERROR(serialization_name_mismatch_repl,none,
ERROR(serialization_target_incompatible,Fatal,
"module %0 was created for incompatible target %1: %2",
(Identifier, StringRef, StringRef))
ERROR(serialization_sdk_mismatch,Fatal,
"cannot load module %0 built with SDK '%1' when using SDK '%2': %3",
(Identifier, StringRef, StringRef, StringRef))
ERROR(serialization_target_incompatible_repl,none,
"module %0 was created for incompatible target %1: %2",
(Identifier, StringRef, StringRef))
Expand Down
12 changes: 11 additions & 1 deletion include/swift/AST/IRGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ enum class IRGenEmbedMode : unsigned {
EmbedBitcode
};

enum class SwiftAsyncFramePointerKind : unsigned {
Auto, // Choose Swift async extended frame info based on deployment target.
Always, // Unconditionally emit Swift async extended frame info.
Never, // Don't emit Swift async extended frame info.
};

using clang::PointerAuthSchema;

struct PointerAuthOptions : clang::PointerAuthOptions {
Expand Down Expand Up @@ -282,6 +288,8 @@ class IRGenOptions {

IRGenLLVMLTOKind LLVMLTOKind : 2;

SwiftAsyncFramePointerKind SwiftAsyncFramePointer : 2;

/// Add names to LLVM values.
unsigned HasValueNamesSetting : 1;
unsigned ValueNames : 1;
Expand Down Expand Up @@ -393,7 +401,9 @@ class IRGenOptions {
Playground(false),
EmitStackPromotionChecks(false), FunctionSections(false),
PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None),
LLVMLTOKind(IRGenLLVMLTOKind::None), HasValueNamesSetting(false),
LLVMLTOKind(IRGenLLVMLTOKind::None),
SwiftAsyncFramePointer(SwiftAsyncFramePointerKind::Always),
HasValueNamesSetting(false),
ValueNames(false), EnableReflectionMetadata(true),
EnableReflectionNames(true), EnableAnonymousContextMangledNames(false),
ForcePublicLinkage(false), LazyInitializeClassMetadata(false),
Expand Down
4 changes: 4 additions & 0 deletions include/swift/AST/SearchPathOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ class SearchPathOptions {
/// would for a non-system header.
bool DisableModulesValidateSystemDependencies = false;

/// Enforce loading only serialized modules built with the same SDK
/// as the context loading it.
bool EnableSameSDKCheck = true;

/// A set of compiled modules that may be ready to use.
std::vector<std::string> CandidateCompiledModules;

Expand Down
6 changes: 6 additions & 0 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ namespace swift {
/// The target variant SDK version, if known.
Optional<llvm::VersionTuple> VariantSDKVersion;

/// The SDK canonical name, if known.
std::string SDKName;

/// The alternate name to use for the entry point instead of main.
std::string entryPointFunctionName = "main";

Expand Down Expand Up @@ -301,6 +304,9 @@ namespace swift {
/// Enable experimental concurrency model.
bool EnableExperimentalConcurrency = false;

/// Enable experimental support for emitting defined borrow scopes.
bool EnableExperimentalDefinedLifetimes = false;

/// Enable experimental support for named opaque result types, e.g.
/// `func f() -> <T> T`.
bool EnableExperimentalNamedOpaqueTypes = false;
Expand Down
11 changes: 11 additions & 0 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ def enable_experimental_concurrency :
Flag<["-"], "enable-experimental-concurrency">,
HelpText<"Enable experimental concurrency model">;

def enable_experimental_defined_lifetimes :
Flag<["-"], "enable-experimental-defined-lifetimes">,
HelpText<"Enable experimental defined lifetimes">;

def enable_experimental_distributed :
Flag<["-"], "enable-experimental-distributed">,
HelpText<"Enable experimental 'distributed' actors and functions">;
Expand Down Expand Up @@ -802,6 +806,10 @@ def type_info_dump_filter_EQ : Joined<["-"], "type-info-dump-filter=">,
Flags<[FrontendOption]>,
HelpText<"One of 'all', 'resilient' or 'fragile'">;

def swift_async_frame_pointer_EQ : Joined<["-"], "swift-async-frame-pointer=">,
Flags<[FrontendOption]>,
HelpText<"One of 'auto', 'always' or 'never'">;

def previous_module_installname_map_file
: Separate<["-"], "previous-module-installname-map-file">, MetaVarName<"<path>">,
HelpText<"Path to a Json file indicating module name to installname map for @_originallyDefinedIn">;
Expand All @@ -827,6 +835,9 @@ def target_sdk_version : Separate<["-"], "target-sdk-version">,
def target_variant_sdk_version : Separate<["-"], "target-variant-sdk-version">,
HelpText<"The version of target variant SDK used for compilation">;

def target_sdk_name : Separate<["-"], "target-sdk-name">,
HelpText<"Canonical name of the target SDK used for compilation">;

def extra_clang_options_only : Flag<["-"], "only-use-extra-clang-opts">,
HelpText<"Options passed via -Xcc are sufficient for Clang configuration">;

Expand Down
6 changes: 4 additions & 2 deletions include/swift/SIL/SILBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,16 @@ class SILBuilder {

AllocStackInst *createAllocStack(SILLocation Loc, SILType elementType,
Optional<SILDebugVariable> Var = None,
bool hasDynamicLifetime = false) {
bool hasDynamicLifetime = false,
bool isLexical = false) {
llvm::SmallString<4> Name;
Loc.markAsPrologue();
assert((!dyn_cast_or_null<VarDecl>(Loc.getAsASTNode<Decl>()) || Var) &&
"location is a VarDecl, but SILDebugVariable is empty");
return insert(AllocStackInst::create(
getSILDebugLocation(Loc), elementType, getFunction(),
substituteAnonymousArgs(Name, Var, Loc), hasDynamicLifetime));
substituteAnonymousArgs(Name, Var, Loc), hasDynamicLifetime,
isLexical));
}

AllocRefInst *createAllocRef(SILLocation Loc, SILType ObjectType,
Expand Down
6 changes: 3 additions & 3 deletions include/swift/SIL/SILCloner.h
Original file line number Diff line number Diff line change
Expand Up @@ -759,9 +759,9 @@ SILCloner<ImplClass>::visitAllocStackInst(AllocStackInst *Inst) {
Loc = MandatoryInlinedLocation::getAutoGeneratedLocation();
VarInfo = None;
}
auto *NewInst =
getBuilder().createAllocStack(Loc, getOpType(Inst->getElementType()),
VarInfo, Inst->hasDynamicLifetime());
auto *NewInst = getBuilder().createAllocStack(
Loc, getOpType(Inst->getElementType()), VarInfo,
Inst->hasDynamicLifetime(), Inst->isLexical());
remapDebugVarInfo(DebugVarCarryingInst(NewInst));
recordClonedInstruction(Inst, NewInst);
}
Expand Down
15 changes: 9 additions & 6 deletions include/swift/SIL/SILInstruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -1900,16 +1900,16 @@ class AllocStackInst final
friend SILBuilder;

bool dynamicLifetime = false;
bool lexical = false;

AllocStackInst(SILDebugLocation Loc, SILType elementType,
ArrayRef<SILValue> TypeDependentOperands,
SILFunction &F,
Optional<SILDebugVariable> Var, bool hasDynamicLifetime);
ArrayRef<SILValue> TypeDependentOperands, SILFunction &F,
Optional<SILDebugVariable> Var, bool hasDynamicLifetime,
bool isLexical);

static AllocStackInst *create(SILDebugLocation Loc, SILType elementType,
SILFunction &F,
Optional<SILDebugVariable> Var,
bool hasDynamicLifetime);
SILFunction &F, Optional<SILDebugVariable> Var,
bool hasDynamicLifetime, bool isLexical);

SIL_DEBUG_VAR_SUPPLEMENT_TRAILING_OBJS_IMPL()

Expand Down Expand Up @@ -1940,6 +1940,9 @@ class AllocStackInst final
/// is conditionally initialized.
bool hasDynamicLifetime() const { return dynamicLifetime; }

/// Whether the alloc_stack instruction corresponds to a source-level VarDecl.
bool isLexical() const { return lexical; }

/// Return the debug variable information attached to this instruction.
Optional<SILDebugVariable> getVarInfo() const {
Optional<SILType> AuxVarType;
Expand Down
1 change: 1 addition & 0 deletions include/swift/Serialization/SerializationOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace swift {
bool SkipSymbolGraphInheritedDocs = true;
bool IncludeSPISymbolsInSymbolGraph = false;
llvm::VersionTuple UserModuleVersion;
std::string SDKName;

StringRef GroupInfoPath;
StringRef ImportedHeader;
Expand Down
7 changes: 6 additions & 1 deletion include/swift/Serialization/Validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ enum class Status {
TargetIncompatible,

/// The module file was built for a target newer than the current target.
TargetTooNew
TargetTooNew,

/// The module file was built with a different SDK than the one in use
/// to build the client.
SDKMismatch
};

/// Returns true if the data looks like it contains a serialized AST.
Expand All @@ -80,6 +84,7 @@ struct ValidationInfo {
StringRef miscVersion = {};
version::Version compatibilityVersion = {};
llvm::VersionTuple userModuleVersion;
StringRef sdkName = {};
size_t bytes = 0;
Status status = Status::Malformed;
};
Expand Down
3 changes: 3 additions & 0 deletions lib/APIDigester/ModuleAnalyzerNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,9 @@ swift::ide::api::getSDKNodeRoot(SDKContext &SDKCtx,

auto &Ctx = CI.getASTContext();

// Don't check if the stdlib was build with the same SDK as what is loaded
// here as some tests rely on using a different stdlib.
Ctx.SearchPathOpts.EnableSameSDKCheck = false;

// Load standard library so that Clang importer can use it.
auto *Stdlib = Ctx.getStdlibModule(/*loadIfAbsent=*/true);
Expand Down
Loading