Commit Graph

17 Commits

Author SHA1 Message Date
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
Michael Gottesman
c49fb33d29 [region-isolation] Change look through check to use a switch instead of an isa list.
I am doing this because I discovered that mark_dependence was being
misclassified as assigned even though we wanted to treat it as being look
through in its first operand and since I kept on hitting merge conflicts with
the isa list option.

With this commit:

1. I am converting it to a switch in a utility function. That should prevent the
merge conflicts.

2. I also fixed mark_dependence's semantics.

3. I added an assert into CONSTANT_TRANSLATION(..., LookThrough) to make sure
that the switch and the CONSTANT_TRANSLATION code stays in sync.
2024-01-17 14:03:11 -08:00
Michael Gottesman
053e30d46d [region-isolation] Make sure not to run RegionAnalysis on functions that we do not support.
Before this commit, this was done at the beginning of TransferNonSendable. I
thought that those checks would be sufficient to ensure that
RegionAnalysisFunctionInfo was not created for functions that we do not
support. Turns out when we perform certain forms of verification, we force all
function analyses to be created for all functions meaning that we would create a
RegionAnalysisFunctionInfo for such an unsupported function causing us to hit
asserts.

In this commit, I move the check to whether or not we support a function into
RegionAnalysisFunctionInfo itself and use that to determine if we should run
TransferNonSendable. This additionally allows me to change
RegionAnalysisFunctionInfo so that one can construct one for an unsupported
function... as long as one doesn't actually touch any of its methods. If one
does, I put in an assert so we will know that operator error has occured.
2024-01-10 13:41:12 -08:00
Michael Gottesman
a9dc4ed6cc [region-isolation] Refactor out the Region analysis from TransferNonSendable.
NFCI. This is just a pure refactor of the analysis part of TransferNonSendable
into a separate SIL level analysis so it can be reused by other passes.

The reason that I am committing this earlier is that I am working concurrently
on other patches that change TransferNonSendable itself and I want to avoid
issues when rebasing those patches. Getting this patch into tree earlier avoids
that.

This is in preparation for adding a new flow sensitive initialization pass that
combines region based analysis with the current flow sensitive isolation's
diagnostic emitter. The idea is that we want to preserve the diagnostics from
that pass rather than try to make our own as an initial step.
2024-01-10 13:41:12 -08:00