Skip to content

Commit 4237a05

Browse files
committed
Use preorder traversal when checking for SSA locals
When rebuilding the standard library, this change reduces the number of locals that require an alloca from 62452 to 62348.
1 parent 69e2f23 commit 4237a05

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_codegen_ssa/src/mir/analyze.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
1818
let mir = fx.mir;
1919
let mut analyzer = LocalAnalyzer::new(fx);
2020

21-
for (bb, data) in mir.basic_blocks().iter_enumerated() {
21+
// If there exists a local definition that dominates all uses of that local,
22+
// the definition should be visited first. Traverse blocks in preorder which
23+
// is a topological sort of dominance partial order.
24+
for (bb, data) in traversal::preorder(&mir) {
2225
analyzer.visit_basic_block_data(bb, data);
2326
}
2427

0 commit comments

Comments
 (0)