Skip to content

Commit 734c65b

Browse files
committed
perf experiment: computed required_consts before promotion
1 parent e949b49 commit 734c65b

File tree

1 file changed

+7
-8
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+7
-8
lines changed

compiler/rustc_mir_transform/src/lib.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,13 @@ fn mir_promoted(
343343
body.tainted_by_errors = Some(error_reported);
344344
}
345345

346+
let mut required_consts = Vec::new();
347+
let mut required_consts_visitor = RequiredConstsVisitor::new(&mut required_consts);
348+
for (bb, bb_data) in traversal::reverse_postorder(&body) {
349+
required_consts_visitor.visit_basic_block_data(bb, bb_data);
350+
}
351+
body.required_consts = required_consts;
352+
346353
// What we need to run borrowck etc.
347354
let promote_pass = promote_consts::PromoteTemps::default();
348355
pm::run_passes(
@@ -352,14 +359,6 @@ fn mir_promoted(
352359
Some(MirPhase::Analysis(AnalysisPhase::Initial)),
353360
);
354361

355-
// Promotion generates new consts; we run this after promotion to ensure they are accounted for.
356-
let mut required_consts = Vec::new();
357-
let mut required_consts_visitor = RequiredConstsVisitor::new(&mut required_consts);
358-
for (bb, bb_data) in traversal::reverse_postorder(&body) {
359-
required_consts_visitor.visit_basic_block_data(bb, bb_data);
360-
}
361-
body.required_consts = required_consts;
362-
363362
let promoted = promote_pass.promoted_fragments.into_inner();
364363
(tcx.alloc_steal_mir(body), tcx.alloc_steal_promoted(promoted))
365364
}

0 commit comments

Comments
 (0)