pub fn remove_redundant_branches(&mut self) {
        // For each block, compute the actual target block, looking through all
        // blocks with single-target jumps.
        //
        // The outer `Option` indicates whether the dynamic programming algorithm
        // has computed this value yet. The inner `Option` indicates whether there
        // is a redirect.
        let block_rewrites: Vec<BlockIndex> = (0..self.num_blocks() as u32)
            .map(|bix| look_through_trivial_jumps(self, bix))
            .collect();
        let deleted: Vec<bool> = block_rewrites
            .iter()
            .enumerate()
            .map(|(i, target)| i != *target as usize)
            .collect();

        debug!(
            "remove_redundant_branches: block_rewrites = {:?}",
            block_rewrites
        );

        for block in 0..self.num_blocks() as u32 {
            for insn in self.block_insns(BlockIx::new(block)) {
                self.get_insn_mut(insn)
                    .with_block_rewrites(&block_rewrites[..]);
            }
        }

        let block_order = std::mem::replace(&mut self.final_block_order, vec![]);
        self.final_block_order = block_order
            .into_iter()
            .filter(|b| !deleted[*b as usize])
            .collect();
    }
/// Removes redundant branches, rewriting targets to point directly to the
/// ultimate block at the end of a chain of trivial one-target jumps.
Removes redundant branches, rewriting targets to point directly to the
ultimate block at the end of a chain of trivial one-target jumps.
Removes redundant branches rewriting targets to point directly to the ultimate block at the end of a chain of trivial one - target jumps .
pub fn remove_redundant_branches(&mut self) {
        // For each block, compute the actual target block, looking through all
        // blocks with single-target jumps.
        //
        // The outer `Option` indicates whether the dynamic programming algorithm
        // has computed this value yet. The inner `Option` indicates whether there
        // is a redirect.
        let block_rewrites: Vec<BlockIndex> = (0..self.num_blocks() as u32)
            .map(|bix| look_through_trivial_jumps(self, bix))
            .collect();
        let deleted: Vec<bool> = block_rewrites
            .iter()
            .enumerate()
            .map(|(i, target)| i != *target as usize)
            .collect();
        debug!(
            "remove_redundant_branches: block_rewrites = {:?}",
            block_rewrites
        );
        for block in 0..self.num_blocks() as u32 {
            for insn in self.block_insns(BlockIx::new(block)) {
                self.get_insn_mut(insn)
                    .with_block_rewrites(&block_rewrites[..]);
            }
        }
        let block_order = std::mem::replace(&mut self.final_block_order, vec![]);
        self.final_block_order = block_order
            .into_iter()
            .filter(|b| !deleted[*b as usize])
            .collect();
    }
pub fn remove_redundant_branches ( & mut self ) { // For each block, compute the actual target block, looking through all // blocks with single-target jumps. // // The outer `Option` indicates whether the dynamic programming algorithm // has computed this value yet. The inner `Option` indicates whether there // is a redirect. let block_rewrites : Vec < BlockIndex > = ( 0 .. self . num_blocks ( ) as u32 ) . map ( | bix | look_through_trivial_jumps ( self , bix ) ) . collect ( ) ; let deleted : Vec < bool > = block_rewrites . iter ( ) . enumerate ( ) . map ( | ( i , target ) | i != * target as usize ) . collect ( ) ; debug ! ( " " block_rewrites ) ; for block in 0 .. self . num_blocks ( ) as u32 { for insn in self . block_insns ( BlockIx :: new ( block ) ) { self . get_insn_mut ( insn ) . with_block_rewrites ( & block_rewrites [ .. ] ) ; } } let block_order = std :: mem :: replace ( & mut self . final_block_order , vec ! [ ] ) ; self . final_block_order = block_order . into_iter ( ) . filter ( | b | ! deleted [ * b as usize ] ) . collect ( ) ; }
Removes redundant branches, rewriting targets to point directly to the
ultimate block at the end of a chain of trivial one-target jumps.
Removes redundant branches rewriting targets to point directly to the ultimate block at the end of a chain of trivial one - target jumps .
&mut self
&mut self