Skip to content

Commit 42d586c

Browse files
committed
mvp
1 parent 9a1a5a2 commit 42d586c

File tree

5 files changed

+1231
-3
lines changed

5 files changed

+1231
-3
lines changed

compiler/rustc_mir_transform/src/lib.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ mod normalize_array_len;
9191
mod nrvo;
9292
mod prettify;
9393
mod promote_consts;
94+
mod promote_consts_local_arrays;
9495
mod ref_prop;
9596
mod remove_noop_landing_pads;
9697
mod remove_storage_markers;
@@ -352,14 +353,22 @@ fn mir_promoted(
352353

353354
// What we need to run borrowck etc.
354355
let promote_pass = promote_consts::PromoteTemps::default();
356+
let promote_array = promote_consts_local_arrays::PromoteArraysOpt::default();
355357
pm::run_passes(
356358
tcx,
357359
&mut body,
358-
&[&promote_pass, &simplify::SimplifyCfg::PromoteConsts, &coverage::InstrumentCoverage],
360+
&[
361+
&promote_pass,
362+
&promote_array,
363+
&simplify::SimplifyCfg::PromoteConsts,
364+
&coverage::InstrumentCoverage,
365+
],
359366
Some(MirPhase::Analysis(AnalysisPhase::Initial)),
360367
);
361368

362-
let promoted = promote_pass.promoted_fragments.into_inner();
369+
let mut promoted = promote_pass.promoted_fragments.into_inner();
370+
let array_promoted = promote_array.promoted_fragments.into_inner();
371+
promoted.extend(array_promoted);
363372
(tcx.alloc_steal_mir(body), tcx.alloc_steal_promoted(promoted))
364373
}
365374

compiler/rustc_mir_transform/src/promote_consts.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,15 @@ impl<'tcx> Visitor<'tcx> for Collector<'_, 'tcx> {
103103
// We're only interested in temporaries and the return place
104104
match self.ccx.body.local_kind(index) {
105105
LocalKind::Arg => return,
106-
LocalKind::Temp if self.ccx.body.local_decls[index].is_user_variable() => return,
106+
LocalKind::Temp
107+
if {
108+
let is_user_variable = self.ccx.body.local_decls[index].is_user_variable();
109+
debug!(?is_user_variable);
110+
is_user_variable
111+
} =>
112+
{
113+
return;
114+
}
107115
LocalKind::ReturnPointer | LocalKind::Temp => {}
108116
}
109117

0 commit comments

Comments
 (0)