pub fn sweep<T>(ssa: &mut T)
where
    T: Clone
        + SSAExtra
        + SSAMod<ActionRef = <T as Graph>::GraphNodeRef, CFEdgeRef = <T as Graph>::GraphEdgeRef>,
{
    for node in &ssa.values() {
        if !ssa.is_marked(node) {
            ssa.remove_value(*node);
        }
        ssa.clear_mark(node);
    }

    // Remove empty blocks and redirect control flows.
    let blocks = ssa.blocks();
    for block in &blocks {
        // Do not touch start or exit nodes
        if *block == entry_node_err!(ssa) || *block == exit_node_err!(ssa) {
            continue;
        }

        let remove_block = if ssa.exprs_in(*block).is_empty() && ssa.phis_in(*block).is_empty() {
            let incoming = ssa.incoming_edges(*block);
            let outgoing = ssa.outgoing_edges(*block);
            // Two cases.
            if outgoing.len() == 1 {
                let new_target = ssa
                    .edge_info(outgoing[0].0)
                    .expect("Less-endpoints edge")
                    .target;
                for &(ie, ref i) in &incoming {
                    let new_src = ssa.edge_info(ie).expect("Less-endpoints edge").source;
                    ssa.remove_control_edge(ie);
                    ssa.insert_control_edge(new_src, new_target, *i);
                }
                ssa.remove_control_edge(outgoing[0].0);
                true
            } else {
                // Incoming edge has to be an unconditional,
                // else we cannot re-route.
                // TODO: This is currently unimplemented!
                false
            }
        } else {
            false
        };
        if remove_block {
            radeco_trace!("dce_rm_empty|{:?}", block);
            ssa.remove_block(*block);
        }
    }
}
/// Sweeps away the un-marked nodes
Sweeps away the un-marked nodes
Sweeps away the un - marked nodes
pub fn sweep<T>(ssa: &mut T)
where
    T: Clone
        + SSAExtra
        + SSAMod<ActionRef = <T as Graph>::GraphNodeRef, CFEdgeRef = <T as Graph>::GraphEdgeRef>,
{
    for node in &ssa.values() {
        if !ssa.is_marked(node) {
            ssa.remove_value(*node);
        }
        ssa.clear_mark(node);
    }
    // Remove empty blocks and redirect control flows.
    let blocks = ssa.blocks();
    for block in &blocks {
        // Do not touch start or exit nodes
        if *block == entry_node_err!(ssa) || *block == exit_node_err!(ssa) {
            continue;
        }
        let remove_block = if ssa.exprs_in(*block).is_empty() && ssa.phis_in(*block).is_empty() {
            let incoming = ssa.incoming_edges(*block);
            let outgoing = ssa.outgoing_edges(*block);
            // Two cases.
            if outgoing.len() == 1 {
                let new_target = ssa
                    .edge_info(outgoing[0].0)
                    .expect("Less-endpoints edge")
                    .target;
                for &(ie, ref i) in &incoming {
                    let new_src = ssa.edge_info(ie).expect("Less-endpoints edge").source;
                    ssa.remove_control_edge(ie);
                    ssa.insert_control_edge(new_src, new_target, *i);
                }
                ssa.remove_control_edge(outgoing[0].0);
                true
            } else {
                // Incoming edge has to be an unconditional,
                // else we cannot re-route.
                // TODO: This is currently unimplemented!
                false
            }
        } else {
            false
        };
        if remove_block {
            radeco_trace!("dce_rm_empty|{:?}", block);
            ssa.remove_block(*block);
        }
    }
}
pub fn sweep < T > ( ssa : & mut T ) where T : Clone + SSAExtra + SSAMod < ActionRef = < T as Graph > :: GraphNodeRef , CFEdgeRef = < T as Graph > :: GraphEdgeRef > , { for node in & ssa . values ( ) { if ! ssa . is_marked ( node ) { ssa . remove_value ( * node ) ; } ssa . clear_mark ( node ) ; } // Remove empty blocks and redirect control flows. let blocks = ssa . blocks ( ) ; for block in & blocks { // Do not touch start or exit nodes if * block == entry_node_err ! ( ssa ) || * block == exit_node_err ! ( ssa ) { continue ; } let remove_block = if ssa . exprs_in ( * block ) . is_empty ( ) && ssa . phis_in ( * block ) . is_empty ( ) { let incoming = ssa . incoming_edges ( * block ) ; let outgoing = ssa . outgoing_edges ( * block ) ; // Two cases. if outgoing . len ( ) == 1 { let new_target = ssa . edge_info ( outgoing [ 0 ] . 0 ) . expect ( " " ) . target ; for & ( ie , ref i ) in & incoming { let new_src = ssa . edge_info ( ie ) . expect ( " " ) . source ; ssa . remove_control_edge ( ie ) ; ssa . insert_control_edge ( new_src , new_target , * i ) ; } ssa . remove_control_edge ( outgoing [ 0 ] . 0 ) ; true } else { // Incoming edge has to be an unconditional, // else we cannot re-route. // TODO: This is currently unimplemented! false } } else { false } ; if remove_block { radeco_trace ! ( " " block ) ; ssa . remove_block ( * block ) ; } } }
Sweeps away the un-marked nodes
Sweeps away the un - marked nodes
ssa
&mut T
ssa
&mut T