Commit Graph

173 Commits

Author SHA1 Message Date
Michael Gottesman
f06244f397 [region-isolation] Take into account that Swift's RPO order doesn't include blocks that are dead.
When we run RegionAnalysis, since it uses RPO order, we do not visit dead
blocks. This can create a problem when we emit diagnostics since we may merge in
a value into the region that was never actually defined. In this patch, if we
actually visit the block while performing dataflow, I mark a bit in its state
saying that it was live. Then when we emit diagnostics, I do not visit blocks
that were not marked live.

rdar://124042351
2024-03-04 17:09:51 -08:00
Michael Gottesman
2f353b815e [region-isolation] Only make partial_apply actor derived if we capture an isolated parameter... not just any actor.
Before I couldn't do this since, @sil_isolated was not represented on
partial_applies. Since in the previous commit, I added support to the compiler
to represent this, I can now limit this query so now one can pass an actor
instance outside of its method to a nonisolated non-Sendable partial apply.
Since it is Sendable, it is always safe to do this since we are passing the
actor.

rdar://123881277
2024-03-01 11:54:16 -08:00
Michael Gottesman
6eb31b42b1 [region-isolation] Assigning into a transferring parameter should be a store, not a transfer.
rdar://123865943
2024-02-29 16:20:00 -08:00
Michael Gottesman
1776ce4820 [region-isolation] Make sure that we can handle an async let without any captures correctly.
Previously, we assumed we would always have a partial_apply. In the case where
we do not capture any values this is not true since we instead have a
thin_to_thick_function.
2024-02-27 14:10:15 -08:00
Michael Gottesman
3b9d4523cc [transferring] Make sure to enable strict-concurrency on the tests as well as our experimental features.
Just noticed this while trying to write some tests that validated that we were
properly ignoring strict-concurrency features. I put in asserts to validate that
when either of these are enabled, we have strict-concurrency set as well.
2024-02-27 13:35:22 -08:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Nate Chandler
6b0fc181d5 [NFC] Removed imports of MemoryLocations.h.
Make it clear that this is only used by the MemoryVerifier (and the
disabled old DestroyHoisting).
2024-02-19 11:41:38 -08:00
Nate Chandler
600164257a [NFC] Moved SmallBitVector dumping to Basic.
Moved out of MemoryLocations.h and merged the implementations of <<,
keeping the version from MemoryLocations with its brackets and commas
available via a flag but defaulting the implementation previously in the
header.
2024-02-19 11:41:38 -08:00
Michael Gottesman
40cd98794d [region-isolation] Always require before transferring.
We purposely do not treat a PartitionOpKind::Transfer as a require since that
would cause us to error when we weakly transfer the same parameter multiple
times to the same function. This is safe since all of the function parameters
will be in the same region.

To ensure that this fixed the multiple strong transferring issue (which is
exposed by requiring before transferring), I also had to muck around a little
with how we emit errors to ensure that we emit errors if the transfer
instruction is also the require.
2024-02-14 14:39:02 -08:00
Michael Gottesman
f3edb5730a [transferring] Add support for transferring results.
rdar://121324697
2024-02-14 14:39:02 -08:00
Michael Gottesman
bf2ec7eb85 [transferring] Change transferring to no longer be a ParamSpecifier.
Instead it is a bit on ParamDecl and SILParameterInfo. I preserve the consuming
behavior by making it so that the type checker changes the ParamSpecifier to
ImplicitlyCopyableConsuming if we have a default param specifier and
transferring is set. NOTE: The user can never write ImplicitlyCopyableConsuming.

NOTE: I had to expand the amount of flags that can be stored in ParamDecl so I
stole bits from TypeRepr and added some logic for packing option bits into
TyRepr and DefaultValue.

rdar://121324715
2024-02-14 13:04:46 -08:00
John McCall
d5142668f4 SIL and IRGen support for @isolated(any). SILGen to come. 2024-02-13 03:04:13 -05:00
Michael Gottesman
1795f7f661 Merge pull request #71429 from gottesmm/fixes-for-stdlib
[region-isolation] Fixes that enable the stdlib to build with region based isolation
2024-02-07 09:47:11 -08:00
Michael Gottesman
1e4fe6c4ea [region-isolation] Do not transfer @out parameters!
Instead treat them as actual results.
2024-02-06 18:14:34 -08:00
Michael Gottesman
501158450e [region-isolation] Handle (project_box (load %boxAddr)) correctly.
I thought that we would never actually hit this test case, but since we do not
have opaque values this pattern is treated like a projection in certain cases. I
updated the code as appropriate and added a test.
2024-02-06 18:05:05 -08:00
Michael Gottesman
6200a3bc4c [region-isolation] Fix a thinko.
project_box's type is not a box type... it is the type contained in the box.
2024-02-06 17:49:58 -08:00
Michael Gottesman
b2f1c41213 [region-isolation] get_async_continuation{,_addr} can take a parameter, so we need to treat it as a require.
We should make this as a transfer... but this is just temporary until I get
around to it. For now this is always an out parameter, so we should be safe.
2024-02-06 17:49:03 -08:00
Michael Gottesman
e34dc59cea [region-isolation] When asserting about a bad inst, print the inst out to ease debugging. 2024-02-06 16:57:47 -08:00
Michael Gottesman
dd7f5ec11d [region-isolation] Handle ref_to_bridge_object especially.
I was correct that it is lookthrough, but it has multiple parameters, so the
normal "baked" implementation cannot be used since the "baked" implementation
assumes that any insts it handles has a single operand.
2024-02-06 16:57:34 -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
Michael Gottesman
4bed671820 [region-isolation] Now that we support all instructions, remove Unhandled... all future instructions added must be handled! 2024-02-02 14:50:10 -08:00
Michael Gottesman
7d13d27685 [region-isolation] Add support for init_existential_value. 2024-02-02 14:50:10 -08:00
Michael Gottesman
9b686f564f [region-isolation] Add support for strong_copy_unmanaged_value.
I also made ref_to_unmanaged and unmanaged_to_ref look through. They should have
always been look through, but I believe early on they were marked assign and I
never touched fixed it. To get the test for strong_copy_unmanaged_value to work,
I needed them to obey these semantics so I fixed them at the same time.
2024-02-02 14:50:10 -08:00
Michael Gottesman
40c1120a6e [region-isolation] Add support for strong_copy_weak_value. 2024-02-02 14:50:10 -08:00
Michael Gottesman
7d4f8c261a [region-isolation] Add support for weak_copy_value. 2024-02-02 14:50:10 -08:00
Michael Gottesman
ab3204b610 [region-isolation] Add support for metatype instructions. 2024-02-02 14:50:10 -08:00
Michael Gottesman
34dcb8d48c [region-isolation] Add support for load_unowned. 2024-02-02 14:50:10 -08:00
Michael Gottesman
62c6ed2c77 [region-isolation] Add support for open_existential_value. 2024-02-02 14:50:10 -08:00
Michael Gottesman
4bba1942b1 [region-isolation] Add support for differentiability instructions. 2024-02-02 14:50:10 -08:00
Michael Gottesman
347310835a [region-isolation] Make vector asserting since we should never see it.
It can only be in a global variable static initializer list which we do not run
on.
2024-02-02 14:50:10 -08:00
Michael Gottesman
e42b112f53 [region-isolation] Add support for {begin,end}_unpaired_access. 2024-02-02 14:50:10 -08:00
Michael Gottesman
12e4e8d6e8 [region-isolation] Add support for all pack instructions. 2024-02-02 14:50:10 -08:00
Michael Gottesman
feec25cb05 [region-isolation] Mark get_async_continuation{,addr} and extract_executor as AssertingIfNonSendable. 2024-02-02 14:50:10 -08:00
Michael Gottesman
4414636f5f [region-isolation] Add support for bind_memory and rebind_memory. 2024-02-02 14:50:10 -08:00
Michael Gottesman
62a64d3b37 [region-isolation] Update for throw_addr.' 2024-02-02 14:50:10 -08:00
Michael Gottesman
45bb16764e [region-isolation] Add support for await_async_continuation. 2024-02-02 14:50:10 -08:00
Michael Gottesman
4218f5b79d [region-isolation] Teach the checker about unmanaged {retain, release, autorelease}. 2024-02-02 14:50:10 -08:00
Michael Gottesman
0cfe58cca1 [region-isolation] Mark all assign_* variants as asserting since they should be eliminated by DI before we run. 2024-02-02 14:50:10 -08:00
Michael Gottesman
3cacb1f86d [region-isolation] Add support for mark_function_escape. 2024-02-02 14:50:10 -08:00
Michael Gottesman
e3274b34ad [region-isolation] Move unhandled pack instructions away from the rest of unhandled instructions. 2024-02-02 14:50:10 -08:00
Michael Gottesman
3acdc09895 [region-isolation] Add support for test_specification_inst. 2024-02-01 21:23:06 -08:00
Michael Gottesman
ce32a8dbe8 [region-isolation] Add support for store_unowned. 2024-02-01 21:22:25 -08:00
Michael Gottesman
531154c504 [region-isolation] Ignore deinit_existential_{addr,value}. They do not matter from a region perspective. 2024-02-01 21:21:51 -08:00
Michael Gottesman
4b4495bd71 [region-isolation] Mark dealloc_{ref,stack_ref,partial_ref} as ignored.
We do not care about them.
2024-02-01 21:21:18 -08:00
Michael Gottesman
0cd57e4431 [region-isolation] Add support for unconditional_checked_cast_addr. 2024-02-01 21:20:48 -08:00
Michael Gottesman
02ad3dedcb [region-isolation] Add support for unchecked_ref_cast_addr. 2024-02-01 21:20:20 -08:00
Michael Gottesman
b107a18f68 [region-isolation] Handle BeginCowMutation. 2024-02-01 21:19:52 -08:00
Michael Gottesman
3ffe5c5dff [region-isolation] Add increment_profiler_counter support. 2024-01-29 21:34:41 -08:00
Michael Gottesman
86ef55542c [region-isolation] Clean up the handling of ref_element_addr let for Sendable types.
Specifically, if we access a Sendable type from a ref_element_addr and the field
is mutable, we need to treat the use as a require since we could race on writing
to the field. If the field is a let though (and thus immutable), we can still
ignore it.

I also used this as an opportunity to add SIL tests for ref_element_addr.
2024-01-29 21:34:41 -08:00
Michael Gottesman
edf4543b0c [region-isolation] Add support for ref_tail_addr. 2024-01-29 21:34:41 -08:00