// Collapse a goto chain starting from `start`
Collapse a goto chain starting from `start`
Collapse a goto chain starting from ` start `
fn collapse_goto_chain(&mut self, start: &mut BasicBlock, changed: &mut bool) {
        let mut terminator = match self.basic_blocks[*start] {
            BasicBlockData {
                ref statements,
                terminator: ref mut terminator @ Some(Terminator {
                    kind: TerminatorKind::Goto { .. }, ..
                }), ..
            } if statements.is_empty() => terminator.take(),
            // if `terminator` is None, this means we are in a loop. In that
            // case, let all the loop collapse to its entry.
            _ => return
        };
        let target = match terminator {
            Some(Terminator { kind: TerminatorKind::Goto { ref mut target }, .. }) => {
                self.collapse_goto_chain(target, changed);
                *target
            }
            _ => unreachable!()
        };
        self.basic_blocks[*start].terminator = terminator;
        debug!("collapsing goto chain from {:?} to {:?}", *start, target);
        *changed |= *start != target;
        self.pred_count[target] += 1;
        self.pred_count[*start] -= 1;
        *start = target;
    }
fn collapse_goto_chain ( & mut self , start : & mut BasicBlock , changed : & mut bool ) { let mut terminator = match self . basic_blocks [ * start ] { BasicBlockData { ref statements , terminator : ref mut terminator @ Some ( Terminator { kind : TerminatorKind :: Goto { .. } , .. } ) , .. } if statements . is_empty ( ) => terminator . take ( ) , // if `terminator` is None, this means we are in a loop. In that // case, let all the loop collapse to its entry. _ => return } ; let target = match terminator { Some ( Terminator { kind : TerminatorKind :: Goto { ref mut target } , .. } ) => { self . collapse_goto_chain ( target , changed ) ; * target } _ => unreachable ! ( ) } ; self . basic_blocks [ * start ] . terminator = terminator ; debug ! ( " " start target ) ; * changed |= * start != target ; self . pred_count [ target ] += 1 ; self . pred_count [ * start ] -= 1 ; * start = target ; }
Collapse a goto chain starting from `start`
Collapse a goto chain starting from ` start `
&mut self
start
&mut BasicBlock
changed
&mut bool