rust/tests/mir-opt/dataflow-const-prop
Dylan DPC c78e3c735a
Rollup merge of #107411 - cjgillot:dataflow-discriminant, r=oli-obk
Handle discriminant in DataflowConstProp

cc ``@jachris``
r? ``@JakobDegen``

This PR attempts to extend the DataflowConstProp pass to handle propagation of discriminants. We handle this by adding 2 new variants to `TrackElem`: `TrackElem::Variant` for enum variants and `TrackElem::Discriminant` for the enum discriminant pseudo-place.

The difficulty is that the enum discriminant and enum variants may alias each another. This is the issue of the `Option<NonZeroUsize>` test, which is the equivalent of https://github.com/rust-lang/unsafe-code-guidelines/issues/84 with a direct write.

To handle that, we generalize the flood process to flood all the potentially aliasing places. In particular:
- any write to `(PLACE as Variant)`, either direct or through a projection, floods `(PLACE as OtherVariant)` for all other variants and `discriminant(PLACE)`;
- `SetDiscriminant(PLACE)` floods `(PLACE as Variant)` for each variant.

This implies that flooding is not hierarchical any more, and that an assignment to a non-tracked place may need to flood a tracked place. This is handled by `for_each_aliasing_place` which generalizes `preorder_invoke`.

As we deaggregate enums by putting `SetDiscriminant` last, this allows to propagate the value of the discriminant.

This refactor will allow to make https://github.com/rust-lang/rust/pull/107009 able to handle discriminants too.
2023-02-15 12:24:55 +05:30
..
cast.main.DataflowConstProp.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
cast.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
checked.main.DataflowConstProp.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
checked.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
enum.mutate_discriminant.DataflowConstProp.diff Handle discriminants in dataflow-const-prop. 2023-02-06 21:51:47 +00:00
enum.rs Handle discriminants in dataflow-const-prop. 2023-02-06 21:51:47 +00:00
enum.simple.DataflowConstProp.diff Handle discriminants in dataflow-const-prop. 2023-02-06 21:51:47 +00:00
if.main.DataflowConstProp.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
if.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
inherit_overflow.main.DataflowConstProp.diff Remove both StorageLive and StorageDead in CopyProp. 2023-01-31 17:50:04 +00:00
inherit_overflow.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_81605.f.DataflowConstProp.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
issue_81605.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ref_without_sb.main.DataflowConstProp.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
ref_without_sb.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
repr_transparent.main.DataflowConstProp.diff Bless tests. 2023-02-02 23:26:26 +00:00
repr_transparent.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
self_assign.main.DataflowConstProp.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
self_assign.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
self_assign_add.main.DataflowConstProp.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
self_assign_add.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
sibling_ptr.main.DataflowConstProp.diff Clearly document intentional UB in mir-opt tests 2023-02-13 13:50:50 -05:00
sibling_ptr.rs Clearly document intentional UB in mir-opt tests 2023-02-13 13:50:50 -05:00
struct.main.DataflowConstProp.diff Bless tests. 2023-02-02 23:26:26 +00:00
struct.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
terminator.main.DataflowConstProp.diff Move /src/test to /tests 2023-01-11 09:32:08 +00:00
terminator.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00
tuple.main.DataflowConstProp.diff Bless tests. 2023-02-02 23:26:26 +00:00
tuple.rs Move /src/test to /tests 2023-01-11 09:32:08 +00:00