diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-09-15 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-09-18 07:28:55 +0200 |
| commit | 4d614e1d1f964ac1dc7af0261848cf6dc63d915c (patch) | |
| tree | 0cbd9b9d0118cbb0fe5908936bf180fbf9adde58 /compiler/rustc_mir_transform/src | |
| parent | 5118dd5a2f0b97a006f55ef68408a7dd1925bc12 (diff) | |
| download | rust-4d614e1d1f964ac1dc7af0261848cf6dc63d915c.tar.gz rust-4d614e1d1f964ac1dc7af0261848cf6dc63d915c.zip | |
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.
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/simplify.rs | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/compiler/rustc_mir_transform/src/simplify.rs b/compiler/rustc_mir_transform/src/simplify.rs index e3cfd1d0afc..d6cd505cbb5 100644 --- a/compiler/rustc_mir_transform/src/simplify.rs +++ b/compiler/rustc_mir_transform/src/simplify.rs @@ -95,8 +95,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> { pub fn simplify(mut self) { self.strip_nops(); - let mut start = START_BLOCK; - // Vec of the blocks that should be merged. We store the indices here, instead of the // statements itself to avoid moving the (relatively) large statements twice. // 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> { loop { let mut changed = false; - self.collapse_goto_chain(&mut start, &mut changed); - for bb in self.basic_blocks.indices() { if self.pred_count[bb] == 0 { continue; @@ -149,27 +145,6 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> { break; } } - - if start != START_BLOCK { - debug_assert!(self.pred_count[START_BLOCK] == 0); - self.basic_blocks.swap(START_BLOCK, start); - self.pred_count.swap(START_BLOCK, start); - - // pred_count == 1 if the start block has no predecessor _blocks_. - if self.pred_count[START_BLOCK] > 1 { - for (bb, data) in self.basic_blocks.iter_enumerated_mut() { - if self.pred_count[bb] == 0 { - continue; - } - - for target in data.terminator_mut().successors_mut() { - if *target == start { - *target = START_BLOCK; - } - } - } - } - } } /// This function will return `None` if |
