Skip to content

Commit 0279cb1

Browse files
committed
Auto merge of #85741 - tmiasko:ssa, r=nagisa
Use preorder traversal when checking for SSA locals Traverse blocks in topological sort of dominance partial order, to ensure that local analyzer correctly identifies locals that are already in static single assignment form, while avoiding dependency on implicit numeric order of blocks. When rebuilding the standard library, this change reduces the number of locals that require an alloca from 62452 to 62348.
2 parents c5fbcd3 + 4237a05 commit 0279cb1

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)