Commit Graph

9 Commits

Author SHA1 Message Date
Allan Shortlidge
0e5cfa6259 NFC: Remove duplicated RUN lines from many SILOptimizer tests.
A previous PR (https://github.com/apple/swift/pull/32407) that mass-modified
tests left some duplicate `RUN:` lines behind.
2023-08-08 11:19:52 -07:00
Andrew Trick
b0dc18dd04 Fix an assert in exclusivity diagnostics when inouts escape.
An error found in DiagnoseInvalidEscapingCaptures can indicate invalid
SIL, which will cause DiagnoseStaticExclusivity to assert during SIL
verification. When the source-level closure captures an inout
argument, it appears in SIL to be a non-escaping closure. The SIL
verification then fails because the "nonescaping" closure actually
escapes.

Ensure that capture diagnostics run on closures before exclusivity
enforcement runs on the parent function. Bypass the SIL verification
assert if a diagnostic error was found.

Fixes rdar://75364904 (Crash with assertion `noescape partial_apply
has unexpected use`)
2021-05-05 17:06:30 -07:00
Slava Pestov
2d93585332 SIL: Look through SILBoxType when checking for invalid non-escaping function value captures
While you can't write a noescape function type explicitly except
on a function-typed parameter, you can still assign the value of
such a parameter to another 'let' or 'var' with an inferred type.

We correctly handled the 'let' case, but in the 'var' case the
value is wrapped inside a SILBoxType, so we have to look through
that.

Fixes <rdar://problem/70822136>.
2020-10-29 21:05:29 -04:00
Michael Gottesman
46432404f3 [ownership] Remove dead option: enable-ownership-stripping-after-serialization.
We always lower ownership now after the diagnostic passes (what this option
actually controlled). So remove it.

NFC.
2020-06-16 10:52:02 -07:00
Ravi Kandhadai
a2d38f608f [SIL Diagnostics] Improve diagnostics for capture of inout values
within escaping autoclosures.

<rdar://problem/60551844>
2020-04-19 13:52:51 -07:00
Michael Gottesman
f10b45b540 [ownership] Add an extra run of -Onone tests with diagnostics with -enable-ownership-stripping-after-serialization enabled.
Right now the stdlib/overlays can compile against -Onone tests with or without
-enable-ownership-stripping-after-serialization. This will help me to prevent
other work going on from breaking these properties.
2019-10-26 15:12:14 -07:00
Slava Pestov
05898d8deb SIL: More descriptive diagnostic about escaping closure vs local function
Fixes <rdar://problem/50554625>.
2019-10-21 17:47:18 -04:00
Slava Pestov
d832fb9823 SILOptimizer: Fix crash on invalid in invalid escaping captures pass
An inout capture of 'self' is not lowered as a SIL argument inside
an initializer, so add a new check to handle this case.

Fixes <rdar://problem/50412872>.
2019-05-18 00:24:13 -04:00
Slava Pestov
9ac0dc3d6c SILOptimizer: Re-implement escaping capture diagnostics
The new pass is based on existing asserts in DiagnoseStaticExclusivity.
They were compiled out in release builds and only checked for captures of
inout parameters. This patch converts the assertions into diagnostics and
adds checks for captures of non-escaping function values.

Unlike the Sema-based checks that this replaces, the new code handles
transitive captures from recursive local functions, which means certain
invalid code that used to compile will now be rejected with an error.

The new analysis also looks at the ultimate usages of a local function
instead of just assuming all local functions are escaping, which fixes
issues where the compiler would reject valid code.

Fixes a bunch of related issues, including:

- <rdar://problem/29403178>
- <https://bugs.swift.org/browse/SR-8546> / <rdar://problem/43355341>
- <https://bugs.swift.org/browse/SR-9043> / <rdar://problem/45511834>
2019-04-09 15:02:14 -04:00