Skip to content

Commit

Permalink
Auto merge of #85741 - tmiasko:ssa, r=nagisa
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Jun 10, 2021
2 parents c5fbcd3 + 4237a05 commit 0279cb1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/rustc_codegen_ssa/src/mir/analyze.rs
Expand Up @@ -18,7 +18,10 @@ pub fn non_ssa_locals<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
let mir = fx.mir;
let mut analyzer = LocalAnalyzer::new(fx);

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

Expand Down

0 comments on commit 0279cb1

Please sign in to comment.