diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-05-27 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-06-07 05:33:49 +0200 |
| commit | 4237a052330ddc39fc458b42238bdc50c8584d73 (patch) | |
| tree | a9e6f8892b596a8a56b524c579bad7d19a0f5528 /compiler/rustc_codegen_ssa/src/mir | |
| parent | 69e2f23a41f3bb5cb49e3dc66160f3888d871917 (diff) | |
| download | rust-4237a052330ddc39fc458b42238bdc50c8584d73.tar.gz rust-4237a052330ddc39fc458b42238bdc50c8584d73.zip | |
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.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/mir')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/analyze.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/analyze.rs b/compiler/rustc_codegen_ssa/src/mir/analyze.rs index 8a22a74f97c..49b5e8466be 100644 --- a/compiler/rustc_codegen_ssa/src/mir/analyze.rs +++ b/compiler/rustc_codegen_ssa/src/mir/analyze.rs @@ -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); } |
