Skip to content

Commit e385ca2

Browse files
authored
Rollup merge of rust-lang#107687 - cjgillot:sroa-2, r=oli-obk
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.
2 parents 675976e + 51ef82d commit e385ca2

21 files changed

+589
-313
lines changed

compiler/rustc_mir_dataflow/src/value_analysis.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ impl<V, T> TryFrom<ProjectionElem<V, T>> for TrackElem {
790790
}
791791

792792
/// Invokes `f` on all direct fields of `ty`.
793-
fn iter_fields<'tcx>(
793+
pub fn iter_fields<'tcx>(
794794
ty: Ty<'tcx>,
795795
tcx: TyCtxt<'tcx>,
796796
mut f: impl FnMut(Option<VariantIdx>, Field, Ty<'tcx>),
@@ -824,7 +824,7 @@ fn iter_fields<'tcx>(
824824
}
825825

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

0 commit comments

Comments
 (0)