Commit Graph

9332 Commits

Author SHA1 Message Date
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
Joe Groff
03e2e8f476 BorrowToDestructureUtils: handle borrowing switches.
Instead of trying to convert all switches into consumes, allow a switch of a borrow
to remain as such.
2024-01-31 20:38:22 -08:00
Slava Pestov
af3ab14986 SILGen: Clean up substitution map construction to deal with Copyable 2024-01-31 21:55:52 -05:00
Slava Pestov
094328ddab SIL: Add some assertions 2024-01-31 21:55:52 -05:00
Nate Chandler
990c318941 Revert "NFC: [TypeLowering] Handle @unchecked BC fields."
This reverts commit 0ae0fdc3b1.
2024-01-31 17:11:55 -08:00
Slava Pestov
45f31b4516 AST: Refactor ASTPrinter to use getRequirementsWithInverses() 2024-01-31 18:40:35 -05:00
Erik Eckstein
3b239b25f3 swift SIL: add Function thunk APIs
* `var thunkKind`
* `set(thunkKind:)`
2024-01-31 17:16:13 +01:00
Erik Eckstein
b3e5f07a99 SILFunction: don't preserve specialized functions for the debugger 2024-01-31 17:16:12 +01:00
nate-chandler
a43faf89c8 Merge pull request #71242 from nate-chandler/bitwise-copyable/not-for-unchecked
[BitwiseCopyable] Don't derive on @unchecked field
2024-01-31 05:55:38 -08:00
nate-chandler
643fa6ca7c Merge pull request #71157 from nate-chandler/nfc/20240125/1/tweak-visit-product-leaves
NFC: [MemAccessUtils] Tweaked API.
2024-01-30 17:00:12 -08:00
Nate Chandler
0ae0fdc3b1 NFC: [TypeLowering] Handle @unchecked BC fields.
The appearance of a field whose type's conformance to BitwiseCopyable is
@unchecked permits the type not to conform.
2024-01-30 11:21:40 -08:00
Andrew Trick
13db95eac3 BridgedASTType::isEscapable 2024-01-30 08:38:57 -08:00