Skip to content

Commit

Permalink
Rollup merge of rust-lang#107687 - cjgillot:sroa-2, r=oli-obk
Browse files Browse the repository at this point in the history
Adapt SROA MIR opt for aggregated MIR

The pass was broken by rust-lang#107267.

This PR extends it to replace:
```
x = Struct { 0: a, 1: b }
y = move? x
```

by assignment between locals
```
x_0 = a
x_1 = b
y_0 = move? x_0
y_1 = move? x_1
```

The improved pass runs to fixpoint, so we can flatten nested field accesses.
  • Loading branch information
Dylan-DPC authored Feb 6, 2023
2 parents 675976e + 51ef82d commit e385ca2
Show file tree
Hide file tree
Showing 21 changed files with 589 additions and 313 deletions.
4 changes: 2 additions & 2 deletions compiler/rustc_mir_dataflow/src/value_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ impl<V, T> TryFrom<ProjectionElem<V, T>> for TrackElem {
}

/// Invokes `f` on all direct fields of `ty`.
fn iter_fields<'tcx>(
pub fn iter_fields<'tcx>(
ty: Ty<'tcx>,
tcx: TyCtxt<'tcx>,
mut f: impl FnMut(Option<VariantIdx>, Field, Ty<'tcx>),
Expand Down Expand Up @@ -824,7 +824,7 @@ fn iter_fields<'tcx>(
}

/// Returns all locals with projections that have their reference or address taken.
fn excluded_locals(body: &Body<'_>) -> IndexVec<Local, bool> {
pub fn excluded_locals(body: &Body<'_>) -> IndexVec<Local, bool> {
struct Collector {
result: IndexVec<Local, bool>,
}
Expand Down
Loading

0 comments on commit e385ca2

Please sign in to comment.