Skip to content

Commit 84c024d

Browse files
author
Markus Westerlind
committed
Clarify mir block merging
1 parent 2440998 commit 84c024d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/librustc_mir/transform/simplify.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
9595

9696
let mut start = START_BLOCK;
9797

98+
// Vec of the blocks that should be merged. We store the indices here, instead of the
99+
// statements itself to avoid moving the (relatively) large statements twice.
100+
// We do not push the statements directly into the target block (`bb`) as that is slower
101+
// due to additional reallocations
98102
let mut merged_blocks = Vec::new();
99103
loop {
100104
let mut changed = false;
@@ -116,6 +120,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
116120
}
117121

118122
let mut inner_changed = true;
123+
merged_blocks.clear();
119124
while inner_changed {
120125
inner_changed = false;
121126
inner_changed |= self.simplify_branch(&mut terminator);
@@ -134,7 +139,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
134139
}
135140
self.basic_blocks[bb].statements = statements;
136141
}
137-
merged_blocks.clear();
138142

139143
self.basic_blocks[bb].terminator = Some(terminator);
140144

0 commit comments

Comments
 (0)