Commit Graph

9332 Commits

Author SHA1 Message Date
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
Nate Chandler
c11a2cef91 [NFC] LifetimeCompletion: Fix switch order.
Match the declaration order.
2024-05-08 17:15:14 -07:00
Nate Chandler
de5d2ece86 [NFC] LifetimeCompletion: Improve lambda name.
This lambda has to do with availability or the lack thereof but
unreachable instructions are of interest in this context so using the
wrong name confuses things unnecessarily.
2024-05-08 17:15:14 -07:00
Nate Chandler
a0b8324eb3 [Test] Used underscores in test name.
Makes it easier to search for since editors will see it as a single
name.
2024-05-08 17:15:14 -07:00
Ellie Shin
0f606e76cb Merge pull request #73478 from apple/elsh/pcmo-res
Support generating loadable types in serialized function when package-cmo is enabled.
2024-05-08 16:08:13 -07:00
Adrian Prantl
9a2e245678 Merge pull request #73504 from Snowy1803/rdar127348128
[DebugInfo] Fix verifier crash for complex switch
2024-05-08 16:06:00 -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
6136183c33 [DebugInfo] Fix loss of VarDecl in debug values for salvaged stores
When a store is salvaged, its debug_value will have two locations:
the location of the store, attached to the debug_value instruction,
and the location of the variable, attached to the SILDebugVariable.

The getDecl function was using the location of the store, instead
of the location of the variable, and so was returning nullptr.
2024-05-07 14:34:18 -07:00
Emil Pedersen
4bc672e7c1 [DebugInfo] Deduplicate location and scope in debug variables (NFC) 2024-05-07 13:58:57 -07:00
nate-chandler
e805679c76 Merge pull request #73460 from nate-chandler/gh73252
[Test] Reenable SIL unit tests on windows.
2024-05-07 10:15:11 -07:00
Nate Chandler
c84e196b16 [Test] Reenable SIL unit tests on windows.
Use `fflush(stdout)` from C++.

Issue 73252.
2024-05-06 12:20:16 -07:00
Erik Eckstein
b636da1716 SILVerifier: be more tolerant if errors were detected in diagnostic passes
SIL cannot be assumed to be 100% valid if errors were detected in diagnostic passes. For example in DefiniteInitialization.

Fixes some false verifier errors in case -sil-verify-all is used.

rdar://127519229
rdar://127518886
2024-05-06 16:06:36 +02:00
nate-chandler
bcd08c0c9a Merge pull request #73235 from nate-chandler/bitwise-copyable/enable
[BitwiseCopyable] Promote to feature.
2024-05-04 10:16:40 -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
Slava Pestov
625436af05 Merge pull request #73393 from slavapestov/pack-expansion-closures-part-3
SIL type lowering support for closures that capture pack element archetypes
2024-05-02 19:43:24 -04:00
Emil Pedersen
bf58b030c5 Merge pull request #73387 from Snowy1803/allocbox-fix
[DebugInfo] Fix loss of variables at -Onone
2024-05-02 12:39:17 -07:00
Slava Pestov
fa89c52556 SIL: Introduce TypeConverter::getForwardingSubstitutionsForLowering() 2024-05-02 14:28:30 -04:00
Slava Pestov
fa2cd6cbcc SIL: Support element archetypes inside lowerCaptureContextParameters() 2024-05-02 13:40:54 -04:00
Slava Pestov
1cad5f9350 SIL: Plumb pack element captures through type lowering 2024-05-02 13:40:54 -04:00
Slava Pestov
70fb18e799 SIL: Rename misleading getFunctionInterfaceTypeWithCaptures() 2024-05-02 13:40:54 -04: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
9e13db09e0 SIL: buildThunkType() uses (new) LocalRequirementArchetypeCollector 2024-05-01 15:35:24 -04:00
Nate Chandler
2ca995177c [NFC] LifetimeCompletion: Lift default a level. 2024-05-01 08:57:01 -07: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
fcd25ead54 [NFC] LifetimeCompletion: Clarify doc and code. 2024-05-01 08:57:00 -07:00
Nate Chandler
9c16318ad9 [NFC] LifetimeCompletion: Simplified enum wrapper. 2024-05-01 08:57:00 -07:00
Slava Pestov
865b155f2e SIL: Thunks that capture local environments must also capture the primary environment
I suspect there are latent bugs here with generic-class-constrained existentials,
same-element requirements involving packs, etc. We can't assume that the
local archetypes don't have "hidden" dependencies on the outer parameters
that are not encoded in the thunk's interface type.
2024-04-30 22:45:41 -04:00
Slava Pestov
97d95218f8 AST: Record captured generic environments in CaptureInfo 2024-04-30 21:38:15 -04:00
Emil Pedersen
f6232a937d [DebugInfo] Fix wrong scope being used in AllocBoxToStack 2024-04-30 16:29:49 -07:00
Akira Hatanaka
428fe21855 [SILGen] Fix a bug where the wrong convention was being used for computing the type of a closure thunk (#73299)
The ObjC selector family convention was being used instead of the C
function type convention.

rdar://127090209
2024-04-29 18:03:59 -07:00
nate-chandler
30fa15a01b Merge pull request #73278 from nate-chandler/lifetime-completion/20240425/2
[SIL] Only verify ownership when not disabled.
2024-04-26 07:00:46 -07:00
Nate Chandler
640e3986f9 [SIL] Only verify ownership when not disabled.
The option -disable-sil-ownership-verifier should almost never be used.
But if it is, it should result in ownership verification being disabled,
even when done via direct calls to `SILFunction::verifyOwnership`.

There are still a couple of test cases that use
-disable-sil-ownership-verifier.
2024-04-25 18:06:29 -07: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
Nate Chandler
121b2faccc [NFC] SIL: Add ValueBase::isBeginApplyToken.
Forwards to the member function of the same name on
MultipleValueInstructionResult.
2024-04-25 17:03:11 -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
b1fbe4ea91 [BitwiseCopyable] Remove underscore. 2024-04-25 11:44:15 -07:00
Emil Pedersen
00a93d939c Fix inverted condition in MemoryLifetimeVerifier 2024-04-24 18:23:39 -07:00
Nate Chandler
ed5c7ef7ae [BitwiseCopyable] Promote to feature.
SE-0426 was accepted.
2024-04-24 15:52:20 -07:00
Michael Gottesman
e85dfbd043 Merge pull request #73202 from gottesmm/move-error
[region-isolation] When RegionIsolation is enabled, delay the preconcurrency import not used diagnostic to the SIL pipeline.
2024-04-23 16:11:48 -05:00
Michael Gottesman
025902fa99 [sil] Add a SILDeclRef field to SILFunction, have SILGen set it, and teach SILFunction how to use the field to get the SourceFile associated with the SILFunction. 2024-04-23 11:45:36 -05:00
nate-chandler
1a0a44c9a0 Merge pull request #73174 from nate-chandler/rdar126863003
[MoveOnlyAddressChecker] Fix empty deiniting struct representation.
2024-04-22 15:38:28 -07:00
Ellie Shin
3f047102c2 Merge pull request #72937 from apple/elsh/pkg-sil-verify
Add a package serialization bit to Module for SIL verifier in Package CMO mode.
2024-04-22 12:44:28 -07:00
nate-chandler
a354528321 Merge pull request #73155 from nate-chandler/lifetime-completion/20240419/1
[LifetimeCompletion] Don't destroy alloc_boxes.
2024-04-22 11:33:36 -07:00
Yuta Saito
ae74a57345 Merge pull request #73162 from kateinoigakukun/yt/indirect-err-result-conv 2024-04-23 00:50:02 +09:00
Nate Chandler
5325a4d5f8 [MoveOnlyAddressChecker] Fix empty struct repr.
An empty struct without a deinit gets a single bit which is used to
track the struct's liveness.  Previously, an empty struct with a deinit
also only got a single bit.  Consequently, when discarding the struct
(i.e. dropping the deinit), there was no bit left to represent the
struct.  This resulted in a failure to track liveness for the value.

rdar://126863003
2024-04-22 08:42:14 -07:00
nate-chandler
1faeb50fff Merge pull request #73121 from nate-chandler/rdar126715654
[NoncopyablePartialConsumption] Promote to feature.
2024-04-22 07:01:10 -07:00
Nate Chandler
6a01bf4d70 [LifetimeCompletion] Don't destroy alloc_boxes.
A destroy_value of an alloc_box unconditionally destroys the value
within the box.  On unreachable paths, such memory may not be
initialized, so it cannot be destroyed unconditionally.  Moreover,
destroying values stored in memory is outside the purview of OSSA
lifetime completion.
2024-04-21 20:56:39 -07:00