Commit Graph

11193 Commits

Author SHA1 Message Date
Michael Gottesman
9bfb3b7ee7 [region-isolation] Some small gardening updates in preparation for the next commit.
Specifically, I added a few helper methods and improved the logging printing.
This all makes the next commit a more focused commit.
2024-05-10 15:33:44 -07:00
Kuba (Brecka) Mracek
829f442e84 Merge pull request #70441 from kubamracek/embedded-diagnose-alloc-ref-dynamic
[embedded] Start flagging AllocRefDynamicInst usage in embedded Swift
2024-05-10 08:55:27 -07:00
Kshitij Jain
01654fd323 Merge pull request #71775 from jkshtj/main
[Autodiff] Adds part of the Autodiff specific closure-specialization optimization pass
2024-05-10 08:51:01 -07:00
nate-chandler
e74cfb02ae Merge pull request #73386 from nate-chandler/lifetime-completion/20240501/2
[LifetimeCompletion] Require boundary to be specified.
2024-05-10 07:18:22 -07:00
Emil Pedersen
784034fd3a [DebugInfo] Fix scope mapping in ClosureCloner 2024-05-09 15:01:17 -07:00
Joe Groff
2d61e3d26b Merge pull request #73531 from jckarter/forwarding-force-unwrap
SILGen: Treat Optional `x!` force unwrapping as a forwarding operation.
2024-05-09 08:35:29 -07:00
Nate Chandler
284262dad1 [SILGenCleanup] Handle leaky OSSA.
Use the new AvailabilityWithLeaks boundary.
2024-05-08 17:15:15 -07:00
Nate Chandler
632406762c [LifetimeCompletion] Add availability_with_leaks.
The new boundary allows for invalid OSSA where values are not consumed
on paths leading to blocks that exit the function normally.  In such
cases, the value is allowed to continue leaking as before.
2024-05-08 17:15:15 -07:00
Nate Chandler
518de7c6b1 [LifetimeCompletion] Require boundary spec.
Don't default to one boundary or another based on whether the value
being completed is lexical.
2024-05-08 17:15:15 -07:00
Emil Pedersen
7c9676e890 [DebugInfo] Fix var info after DeadObjectElimination
The scope of a store has to be the variable's scope.
The type should be set to the element's type, and only if not already set.
The variable's location should be set.
2024-05-08 16:43:34 -07:00
Joe Groff
82e566a23a SILGen: Treat Optional x! force unwrapping as a forwarding operation.
Like `?` or property access, `x!` can be borrowing, consuming, or mutated
through depending on the use site and the ownership of the base value.
Alter SILGen to emit `x!` as a borrowing operation when the result is only
used as a borrow. Fix the move-only checker not to treat the unreachable
branch as a dead path for values and try to destroy the value unnecessarily
and possibly out-of-order with cleanups on the value. Fixes rdar://127459955.
2024-05-08 15:35:07 -07:00
Ellie Shin
9b28969e2d To support serializing functions containing loadable types in a resiliently built
module when package serialization is enabled, return maximal resilience expansion
in SILFunction::getResilienceExpansion(). This allows aggregate types to be generated
as loadable SIL types which otherwise are address-only in a serialized function.
During type lowering, opaque flag setting is also skipped if package serialization
is enabled.

Resolves rdar://127400743
2024-05-08 05:01:25 -07:00
Emil Pedersen
3003155fb1 Merge pull request #73404 from Snowy1803/phixpansion
[DebugInfo] Fix PhiExpansion losing debug info
2024-05-06 10:17:55 -07:00
Michael Gottesman
787bb7d249 [region-isolation] Create a non-"callee" kind of error for async let.
I am doing this separately from the previous fix for just normal region
isolation since without transferring args and results enabled, we do not hit
this code path. But since I am here, I want to fix it at the same time.

rdar://127588005
2024-05-05 22:39:59 -07:00
Michael Gottesman
6a53e9a3f4 Merge pull request #73446 from gottesmm/rdar127580781
[region-isolation] Some diagnostic tweaks
2024-05-05 22:21:36 -07:00
Michael Gottesman
58fd432e6c Remove clang optimize off and loosen an error in the swift-version test. 2024-05-05 19:33:11 -07:00
Michael Gottesman
a933c14b77 [region-isolation] Only print the type of region that a value is in if it is not disconnected.
Just another diagnostic tweak.
2024-05-05 18:01:05 -07:00
Michael Gottesman
0b761109e2 [region-isolation] If we can infer the callee's name, use that instead of just saying 'callee'.
I also wordsmithed the error message to use the term 'risk' instead of less
negative terms.
2024-05-05 18:01:05 -07:00
nate-chandler
768b3a4944 Merge pull request #73422 from nate-chandler/rdar127502242
[SIL] Hollow out Builtin.copy and deprecate _copy.
2024-05-03 22:19:47 -07:00
Nate Chandler
06921cfe84 [SIL] Hollow out Builtin.copy, deprecate _copy.
The copy operator has been implemented and doesn't use it.  Remove
`Builtin.copy` and `_copy` as much as currently possible.

Source compatibility requires that `_copy` remain in the stdlib.  It is
deprecated here and just uses the copy operator.

Handling old swiftinterfaces requires that `Builtin.copy` be defined.
Redefine it here as a passthrough--SILGen machinery will produce the
necessary copy_addr.

rdar://127502242
2024-05-03 15:56:25 -07:00
Emil Pedersen
b944e38ec3 [DebugInfo] Fix PhiExpansion losing debug info
When replacing a struct with its field, it now emits a debug_value
with a fragment, instead of dropping the debug_value.
2024-05-03 14:46:04 -07:00
Nate Chandler
54ebff3de9 [SILCombine] Handle indirect error in apply(conv).
Previously, only the indirect results and the parameters were handled.
However, the indirect error doesn't show up in the list of indirect
results (or in the list of parameters).  But it sure does show up in the
list of arguments.  Here, that argument too is handled.

rdar://127452206
2024-05-03 08:06:21 -07:00
Nate Chandler
30d779e946 [Test] Added sil_combine_instruction. 2024-05-03 08:06:21 -07:00
Kshitij
c6330a7d3f Rev: Addressed feedback 2024-05-02 13:16:12 -07:00
Kshitij
fd609846ae Makes the swift-based closure-spec pass an experimental frontend feature 2024-05-02 09:14:05 -07:00
Kshitij
a7f8d6c647 [Autodiff] Adds bridging code in preparation for the Swift based Autodiff closure-spec pass 2024-05-02 09:14:05 -07:00
Joe Groff
73ed03c827 Merge pull request #73380 from jckarter/mark-captured-no-implicit-copy-parameters
Consistently mark `borrowing` and `consuming` parameters for move-only checking when captured.
2024-05-02 08:56:10 -07:00
Erik Eckstein
c7f35f99ef SILCombine: remove dead string.init_empty_with_capacity semantic calls
This avoids leftover runtime calls for constant folded large interpolated strings.

rdar://127308237
2024-05-02 10:49:33 +02:00
Emil Pedersen
d451c3e4e1 Merge pull request #73334 from Snowy1803/unified-lost-vars-statistics
Add compile flag for lost debug variables statistics
2024-05-01 18:03:32 -07:00
nate-chandler
d5aafbcdad Merge pull request #73368 from nate-chandler/lifetime-completion/20240501/1
[NFC] LifetimeCompletion: Clarified API and documentation.
2024-05-01 18:02:46 -07:00
Slava Pestov
fda93680df Merge pull request #73363 from slavapestov/pack-expansion-closures-part-2
Extract common code for building opened existential and element signatures
2024-05-01 19:44:05 -04:00
Joe Groff
90e1ecb864 Consistently mark borrowing and consuming parameters for move-only checking when captured.
When a `borrowing` or `consuming` parameter is captured by a closure,
we emit references to the binding within the closure as if it is non-implicitly
copyable, but we didn't mark the bindings inside the closure for move-only
checking to ensure the uses were correct, so improper consumes would go
undiagnosed and lead to assertion failures, compiler crashes, and/or
miscompiles. Fixes rdar://127382105
2024-05-01 13:41:28 -07:00
Slava Pestov
7da488663c SILOptimizer: Use getNextDepth()/getMaxDepth() 2024-05-01 12:09:01 -04:00
Nate Chandler
5383df755a [NFC] LifetimeCompletion: Clarify modes.
Completion is done along a boundary, either the availability or the
liveness boundary.  Represent which with a type.  Update docs and names.
2024-05-01 08:57:01 -07:00
nate-chandler
bb502c5cb8 Merge pull request #73358 from nate-chandler/rdar127190151
[MoveOnlyAddressChecker] Don't complete reborrows or their adjacent phis.
2024-04-30 22:46:24 -07:00
Michael Gottesman
f1539f1b64 Merge pull request #73304 from gottesmm/pr-0f53738606af56510a700d55dbd3a83360da595e
[region-isolation] Look through actor isolated, non-Sendable struct_element_addr geps.
2024-04-30 17:17:56 -07:00
Nate Chandler
7009a18cc4 [MoveOnlyAddressChecker] Don't complete phis.
After 874971c40d, before running address
checking, all lifetimes in the function are completed.  That doesn't
quite work because lifetime completion expects not to encounter
reborrows or their adjacent phis.
2024-04-30 16:52:01 -07:00
Michael Gottesman
077f62c93d Fix how we look through (or not) and find the isolation ofunchecked_take_enum_data_addr/struct_element_addr fields. 2024-04-30 14:01:32 -07:00
Emil Pedersen
59d0bd4f64 Add compile flag for lost debug variables statistics 2024-04-29 18:38:37 -07:00
Emil Pedersen
ce68d74025 Merge pull request #73276 from Snowy1803/doc-and-fixes
[DebugInfo] Improve documentation & Fix discovered bugs
2024-04-29 10:22:46 -07:00
Emil Pedersen
16c57aefcd [DebugInfo] Salvage integer literals 2024-04-26 16:31:16 -07:00
Emil Pedersen
c2c16f53dd [DebugInfo] Fix undef debug values being removed 2024-04-26 16:31:16 -07:00
Michael Gottesman
14f5623bbc [region-isolation] Look through actor isolated, non-Sendable struct_element_addr geps.
Just an initial commit. Going to add more tests.

rdar://127006035.
2024-04-26 17:50:13 -05:00
Nate Chandler
29d046fa42 [SIL] Add BorrowedValueKind::BeginApplyToken.
The token is a guaranteed value introduced by the begin_apply and
consumed by its end_apply, abort_apply, and end_borrow users.
2024-04-25 17:03:43 -07:00
Nate Chandler
5307ac666e [SIL] Permit end_borrow(begin_apply). 2024-04-25 17:03:41 -07:00
Emil Pedersen
a31d15c438 Merge pull request #72964 from Snowy1803/mem2reg-salvage-store
[DebugInfo] Salvage all stores
2024-04-25 16:52:37 -07:00
nate-chandler
7b45597761 Merge pull request #73195 from nate-chandler/lifetime-completion/20240422/1
[SIL] Verify complete lifetimes when option set.
2024-04-25 14:51:07 -07:00
nate-chandler
49dd95fae3 Merge pull request #73240 from nate-chandler/rdar127013278
[LICM] Bail on unreferenceable storage.
2024-04-25 07:00:39 -07:00
Emil Pedersen
450db6e530 [DebugInfo] Add special cases for copy forwarding 2024-04-24 18:23:39 -07:00
Nate Chandler
7753b0fa78 [LICM] Bail on unrefable storage.
When computing an access path, if a struct with unreferenceable storage
is encountered, bail out.  Otherwise, an attempt will be made to
construct such a struct via the struct instruction which isn't possible.

rdar://127013278
2024-04-24 18:04:21 -07:00