Skip to content

Commit 7489bab

Browse files
authored
Merge pull request swiftlang#150 from swiftwasm/maxd/swiftwasm-merge
Merge master with resolved conflicts
2 parents 50db842 + 017bfe0 commit 7489bab

File tree

220 files changed

+9398
-1471
lines changed

Some content is hidden

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

220 files changed

+9398
-1471
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ CHANGELOG
2626
Swift Next
2727
----------
2828

29+
* [SE-0266][]:
30+
31+
Enumerations with no associated values, or only `Comparable` associated values, can opt-in to synthesized `Comparable` conformance by declaring conformance to the `Comparable` protocol. The synthesized implementation orders the cases first by case-declaration order, and then by lexicographic order of the associated values (if any).
32+
33+
```swift
34+
enum Foo: Comparable {
35+
case a(Int), b(Int), c
36+
}
37+
38+
// .a(0) < .a(1) < .b(0) < .b(1) < .c
39+
```
40+
2941
* [SE-0269][]:
3042

3143
When an escaping closure explicitly captures `self` in its capture list, the
@@ -7901,6 +7913,7 @@ Swift 1.0
79017913
[SE-0252]: <https://github.com/apple/swift-evolution/blob/master/proposals/0252-keypath-dynamic-member-lookup.md>
79027914
[SE-0253]: <https://github.com/apple/swift-evolution/blob/master/proposals/0253-callable.md>
79037915
[SE-0254]: <https://github.com/apple/swift-evolution/blob/master/proposals/0254-static-subscripts.md>
7916+
[SE-0266]: <https://github.com/apple/swift-evolution/blob/master/proposals/0266-synthesized-comparable-for-enumerations.md>
79047917
[SE-0269]: <https://github.com/apple/swift-evolution/blob/master/proposals/0269-implicit-self-explicit-capture.md>
79057918

79067919
[SR-106]: <https://bugs.swift.org/browse/SR-106>

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
|---|:---:|:---:|
1616
|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/ppc64le_ubuntu_16_04.json)** | PPC64LE |[![Build Status](https://ci-external.swift.org/job/oss-swift-5.1-RA-linux-ubuntu-16.04-ppc64le/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-5.1-RA-linux-ubuntu-16.04-ppc64le)|
1717
|**[Ubuntu 16.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/aarch64_ubuntu_16.04.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-aarch64)|
18+
|**[Ubuntu 18.04 ](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/aarch64_ubuntu_18.04.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-18.04-aarch64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-18.04-aarch64)|
1819
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | ARMv7 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android)|
1920
|**[Android](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_ubuntu_16_04_LTS_android.json)** | AArch64 |[![Build Status](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-RA-linux-ubuntu-16.04-android-arm64)|
20-
|**[Windows 2019](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_windows_2019.json)** | x86_64 | [![Build Status](https://ci-external.swift.org/job/oss-swift-windows-x86_64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-windows-x86_64)|
21+
|**[Windows 2019 (VS 2017)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_windows_2019.json)** | x86_64 | [![Build Status](https://ci-external.swift.org/job/oss-swift-windows-x86_64/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/oss-swift-windows-x86_64)|
22+
|**[Windows 2019 (VS 2019)](https://github.com/apple/swift-community-hosted-continuous-integration/blob/master/nodes/x86_64_windows_2019_VS2019.json)** | x86_64 | [![Build Status](https://ci-external.swift.org/job/oss-swift-windows-x86_64-vs2019/lastCompletedBuild/badge/icon)](https://ci-external.swift.org/job/ooss-swift-windows-x86_64-vs2019)|
2123

2224
**Swift TensorFlow Community-Hosted CI Platforms**
2325

@@ -108,7 +110,9 @@ Instructions for installing CMake and Ninja directly can be found [below](#build
108110

109111
For Ubuntu, you'll need the following development dependencies:
110112

111-
sudo apt-get install git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libcurl4-openssl-dev systemtap-sdt-dev tzdata rsync python-six
113+
sudo apt-get install git cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libedit-dev \
114+
libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libcurl4-openssl-dev \
115+
systemtap-sdt-dev tzdata rsync python-six
112116

113117
**Note:** LLDB currently requires at least `swig-1.3.40` but will successfully build
114118
with version 2 shipped with Ubuntu.

cmake/modules/AddSwift.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,10 @@ function(_add_variant_c_compile_flags)
279279
list(APPEND result "-D_DLL")
280280
# NOTE: We assume that we are using VS 2015 U2+
281281
list(APPEND result "-D_ENABLE_ATOMIC_ALIGNMENT_FIX")
282+
# NOTE: We use over-aligned values for the RefCount side-table
283+
# (see revision d913eefcc93f8c80d6d1a6de4ea898a2838d8b6f)
284+
# This is required to build with VS2017 15.8+
285+
list(APPEND result "-D_ENABLE_EXTENDED_ALIGNED_STORAGE=1")
282286

283287
# msvcprt's std::function requires RTTI, but we do not want RTTI data.
284288
# Emulate /GR-.

cmake/modules/AddSwiftUnittests.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ function(add_swift_unittest test_dirname)
5252
target_compile_options(${test_dirname} PRIVATE
5353
-march=core2)
5454
endif()
55+
elseif("${SWIFT_HOST_VARIANT}" STREQUAL "windows")
56+
target_compile_definitions("${test_dirname}" PRIVATE
57+
_ENABLE_EXTENDED_ALIGNED_STORAGE)
5558
endif()
5659

5760
find_program(LDLLD_PATH "ld.lld")

cmake/modules/SwiftHandleGybSources.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
include(SwiftAddCustomCommandTarget)
22
include(SwiftSetIfArchBitness)
33

4+
find_package(Python2 COMPONENTS Interpreter REQUIRED)
5+
46
# Create a target to process single gyb source with the 'gyb' tool.
57
#
68
# handle_gyb_source_single(
@@ -58,7 +60,7 @@ function(handle_gyb_source_single dependency_out_var_name)
5860
COMMAND
5961
"${CMAKE_COMMAND}" -E make_directory "${dir}"
6062
COMMAND
61-
"${PYTHON_EXECUTABLE}" "${gyb_tool}" ${SWIFT_GYB_FLAGS} ${GYB_SINGLE_FLAGS} -o "${GYB_SINGLE_OUTPUT}.tmp" "${GYB_SINGLE_SOURCE}"
63+
"$<TARGET_FILE:Python2::Interpreter>" "${gyb_tool}" ${SWIFT_GYB_FLAGS} ${GYB_SINGLE_FLAGS} -o "${GYB_SINGLE_OUTPUT}.tmp" "${GYB_SINGLE_SOURCE}"
6264
COMMAND
6365
"${CMAKE_COMMAND}" -E copy_if_different "${GYB_SINGLE_OUTPUT}.tmp" "${GYB_SINGLE_OUTPUT}"
6466
COMMAND

docs/SIL.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5666,6 +5666,42 @@ destination (if it returns with ``throw``).
56665666

56675667
The rules on generic substitutions are identical to those of ``apply``.
56685668

5669+
Differentiable Programming
5670+
~~~~~~~~~~~~~~~~~~~~~~~~~~
5671+
5672+
differentiability_witness_function
5673+
``````````````````````````````````
5674+
::
5675+
5676+
sil-instruction ::=
5677+
'differentiability_witness_function'
5678+
'[' sil-differentiability-witness-function-kind ']'
5679+
'[' 'parameters' sil-differentiability-witness-function-index-list ']'
5680+
'[' 'results' sil-differentiability-witness-function-index-list ']'
5681+
generic-parameter-clause?
5682+
sil-function-name ':' sil-type
5683+
5684+
sil-differentiability-witness-function-kind ::= 'jvp' | 'vjp' | 'transpose'
5685+
sil-differentiability-witness-function-index-list ::= [0-9]+ (' ' [0-9]+)*
5686+
5687+
differentiability_witness_function [jvp] [parameters 0] [results 0] \
5688+
<T where T: Differentiable> @foo : $(T) -> T
5689+
5690+
Looks up a differentiability witness function (JVP, VJP, or transpose) for
5691+
a referenced function via SIL differentiability witnesses.
5692+
5693+
The differentiability witness function kind identifies the witness function to
5694+
look up: ``[jvp]``, ``[vjp]``, or ``[transpose]``.
5695+
5696+
The remaining components identify the SIL differentiability witness:
5697+
5698+
- Original function name.
5699+
- Parameter indices.
5700+
- Result indices.
5701+
- Witness generic parameter clause (optional). When parsing SIL, the parsed
5702+
witness generic parameter clause is combined with the original function's
5703+
generic signature to form the full witness generic signature.
5704+
56695705
Assertion configuration
56705706
~~~~~~~~~~~~~~~~~~~~~~~
56715707

include/swift/ABI/Metadata.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,32 @@ struct TargetEnumMetadata : public TargetValueMetadata<Runtime> {
14261426
return *asWords;
14271427
}
14281428

1429+
bool isCanonicalStaticallySpecializedGenericMetadata() const {
1430+
auto *description = getDescription();
1431+
if (!description->isGeneric())
1432+
return false;
1433+
1434+
auto *trailingFlags = getTrailingFlags();
1435+
if (trailingFlags == nullptr)
1436+
return false;
1437+
1438+
return trailingFlags->isCanonicalStaticSpecialization();
1439+
}
1440+
1441+
const MetadataTrailingFlags *getTrailingFlags() const {
1442+
auto description = getDescription();
1443+
auto flags = description->getFullGenericContextHeader()
1444+
.DefaultInstantiationPattern->PatternFlags;
1445+
if (!flags.hasTrailingFlags())
1446+
return nullptr;
1447+
auto offset =
1448+
getGenericArgumentOffset() +
1449+
description->getFullGenericContextHeader().Base.getNumArguments() +
1450+
(hasPayloadSize() ? 1 : 0);
1451+
auto asWords = reinterpret_cast<const void *const *>(this);
1452+
return reinterpret_cast<const MetadataTrailingFlags *>(asWords + offset);
1453+
}
1454+
14291455
static constexpr int32_t getGenericArgumentOffset() {
14301456
return sizeof(TargetEnumMetadata<Runtime>) / sizeof(StoredPointer);
14311457
}

include/swift/AST/Attr.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,11 @@ SIMPLE_DECL_ATTR(_inheritsConvenienceInitializers,
519519
APIStableToAdd | ABIStableToAdd | APIBreakingToRemove | ABIBreakingToRemove,
520520
93)
521521

522+
DECL_ATTR(_typeEraser, TypeEraser,
523+
OnProtocol | UserInaccessible | NotSerialized |
524+
ABIStableToAdd | ABIBreakingToRemove | APIStableToAdd | APIBreakingToRemove,
525+
94)
526+
522527
SIMPLE_DECL_ATTR(IBSegueAction, IBSegueAction,
523528
OnFunc |
524529
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,

include/swift/AST/Attr.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,21 @@ class DynamicReplacementAttr final
11081108
}
11091109
};
11101110

1111+
/// The \c @_typeEraser(TypeEraserType) attribute.
1112+
class TypeEraserAttr final : public DeclAttribute {
1113+
TypeLoc TypeEraserLoc;
1114+
public:
1115+
TypeEraserAttr(SourceLoc atLoc, SourceRange range, TypeLoc typeEraserLoc)
1116+
: DeclAttribute(DAK_TypeEraser, atLoc, range, /*Implicit=*/false),
1117+
TypeEraserLoc(typeEraserLoc) {}
1118+
1119+
const TypeLoc &getTypeEraserLoc() const { return TypeEraserLoc; }
1120+
1121+
static bool classof(const DeclAttribute *DA) {
1122+
return DA->getKind() == DAK_TypeEraser;
1123+
}
1124+
};
1125+
11111126
/// Represents any sort of access control modifier.
11121127
class AbstractAccessControlAttr : public DeclAttribute {
11131128
protected:

include/swift/AST/AutoDiff.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,27 @@ struct AutoDiffDerivativeFunctionKind {
7373
}
7474
};
7575

76+
/// The kind of a differentiability witness function.
77+
struct DifferentiabilityWitnessFunctionKind {
78+
enum innerty : uint8_t {
79+
// The Jacobian-vector products function.
80+
JVP = 0,
81+
// The vector-Jacobian products function.
82+
VJP = 1,
83+
// The transpose function.
84+
Transpose = 2
85+
} rawValue;
86+
87+
DifferentiabilityWitnessFunctionKind() = default;
88+
DifferentiabilityWitnessFunctionKind(innerty rawValue) : rawValue(rawValue) {}
89+
explicit DifferentiabilityWitnessFunctionKind(unsigned rawValue)
90+
: rawValue(static_cast<innerty>(rawValue)) {}
91+
explicit DifferentiabilityWitnessFunctionKind(StringRef name);
92+
operator innerty() const { return rawValue; }
93+
94+
Optional<AutoDiffDerivativeFunctionKind> getAsDerivativeFunctionKind() const;
95+
};
96+
7697
/// Identifies an autodiff derivative function configuration:
7798
/// - Parameter indices.
7899
/// - Result indices.

0 commit comments

Comments
 (0)