pub fn compute_dominance_frontiers(
        &self,
        start_index: usize,
    ) -> Result<FxHashMap<usize, FxHashSet<usize>>> {
        let mut df: FxHashMap<usize, FxHashSet<usize>> = FxHashMap::default();

        for vertex in &self.vertices {
            df.insert(*vertex.0, FxHashSet::default());
        }

        let idoms = self.compute_immediate_dominators(start_index)?;

        for vertex in &self.vertices {
            let vertex_index: usize = *vertex.0;

            if self.predecessors[&vertex_index].len() >= 2 {
                if !idoms.contains_key(&vertex_index) {
                    continue;
                }
                let idom = idoms[&vertex_index];

                for predecessor in &self.predecessors[&vertex_index] {
                    let mut runner = *predecessor;
                    while runner != idom {
                        df.get_mut(&runner).unwrap().insert(vertex_index);
                        if !idoms.contains_key(&runner) {
                            break;
                        }
                        runner = idoms[&runner];
                    }
                }
            }
        }

        // Special handling for the start node as it can be part of a loop.
        // This is necessary because we don't have a dedicated entry node.
        for predecessor in &self.predecessors[&start_index] {
            let mut runner = *predecessor;
            loop {
                df.get_mut(&runner).unwrap().insert(start_index);
                if !idoms.contains_key(&runner) {
                    break;
                }
                runner = idoms[&runner];
            }
        }

        Ok(df)
    }
/// Computes the dominance frontiers for all vertices in the graph
Computes the dominance frontiers for all vertices in the graph
Computes the dominance frontiers for all vertices in the graph
pub fn compute_dominance_frontiers(
        &self,
        start_index: usize,
    ) -> Result<FxHashMap<usize, FxHashSet<usize>>> {
        let mut df: FxHashMap<usize, FxHashSet<usize>> = FxHashMap::default();
        for vertex in &self.vertices {
            df.insert(*vertex.0, FxHashSet::default());
        }
        let idoms = self.compute_immediate_dominators(start_index)?;
        for vertex in &self.vertices {
            let vertex_index: usize = *vertex.0;
            if self.predecessors[&vertex_index].len() >= 2 {
                if !idoms.contains_key(&vertex_index) {
                    continue;
                }
                let idom = idoms[&vertex_index];
                for predecessor in &self.predecessors[&vertex_index] {
                    let mut runner = *predecessor;
                    while runner != idom {
                        df.get_mut(&runner).unwrap().insert(vertex_index);
                        if !idoms.contains_key(&runner) {
                            break;
                        }
                        runner = idoms[&runner];
                    }
                }
            }
        }
        // Special handling for the start node as it can be part of a loop.
        // This is necessary because we don't have a dedicated entry node.
        for predecessor in &self.predecessors[&start_index] {
            let mut runner = *predecessor;
            loop {
                df.get_mut(&runner).unwrap().insert(start_index);
                if !idoms.contains_key(&runner) {
                    break;
                }
                runner = idoms[&runner];
            }
        }
        Ok(df)
    }
pub fn compute_dominance_frontiers ( & self , start_index : usize , ) -> Result < FxHashMap < usize , FxHashSet < usize > > > { let mut df : FxHashMap < usize , FxHashSet < usize > > = FxHashMap :: default ( ) ; for vertex in & self . vertices { df . insert ( * vertex . 0 , FxHashSet :: default ( ) ) ; } let idoms = self . compute_immediate_dominators ( start_index ) ? ; for vertex in & self . vertices { let vertex_index : usize = * vertex . 0 ; if self . predecessors [ & vertex_index ] . len ( ) >= 2 { if ! idoms . contains_key ( & vertex_index ) { continue ; } let idom = idoms [ & vertex_index ] ; for predecessor in & self . predecessors [ & vertex_index ] { let mut runner = * predecessor ; while runner != idom { df . get_mut ( & runner ) . unwrap ( ) . insert ( vertex_index ) ; if ! idoms . contains_key ( & runner ) { break ; } runner = idoms [ & runner ] ; } } } } // Special handling for the start node as it can be part of a loop. // This is necessary because we don't have a dedicated entry node. for predecessor in & self . predecessors [ & start_index ] { let mut runner = * predecessor ; loop { df . get_mut ( & runner ) . unwrap ( ) . insert ( start_index ) ; if ! idoms . contains_key ( & runner ) { break ; } runner = idoms [ & runner ] ; } } Ok ( df ) }
Computes the dominance frontiers for all vertices in the graph
Computes the dominance frontiers for all vertices in the graph
&self
start_index
usize
&self
start_index
usize