Commit Graph

9293 Commits

Author SHA1 Message Date
Nate Chandler
427d9cbcba [TypeLowering] Loosen assertion. 2024-02-14 09:57:43 -08:00
Nate Chandler
10dd58152b NFC: [TypeLowering] Add flag to skip verify.
To allow skipping it when verification has a false positive.
2024-02-14 09:57:43 -08:00
Nate Chandler
187f434798 [BitwiseCopyable] Uniform inference for non-frozen
Don't key inference behavior off of library evolution mode.
2024-02-14 09:57:43 -08:00
Nate Chandler
3b0a13a1fd [BitwiseCopyable] Don't verify for interfaces.
Modules built without the feature enabled will have swiftinterfaces
whose types don't conform to the protocol.
2024-02-14 08:20:16 -08:00
Erik Eckstein
6e8b80c791 SIL: add printing and parsing support for specialized vtables
If the vtable refers to a specialized class, a SIL type specifies the bound generic class type:
```
  sil_vtable $G<Int> {
    // ...
  }
```
2024-02-14 09:51:36 +01:00
John McCall
b23bc82cdb Merge pull request #71574 from rjmccall/isolation-any-sil-irgen
SIL and IRGen support for `@isolated(any)` function types
2024-02-13 11:57:16 -05:00
Doug Gregor
eeeb8c3f18 Merge pull request #71577 from DougGregor/silgen-no-peeping-typed-throws-closures
[SILGen] Don't peephole closures with abstraction differences in the thrown error
2024-02-13 08:53:45 -08:00
Joe Groff
2170b4e725 Merge pull request #71489 from jckarter/borrowing-switch-8
MoveOnlyAddressUtils: Fixes for borrowing switch over address-only types.
2024-02-13 07:51:40 -08:00
John McCall
d5142668f4 SIL and IRGen support for @isolated(any). SILGen to come. 2024-02-13 03:04:13 -05:00
Pavel Yaskevich
db020c1486 Merge pull request #71435 from xedin/fix-need-for-adhoc-distributed-requirements
[Distributed] Re-implement ad-hoc requirements into dynamic witness table lookup for `SerializationRequirement` conformance
2024-02-13 00:02:05 -08:00
Doug Gregor
3edbb06632 [SILGen] Don't peephole closures with abstraction differences in the thrown error
The prolog and epilog code in SILGen is not set up to deal with
abstraction differences in the thrown error type of closures, so disable
the peephole optimization for closure literals.

Fixes https://github.com/apple/swift/issues/71401 / rdar://122366566,
which I've stared at for waaaaay too many hours.
2024-02-12 23:15:07 -08:00
Joe Groff
0365c6abba MoveOnlyAddressUtils: Fixes for borrowing switch over address-only types.
Relax some existing pattern matches and add some unhandled instructions to the
walkers so that borrowing switches over address-only enums are properly analyzed
for incorrect consumption. Add a `[strict]` flag to `mark_unresolved_move_only_value`
to indicate a borrow access that should remain a borrow access even if the subject
is later stack-promoted from a box.
2024-02-12 20:20:50 -08:00
Allan Shortlidge
b96812513c Merge pull request #71561 from tshortli/warnings
NFC: Address some warnings
2024-02-12 14:59:27 -08:00
Pavel Yaskevich
1909b12370 [SIL] Distributed: Remove logic related to ad-hoc requirements from SILFunction
Ad-hoc requirements are now obsolete by making `remoteCall`,
`record{Argument, ReturnType}`, `decodeNextArgument` protocols
requirements and injecting witness tables for `SerializationRequirement`
conformances during IRGen.
2024-02-12 14:26:30 -08:00
Andrew Trick
c4eab6a54a Merge pull request #71266 from atrick/lifetime-insertion
Add the LifetimeDependenceInsertion pass.
2024-02-12 13:07:03 -08:00
Allan Shortlidge
91f14e32e7 NFC: Address -Wimplicit-fallthrough warnings. 2024-02-12 12:24:39 -08:00
Cyndy Ishida
f80da87839 [TBDGen] Add back standalone OBJC_METACLASS symbols (#70827)
It turns out there are valid usecases for exposing a standalone
objc-metaclass symbols and tbd files must encode it correctly.

resolves: rdar://118499886
2024-02-12 12:23:14 -08:00
Andrew Trick
f713587aa5 Fix OSSA support for mark_dependence [nonescaping]
Handle escapes to function results.
2024-02-12 09:57:14 -08:00
Andrew Trick
340bd26d23 SwiftCompilerSources: bridge isNoEscape and mayEscape. 2024-02-12 09:57:14 -08:00
Kavon Farvardin
08c30a2cfc ParseSIL: handle ReferenceStorageType
It doesn't make sense that we permit a `ReferenceStorageType` to be
substituted for a generic parameter, since I don't know whether any
valid Swift code would ever actually construct such SIL.

But there are some hand-written SIL test cases that do it anyway, for
unconstrained generic parameters. Since now even those get protocol
requirements with NoncopyableGenerics, just look at the referent type in
ParseSIL.
2024-02-11 20:40:03 -08:00
Kavon Farvardin
4461030914 NCGenerics: fix AutoDiff tests 2024-02-11 20:40:03 -08:00
nate-chandler
b935996be5 Merge pull request #71491 from nate-chandler/bitwise-copyable/within-module
[BitwiseCopyable] Verify only within module.
2024-02-09 09:49:21 -08:00
Nate Chandler
6f3bb493b4 [BitwiseCopyable] Verify only within module.
Don't verify lowering in modules built from swiftinterface (which may
not have been built with `-enable-experimental-feature BitwiseCopyable`)

Allow trivial types defined in other modules to lack conformance because
those modules may not have been built with the feature enabled.
2024-02-09 07:02:13 -08:00
Andrew Trick
da3f583492 Add mark_dependence [unresolved]
In preparation for inserting mark_dependence instructions for lifetime
dependencies early, immediately after SILGen. That will simplify the
implementation of borrowed arguments.

Marking them unresolved is needed to make OSSA verification
conservative until lifetime dependence diagnostics runs.
2024-02-08 22:53:16 -08:00
Slava Pestov
368721ef5c SIL: Adjust isTypeMetadataForLayoutAccessible() to visit more lowered positions
Fixes part of https://github.com/apple/swift/issues/67645, rdar://119267393
2024-02-07 17:13:33 -08:00
Nate Cook
e317febc9d Revert "Allow normal function results of @yield_once coroutines (#69843)"
This reverts commit aa5b505014.
2024-02-07 14:57:31 -06:00
Anton Korobeynikov
aa5b505014 Allow normal function results of @yield_once coroutines (#69843)
This adds SIL-level support and LLVM codegen for normal results of a coroutine.

The main user of this will be autodiff as VJP of a coroutine must be a coroutine itself (in order to produce the yielded result) and return a pullback closure as a normal result.

For now only direct results are supported, but this seems to be enough for autodiff purposes.
2024-02-06 22:13:15 -08:00
nate-chandler
01bce39100 Merge pull request #71418 from nate-chandler/nfc/20240206/1/rename-inst-class
[NFC] SIL: Renamed SpecifyTestInst.
2024-02-06 22:02:05 -08:00
Nate Chandler
b535725647 [NFC] SIL: Renamed SpecifyTestInst.
The instruction's spelling was changed to `specify_test` but the class
name wasn't updated from `TestSpecificationInst`.  Update it here.
2024-02-06 16:29:09 -08:00
Ellie Shin
e38bc9756c Merge pull request #71083 from apple/es-sil-pkg
Support a package SILLinkage
2024-02-07 09:10:13 +09:00
Slava Pestov
d46bd335de Merge pull request #71371 from slavapestov/ncgenerics-fixes-3
Non-copyable generics fixes, part 3
2024-02-06 08:35:07 -05:00
Hamish Knight
7b012d825c Merge pull request #70600 from hamishknight/postal-service
[ASTWalker] Continue post-walking with `Action::SkipChildren`
2024-02-06 10:24:38 +00:00
Ellie Shin
72a7760027 Support package SIL linkage.
Decls with a package access level are currently set to public SIL
linkages. This limits the ability to have more fine-grained control
and optimize around resilience and serialization.
This PR introduces a separate SIL linkage and FormalLinkage for
package decls, pipes them down to IRGen, and updates linkage checks
at call sites to include package linkage.

Resolves rdar://121409846
2024-02-06 01:23:14 -08:00
Slava Pestov
af50d7e6b8 AST: Add allowInverses flag to AbstractGenericSignatureRequest 2024-02-05 18:43:06 -05:00
Slava Pestov
4e84d28670 SIL: Build substitution signature without expanding defaults or applying inverses 2024-02-05 18:43:06 -05:00
Slava Pestov
81027cff23 SIL: Drop conformances to Copyable and Escapable from substitution signature 2024-02-05 18:43:06 -05:00
Hamish Knight
15fa06dd37 [ASTWalker] Cleanup some cases manually doing post-walks
We can replace these with `Action::SkipChildren`.
2024-02-05 15:27:26 +00:00
Hamish Knight
16cfca4186 [ASTWalker] NFC: Rename SkipChildren -> SkipNode
This better describes what the action currently
does, and allows us to re-introduce `SkipChildren`
with the correct behavior.
2024-02-05 15:27:25 +00:00
Erik Eckstein
86f23b089f SIL: add the [perf_constraint] flag in SILFunction
Specifies that the optimizer and IRGen must not add runtime calls which are not in the function originally.
This attribute is set for functions with performance constraints or functions which are called from functions with performance.
2024-02-05 12:26:30 +01:00
Michael Gottesman
94acfd2873 [region-isolation] Enable address walker verification on AllocPackInst.
This provides a guarantee that the address walker will not miss walking any
addresses due to the walker not being updated.
2024-02-02 14:50:10 -08:00
Michael Gottesman
f531f705cf [sil] Dump the unknown users when the address walker fails to visit an instructions.
Just making this easier to debug. Previously, one would have to go into the
debugger to figure out what the issue is. Now upon failure, one just gets the
exact instruction that needs to be added.
2024-02-02 14:50:10 -08:00
Rintaro Ishizaki
b839718351 [AST] Use scoped enum for attribute kinds
Align with other kind enum e.g. DeclKind.
2024-02-02 09:36:48 -08:00
Rintaro Ishizaki
07bb0380a1 [AST] Use class names for type attribute kind enum
Align with DeclAttrKind.
2024-02-02 09:36:47 -08:00
nate-chandler
c0ad612d9a Merge pull request #71335 from nate-chandler/bitwise-copyable/sil-token
[BitwiseCopyable] Permit SILTokenType's nonconformance.
2024-02-02 06:58:39 -08:00
Slava Pestov
066cb8b9a4 SIL: One more SILPrinter fix 2024-02-01 23:35:33 -05:00
Nate Chandler
c148e11741 [TypeLowering] Allow SILToken to !BitwiseCopyable.
Like `ModuleType`, there's no reason to conform this flavor of trivial
type to `BitwiseCopyable`.  So permit it during verification.
2024-02-01 18:08:23 -08:00
Nate Chandler
159571c5ee [NFC] TypeLowering: Tweak verification.
Improved comments, and simplified assertion while making more stringent.
2024-02-01 18:06:45 -08:00
Joe Groff
b847528c55 Merge pull request #71305 from jckarter/borrowing-switch-4
BorrowToDestructureUtils: handle borrowing switches.
2024-02-01 09:20:56 -08:00
Slava Pestov
80205ecf9c Merge pull request #71241 from slavapestov/ncgenerics-fixes
Non-copyable generics fixes
2024-02-01 07:18:29 -05:00
nate-chandler
902a22d94a Merge pull request #71298 from nate-chandler/bitwise-copyable/remove-unchecked
[BitwiseCopyable] Remove @unchecked behavior.
2024-02-01 03:21:26 -08:00