Skip to content

Commit 4d614e1

Browse files
committed
Do not collapse goto chains beginning with the start block
If any block on a goto chain has more than one predecessor, then the new start block would have basic block predecessors. Skip the transformation for the start block altogether, to avoid violating the new invariant that the start block does not have any basic block predecessors.
1 parent 5118dd5 commit 4d614e1

File tree

1 file changed

+0
-25
lines changed

1 file changed

+0
-25
lines changed

compiler/rustc_mir_transform/src/simplify.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
9595
pub fn simplify(mut self) {
9696
self.strip_nops();
9797

98-
let mut start = START_BLOCK;
99-
10098
// Vec of the blocks that should be merged. We store the indices here, instead of the
10199
// statements itself to avoid moving the (relatively) large statements twice.
102100
// We do not push the statements directly into the target block (`bb`) as that is slower
@@ -105,8 +103,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
105103
loop {
106104
let mut changed = false;
107105

108-
self.collapse_goto_chain(&mut start, &mut changed);
109-
110106
for bb in self.basic_blocks.indices() {
111107
if self.pred_count[bb] == 0 {
112108
continue;
@@ -149,27 +145,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
149145
break;
150146
}
151147
}
152-
153-
if start != START_BLOCK {
154-
debug_assert!(self.pred_count[START_BLOCK] == 0);
155-
self.basic_blocks.swap(START_BLOCK, start);
156-
self.pred_count.swap(START_BLOCK, start);
157-
158-
// pred_count == 1 if the start block has no predecessor _blocks_.
159-
if self.pred_count[START_BLOCK] > 1 {
160-
for (bb, data) in self.basic_blocks.iter_enumerated_mut() {
161-
if self.pred_count[bb] == 0 {
162-
continue;
163-
}
164-
165-
for target in data.terminator_mut().successors_mut() {
166-
if *target == start {
167-
*target = START_BLOCK;
168-
}
169-
}
170-
}
171-
}
172-
}
173148
}
174149

175150
/// This function will return `None` if

0 commit comments

Comments
 (0)