Commit Graph

203 Commits

Author SHA1 Message Date
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
Doug Gregor
0cc529768a Merge pull request #70635 from DougGregor/async-sequence-typed-throws
Adopt typed throws in AsyncIteratorProtocol and AsyncSequence
2024-01-29 11:51:25 -08:00
Michael Gottesman
f077e4a9d7 [region-isolation] Fix the call site or self error for values used in the same region as a function argument.
This is just good to do and also makes it so that in my test case for
assumeIsolated, I get a better msg.
2024-01-25 20:40:56 -08:00
Michael Gottesman
7c79a24a1f [region-isolation] Values that are captured by an actor isolated closures are transferred to that closure.
This commit makes it so that we treat values captured by an actor isolated
closure as being transferred to that closure. I also introduced a new diagnostic
for these warnings that puts the main warning on the capture point of the value
so the user is able to see the actual capture that causes the transfer to occur:

```swift
  nonisolated func testLocal2() async {
    let l = NonSendableKlass()

    // This is not safe since we use l later.
    self.assumeIsolated { isolatedSelf in
      isolatedSelf.ns = l
    }

    useValue(l) // expected-note {{access here could race}}
  }
```

```
test.swift:74:14: warning: main actor-isolated closure captures value of non-Sendable type 'NonSendableKlass' from nonisolated context; later accesses to value could race
    useValue(x) // expected-warning {{main actor-isolated closure captures value of non-Sendable type 'NonSendableKlass' from nonisolated context; later accesses to value could race}}
             ^
test.swift:76:12: note: access here could race
  useValue(x) // expected-note {{access here could race}}
           ^
```

One thing to keep in mind is that if we have a function argument being captured
in this way, we still emit the "call site passes `self`" error. I am going to
begin cleaning that up in the next commit in this PR so that we emit a better
error here. But it makes sense to split these into two separate commits since
they are doing different things.

rdar://121345525
2024-01-25 20:40:56 -08:00
Doug Gregor
e96dcac7b4 Make sure we always have a SILFunction for region-based isolation checking
Some values (such as `undef`) might not be associated with a function.
2024-01-25 16:04:48 -08:00
Michael Gottesman
00f1e1ec33 [region-isolation] Make it so that we only propagate actor self if the callee takes self as isolated.
rdar://121387872
2024-01-23 15:20:23 -08:00
Michael Gottesman
fd14a97033 [region-isolation] Ensure that global actor guarded globals are treated as being actor specific state.
So for instance, one cannot transfer them, just like actor state.
2024-01-19 15:38:41 -08:00
Michael Gottesman
50aaad376b Merge pull request #70836 from gottesmm/transferring-parameter
[region-isolation] Add support for transferring parameters.
2024-01-19 11:10:58 -08:00
Michael Gottesman
23adcbadb9 [region-isolation] Eliminate some UB caused by dereferencing unchecked optionals.
llvm::Optional<T> used to make it so that in asserts builds if one dereferenced the optional and nothing was there, one would get an assert. std::optional<T> does not have that property.
2024-01-18 13:20:28 -08:00
Michael Gottesman
9303c40162 [region-isolation] Teach region isolation that assigning into a transferring parameter is a transfer of the value.
The specific semantics is if we assign into a transferring parameter's field,
then we "merge" src's value into the transferring parameter, so we
conservatively leave the region of the transferring parameter alone. If we
assign over the entire transferring parameter, we perform an assign fresh since
any value that used to be in the transferring parameter cannot reference
anything in its new value since they are all gone.
2024-01-18 13:20:28 -08:00
Michael Gottesman
26a75fe5e6 [region-isolation] Implement checking for transferring parameters.
NOTE: This does not handle yet assignment into transferring parameters. In the
next commit, I am going to teach the checker that assigning into such a
parameter is a transfer.
2024-01-18 13:20:28 -08:00
Michael Gottesman
861d9678ed [region-isolation] Add support for value_to_bridge_object. 2024-01-17 16:39:35 -08:00
Michael Gottesman
9b9102bef2 [region-isolation] Add support for autorelease_value. 2024-01-17 15:18:53 -08:00
Michael Gottesman
d514c6eb7d [region-isolation] Make it harder for instruction classification and looking for base values through LookThrough insts to get out of sync.
To ensure that we preserve the correct behavior here, I added classification
helper functions that classify if an instruction can be look through. I used
this to drive the find base value code and added in asserts in the instruction
classifier to ensure that if an instruction is ever classified as LookThrough,
one of the helper routines handles it.
2024-01-17 14:50:52 -08:00
Michael Gottesman
5aec06fb75 [region-isolation] Add support for is_unique. 2024-01-17 14:19:59 -08:00
Michael Gottesman
855b9ff376 [region-isolation] Add support for drop_deinit. 2024-01-17 14:14:47 -08:00
Michael Gottesman
38dd567e6d [region-isolation] Add support for bridge_object_to_word. 2024-01-17 14:09:47 -08:00
Michael Gottesman
d10346bd98 [region-isolation] Add support for unowned_copy_value. 2024-01-17 14:08:37 -08:00
Michael Gottesman
dadc16bf94 [region-isolation] Add support for classify_bridge_object. 2024-01-17 14:07:48 -08:00
Michael Gottesman
872edea4a0 [region-isolation] Add support for debug_step. 2024-01-17 14:07:32 -08:00
Michael Gottesman
f6d7983632 [region-isolation] Add support for ref_to_unowned and unowned_to_ref. 2024-01-17 14:05:55 -08:00