Commit Graph

2251 Commits

Author SHA1 Message Date
Nate Chandler
8b662a7fea [Sema] Allow implicit dynamic @nonobjc.
Back in https://github.com/apple/swift/pull/24959, marking a decl both
dynamic and @nonobjc was allowed.  So implicitly mark decls that are
@nonobjc dynamic when -enable-implicit-dynamic is specified.

rdar://112152116
2023-07-12 14:23:50 -07:00
Rintaro Ishizaki
2b13365f0b Merge pull request #67206 from rintaro/parse-each-self-rdar107450487
[Parse] Accept 'self' after 'each'
2023-07-11 15:02:26 -07:00
Michael Gottesman
adeae2f63e [reference-bindings] Inout Binding ensure that we handle fields correctly
I also:

1. Added some basic SILGen/SILOptimizer/Interpreter tests.
2. Added some logging and cleaned up the pass a little bit.

rdar://112033023
2023-07-11 13:27:51 -07:00
Pavel Yaskevich
4760b95282 Merge pull request #67183 from xedin/convert-effects-into-storageRestrictions
[AST/Sema] Implement @storageRestrictions attribute
2023-07-11 11:57:14 -07:00
Rintaro Ishizaki
ababa1e461 [Parse] Accept 'self' after 'each'
Also move 'repeat', 'each', and 'any' expression parsing to
'parseExprSequenceElement'

rdar://107450487
2023-07-10 15:37:00 -07:00
Slava Pestov
b19fc60a52 Merge pull request #67180 from slavapestov/type-decoder-one-element-tuple
TypeDecoder: Unwrap unlabeled one-element tuples when expanding pack expansions
2023-07-07 17:14:14 -04:00
Pavel Yaskevich
06216fc0f1 [Sema] InitAccessors: Synthesize memberwise inits only with init accessor properties 2023-07-07 13:56:02 -07:00
Pavel Yaskevich
e84cd810d1 [AST] InitAccessors: fallback to init accessor effects if @storageRestrictions is not used 2023-07-07 11:21:37 -07:00
Slava Pestov
6a4036343f TypeDecoder: Unwrap unlabeled one-element tuples when expanding pack expansions 2023-07-07 14:14:51 -04:00
Pavel Yaskevich
fe17491982 [AST] InitAccessors: Switch from init accessor effects (initializes/accesses) to @storageRestrictions 2023-07-07 10:00:36 -07:00
Pavel Yaskevich
00729ad958 Merge pull request #67107 from xedin/setterless-init-accessor-properties
[SILGen/DI] Add support for init accessor properties without setters
2023-07-07 00:16:07 -07:00
Dario Rexin
b3cdcda6c7 Merge pull request #67173 from drexin/wip-singleton-inject
Support destructiveInjectEnumTag in singleton enums with layout strings
2023-07-06 19:33:05 -07:00
Dario Rexin
c046253039 [IRGen] Emit swift_singletonEnum_destructiveInjectEnumTag 2023-07-06 15:47:51 -07:00
Dario Rexin
2f0726a9a1 [IRGen] Emit swift_enumSimple_destructiveInjectEnumTag 2023-07-06 15:25:11 -07:00
Slava Pestov
fb14aef32a Uncomment fixed FIXMEs in test/Interpreter/variadic_generic_conformances.swift 2023-07-05 16:35:16 -04:00
Slava Pestov
b7a404f86a Executable test for runtime demangling of pack expansions 2023-07-05 16:35:16 -04:00
Pavel Yaskevich
8a1107ea45 [Tests] InitAccessors: Test use of init accessor properties without setters 2023-07-04 00:05:25 -07:00
Michael Gottesman
268cd76ac6 [move-only] Add the moveonly_linkedlist.swift interpreter test.
Both of the previous fixes in this PR were found via this test.
2023-07-03 15:55:13 -07:00
Michael Gottesman
4f24a2f64b [move-only] Rename moveonly_fixedqueue.swift -> moveonly_fixedsizequeue.swift and add some more to the test.
The rename makes it more obvious what the file is testing and I added a bit more
to the test.
2023-06-30 12:26:47 -07:00
Dario Rexin
707330c8bd [IRGen] Emit swift_multiPayloadEnumGeneric_destructiveInjectEnumTag
Assign swift_multiPayloadEnumGeneric_destructiveInjectEnumTag as witness function on generic multi payload enums when using layout strings
2023-06-29 16:34:18 -07:00
Dario Rexin
622f7a26e9 Merge pull request #67022 from drexin/wip-sp-gen-destr-inject-tag
Support destructiveInjectEnumTag in generic single payload enums with layout strings
2023-06-29 16:33:30 -07:00
Ben Barham
844508dcbc [Test] Add executable test requirement to moveonly_fixedqueue.swift
Resolves rdar://111531602.
2023-06-29 14:09:59 -07:00
Dario Rexin
8ccaad1db5 [IRGen] Emit swift_singlePayloadEnumGeneric_destructiveInjectEnumTag
Assign swift_singlePayloadEnumGeneric_destructiveInjectEnumTag as witness function on generic single payload enums when using layout strings
2023-06-29 10:39:54 -07:00
Michael Gottesman
9b59588fc3 [move-only] If we have a guaranteed forwarding instruction with only trivial results, treat it as a liveness use.
The reason why we want to do this is that if we treat it as a true forwarding
use, we will visit the uses of the trivial value and treat those as liveness
uses. Since the trivial value is not tied to the lifetime of the underlying
noncopyable value, this can be outside of the lifetime of said value causing a
memory lifetime error. By just treating the guaranteed forwarding instruction
with all trivial values as a liveness use, we avoid this problem.

I added a SIL test, a Swift test, and an Interpreter test that validates this
behavior.

rdar://111497657
2023-06-29 00:00:05 -07:00
Dario Rexin
3524945cd4 [IRGen+Runtime] Implement getEnumTag for singleton enums in layout strings (#66985) 2023-06-28 14:25:34 -07:00
swift-ci
746dd9823a Merge pull request #66976 from nate-chandler/test/20230627/1
[Test] Commented two tests and added one.
2023-06-28 02:04:07 -07:00
Michael Gottesman
bd90e310e1 Merge pull request #66952 from gottesmm/pr-87fcc78991b465d8a15454dc76b66d6f347ddff0
[move-only] Emit an error if we /ever/ partially consume a noncopyable type.
2023-06-28 01:00:40 -07:00
Doug Gregor
3064412703 Merge pull request #66972 from DougGregor/init-accessors-always-part-of-memberwise-init 2023-06-27 21:50:07 -07:00
Nate Chandler
bd52be8990 [Test] Add for MOAC reinit miscompile.
On recent main, this test case fails verification with

```
SIL memory lifetime failure in @$s4main4doityyF: memory is not initialized, but should be
memory location:   %21 = struct_element_addr %20 : $*M4, #M4.s2    // user: %23
at instruction:   %23 = apply %22(%19, %21) : $@convention(thin) (@inout S, @inout S) -> ()

[...]

4.      While running pass #173 SILFunctionTransform "MoveOnlyChecker" on SILFunction "@$s4main4doityyF".
 for 'doit()' (at test/Interpreter/moveonly_reinit_noncontiguous.swift:32:1)
```
2023-06-27 21:02:18 -07:00
Dario Rexin
ca664141cc [IRGen+Runtime] Add support for initializeBufferWithCopyOfBuffer to layout strings (#66965) 2023-06-27 18:05:30 -07:00
Doug Gregor
fe2dec5ee5 [SE-0400] All properties with init accessors become part of the memberwise init
Per the clarification during the review thread, all properties with
init accessors (including those that do not initialize any underlying
storage) are part of the memberwise initializer.
2023-06-27 17:28:53 -07:00
Michael Gottesman
3dde9df468 [move-only] Emit an error if we /ever/ partially consume a noncopyable type.
The reason why I am doing this is that this was not part of the original
evolution proposal (it was called an extension) and after some discussion it was
realized that partial consumption would benefit from discussion on the forums.

rdar://111353459
2023-06-27 13:52:49 -07:00
Dario Rexin
fc6834daf6 [IRGen+Runtime] Add getEnumTag for layout strings on simple single payload enums (#66941) 2023-06-26 19:32:51 -07:00
Dario Rexin
253d8fbf33 [IRGen+Runtime] Add getEnumTag for layout strings on generic single payload enum (#66911) 2023-06-23 20:43:28 -07:00
nate-chandler
98d895db52 Merge pull request #66892 from nate-chandler/rdar111221183
[MoveOnlyAddressChecker] Fixed two use-before-def handlings.
2023-06-23 19:13:56 -07:00
Dario Rexin
270089f297 [IRGen+Runtime] Layout string getEnumTag for fixed size enums subset (#66899)
* [IRGen+Runtime] Layout string getEnumTag for fixed size enums subset

getEnumTag impl for layout strings of fixed sized enums that use a function to fetch the enum tag

* Fix potential UB in IRGen
2023-06-23 18:10:55 -07:00
Nate Chandler
92fd8da3c3 [FieldSensitivePL] Fixed use-before-def handling.
rdar://111118843
2023-06-23 10:16:53 -07:00
Dario Rexin
36ddb77fcd [IRGen+Runtime] Layout string getEnumTag for generic multi payload enums (#66872)
We already store all necessary information to extract the tag in the layout string, so we should utilize it for the getEnumTag witness
2023-06-22 19:07:50 -07:00
Slava Pestov
3676379302 Merge pull request #66814 from slavapestov/variadic-type-conditional-conformance
Conditional conformances for variadic generic types
2023-06-21 17:52:28 -04:00
Slava Pestov
8742b1a1e2 Runtime: Fix shape requirement handling in _checkGenericRequirements()
We would say the shape requirement was always satisfied since we
incorrectly checked the left-hand side type twice.
2023-06-21 15:03:53 -04:00
Slava Pestov
3052e36f7e Runtime: Fix dynamic casts of variadic types that conditionally conform 2023-06-21 13:42:57 -04:00
Slava Pestov
d1cb9307c9 Runtime: Support for conditional conformances with pack conformance requirements 2023-06-21 13:42:57 -04:00
Joe Groff
26d8d84270 Merge pull request #66651 from jckarter/noncopyable-address-only-borrowed-capture
ClosureLifetimeFixup: Remove copy of borrowed move-only nonescaping captures when possible.
2023-06-21 09:36:18 -07:00
Dario Rexin
493a25faae [IRGen+Runtime] Add layout string support for generic single payload enums (#66791) 2023-06-20 20:46:54 -07:00
swift-ci
0845bc1373 Merge pull request #66789 from nate-chandler/rdar111066023
[Test] Marked execution test requires execution.
2023-06-20 20:19:14 -07:00
Nate Chandler
ac6ec58ada [Test] Marked execution test requires execution.
rdar://111066023
2023-06-20 17:16:43 -07:00
Joe Groff
ed2cbca04f ClosureLifetimeFixup: Remove copy of borrowed move-only nonescaping captures when possible.
SILGen introduces a copy of the capture, because the semantics of escaping partial_apply's
requires the closure to take ownership of the parameters. We don't know when a closure is
strictly nonescaping or its final lifetime until ClosureLifetimeFixup runs, but that replaces
the consume of the copy with a borrow of the copy normally, hoping later passes fix it up.
We can't wait that long for move-only types, which can't be copied, so try to remove the
copy up front when the copy lives long enough and has no interfering uses other than the
partial_apply. rdar://110137169
2023-06-20 12:10:31 -07:00
Andrew Trick
a8c45c55c4 Fix MoveOnlyAddressChecker to handle value deinits.
Track liveness of self so we don't accidentally think that such types
can be memberwise reinitialized.

Fixes rdar://110232973 ([move-only] Checker should distinguish in
between field of single field struct vs parent field itself (was:
mutation of field in noncopyable struct should not trigger deinit))
2023-06-19 18:38:03 -07:00
nate-chandler
d3125898ae Merge pull request #66585 from nate-chandler/rdar99681073
[MoveOnlyAddressChecker] Maximize lifetimes.
2023-06-17 14:00:38 -07:00
Nate Chandler
eaf4560cd7 [MoveOnlyAddressChecker] Maximize lifetimes.
Previously, the checker inserted destroys after each last use.  Here,
extend the lifetimes of fields as far as possible within their original
(unchecked) limits.

rdar://99681073
2023-06-16 21:13:09 -07:00