diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2023-02-15 12:24:55 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-15 12:24:55 +0530 |
| commit | c78e3c735aff8aa9bad9cd2dc46b5fdbf4ca1af6 (patch) | |
| tree | 70b814539bb7b7ff9c4c7b10f400611d93099804 /compiler/rustc_codegen_llvm/src | |
| parent | a110cf5d1649aa920c046c764c28c666ebdd85cd (diff) | |
| parent | 09797a463cd1bc70bc439aaf0c94b7b5a80f5bfb (diff) | |
| download | rust-c78e3c735aff8aa9bad9cd2dc46b5fdbf4ca1af6.tar.gz rust-c78e3c735aff8aa9bad9cd2dc46b5fdbf4ca1af6.zip | |
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.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions
