Skip to content

Commit 2b3a974

Browse files
Merge pull request #4388 from swiftwasm/katei/merge-main-2022-03-24
Merge main 2022-03-24
2 parents f3f8d8d + 9ac49cd commit 2b3a974

File tree

249 files changed

+10917
-6448
lines changed

Some content is hidden

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

249 files changed

+10917
-6448
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ _**Note:** This is in reverse chronological order, so newer entries are added to
55

66
## Swift 5.7
77

8+
* [SE-0340][]:
9+
10+
It is now possible to make declarations unavailable from use in asynchronous
11+
contexts with the `@available(*, noasync)` attribute.
12+
13+
This is to protect the consumers of an API against undefined behavior that can
14+
occur when the API uses thread-local storage, or encourages using thread-local
15+
storage, across suspension points, or protect developers against holding locks
16+
across suspension points which may lead to undefined behavior, priority
17+
inversions, or deadlocks.
18+
819
* [SE-0343][]:
920

1021
Top-level scripts support asynchronous calls.
@@ -9083,6 +9094,7 @@ Swift 1.0
90839094
[SE-0341]: <https://github.com/apple/swift-evolution/blob/main/proposals/0341-opaque-parameters.md>
90849095
[SE-0336]: <https://github.com/apple/swift-evolution/blob/main/proposals/0336-distributed-actor-isolation.md>
90859096
[SE-0343]: <https://github.com/apple/swift-evolution/blob/main/proposals/0343-top-level-concurrency.md>
9097+
[SE-0340]: <https://github.com/apple/swift-evolution/blob/main/proposals/0340-swift-noasync.md>
90869098

90879099
[SR-75]: <https://bugs.swift.org/browse/SR-75>
90889100
[SR-106]: <https://bugs.swift.org/browse/SR-106>

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -408,12 +408,6 @@ class UnconditionalCheckedCastInst : SingleValueInstruction, UnaryInstruction {
408408
public override var mayTrap: Bool { true }
409409
}
410410

411-
final public
412-
class UnconditionalCheckedCastValueInst : SingleValueInstruction,
413-
UnaryInstruction {
414-
public override var mayTrap: Bool { true }
415-
}
416-
417411
final public
418412
class ConvertFunctionInst : SingleValueInstruction, UnaryInstruction {}
419413

@@ -624,7 +618,3 @@ final public class CheckedCastBranchInst : TermInst, UnaryInstruction {
624618

625619
final public class CheckedCastAddrBranchInst : TermInst, UnaryInstruction {
626620
}
627-
628-
final public class CheckedCastValueBranchInst : TermInst, UnaryInstruction {
629-
}
630-

SwiftCompilerSources/Sources/SIL/Registration.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public func registerSILClasses() {
9292
register(RefElementAddrInst.self)
9393
register(RefTailAddrInst.self)
9494
register(UnconditionalCheckedCastInst.self)
95-
register(UnconditionalCheckedCastValueInst.self)
9695
register(ConvertFunctionInst.self)
9796
register(ThinToThickFunctionInst.self)
9897
register(ObjCExistentialMetatypeToObjectInst.self)
@@ -140,5 +139,4 @@ public func registerSILClasses() {
140139
register(AwaitAsyncContinuationInst.self)
141140
register(CheckedCastBranchInst.self)
142141
register(CheckedCastAddrBranchInst.self)
143-
register(CheckedCastValueBranchInst.self)
144142
}

docs/Diagnostics.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ If you run into any issues or have questions while following the steps above, fe
141141
(This section is specific to the Swift compiler's diagnostic engine.)
142142

143143
If the `-verify` frontend flag is used, the Swift compiler will check emitted diagnostics against specially formatted comments in the source. This feature is used extensively throughout the test suite to ensure diagnostics are emitted with the correct message and source location.
144+
145+
`-verify` parses all ordinary source files passed as inputs to the compiler to look for expectation comments. If you'd like to check for diagnostics in additional files, like swiftinterfaces or even Objective-C headers, specify them with `-verify-additional-file <filename>`. By default, `-verify` considers any diagnostic at `<unknown>:0` (that is, any diagnostic emitted with an invalid source location) to be unexpected; you can disable this by passing `-verify-ignore-unknown`.
144146

145147
An expected diagnostic is denoted by a comment which begins with `expected-error`, `expected-warning`, `expected-note`, or `expected-remark`. It is followed by:
146148

@@ -150,6 +152,14 @@ An expected diagnostic is denoted by a comment which begins with `expected-error
150152

151153
- (Required) The expected error message. The message should be enclosed in double curly braces and should not include the `error:`/`warning:`/`note:`/`remark:` prefix. For example, `// expected-error {{invalid redeclaration of 'y'}}` would match an error with that message on the same line. The expected message does not need to match the emitted message verbatim. As long as the expected message is a substring of the original message, they will match.
152154

153-
- (Optional) Expected fix-its. These are each enclosed in double curly braces and appear after the expected message. An expected fix-it consists of a column range followed by the text it's expected to be replaced with. For example, `let r : Int i = j // expected-error{{consecutive statements}} {{12-12=;}}` will match a fix-it attached to the consecutive statements error which inserts a semicolon at column 12, just after the 't' in 'Int'. The special {{none}} specifier is also supported, which will cause the diagnostic match to fail if unexpected fix-its are produced.
155+
- (Optional) Expected fix-its. These are each enclosed in double curly braces and appear after the expected message. An expected fix-it consists of a column range followed by the text it's expected to be replaced with. For example, `let r : Int i = j // expected-error{{consecutive statements}} {{12-12=;}}` will match a fix-it attached to the consecutive statements error which inserts a semicolon at column 12, just after the 't' in 'Int'.
156+
157+
* Insertions are represented by identical start and end locations: `{{3-3=@objc }}`. Deletions are represented by empty replacement text: `{{3-9=}}`.
158+
159+
* Line offsets are also permitted; for instance, `{{-1:12-+1:42=}}` would specify a fix-it that deleted everything between column 12 on the previous line and column 42 on the next line. (If the sign is omitted, it specifies an absolute line number, not an offset.)
160+
161+
* By default, the verifier ignores any fix-its that are *not* expected; the special `{{none}}` specifier tells it to verify that the diagnostic it's attached to has *only* the fix-its specified and no others.
162+
163+
* If two (or more) expected fix-its are juxtaposed with nothing (or whitespace) between them, then both must be present for the verifier to match. If two (or more) expected fix-its have `||` between them, then one of them must be present for the verifier to match. `||` binds more tightly than juxtaposition: `{{1-1=a}} {{2-2=b}} || {{2-2=c}} {{3-3=d}} {{none}}` will only match if there is either a set of three fix-its that insert `a`, `b`, and `d`, or a set of three fix-its that insert `a`, `c`, and `d`. (Without the `{{none}}`, it would also permit all four fix-its, but only because one of the four would be unmatched and ignored.)
154164

155165
- (Optional) Expected educational notes. These appear as a comma separated list after the expected message, enclosed in double curly braces and prefixed by 'educational-notes='. For example, `{{educational-notes=some-note,some-other-note}}` will verify the educational notes with filenames `some-note` and `some-other-note` appear. Do not include the file extension when specifying note names.

docs/SIL.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2193,6 +2193,26 @@ parts::
21932193
return %1 : $Klass
21942194
}
21952195

2196+
Forwarding Address-Only Values
2197+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2198+
2199+
Address-only values are potentially unmovable when borrowed. This
2200+
means that they cannot be forwarded with guaranteed ownership unless
2201+
the forwarded value has the same representation as in the original
2202+
value and can reuse the same storage. Non-destructive projection is
2203+
allowed, such as `struct_extract`. Aggregation, such as `struct`, and
2204+
destructive disaggregation, such as `switch_enum` is not allowed. This
2205+
is an invariant for OSSA with opaque SIL values for these reasons:
2206+
2207+
1. To avoid implicit semantic copies. For move-only values, this allows
2208+
complete diagnostics. And in general, it makes it impossible for SIL
2209+
passes to "accidentally" create copies.
2210+
2211+
2. To reuse borrowed storage. This allows the optimizer to share the same
2212+
storage for multiple exclusive reads of the same variable, avoiding
2213+
copies. It may also be necessary to support native Swift atomics, which
2214+
will be unmovable-when-borrowed.
2215+
21962216
Borrowed Object based Safe Interior Pointers
21972217
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21982218

0 commit comments

Comments
 (0)