Class PostDominatorTree


  • public class PostDominatorTree
    extends Object
    Post-dominator tree for a CFG, computed by dominator analysis on the reverse graph.
    • Constructor Detail

      • PostDominatorTree

        public PostDominatorTree​(IRMethod method)
        Creates an empty tree for the given method.
        Parameters:
        method - the method to analyze
    • Method Detail

      • getMethod

        public IRMethod getMethod()
        Returns:
        the method
      • getImmediatePostDominator

        public Map<IRBlock,​IRBlock> getImmediatePostDominator()
        Returns:
        the immediate post dominator
      • getPostDominatorTreeChildren

        public Map<IRBlock,​Set<IRBlock>> getPostDominatorTreeChildren()
        Returns:
        the post dominator tree children
      • getReversePreorder

        public Map<IRBlock,​Integer> getReversePreorder()
        Returns:
        the reverse preorder
      • getReversePostorder

        public Map<IRBlock,​Integer> getReversePostorder()
        Returns:
        the reverse postorder
      • getExitBlocks

        public Set<IRBlock> getExitBlocks()
        Returns:
        the exit blocks
      • compute

        public void compute()
        Computes the post-dominator tree.
      • getImmediatePostDominator

        public IRBlock getImmediatePostDominator​(IRBlock block)
        Gets the immediate post-dominator of the specified block.
        Parameters:
        block - the block to query
        Returns:
        the immediate post-dominator, or null if none exists
      • getPostDominatorTreeChildren

        public Set<IRBlock> getPostDominatorTreeChildren​(IRBlock block)
        Gets the children of the specified block in the post-dominator tree.
        Parameters:
        block - the block to query
        Returns:
        the set of post-dominator tree children
      • postDominates

        public boolean postDominates​(IRBlock a,
                                     IRBlock b)
        Checks if block A post-dominates block B. A post-dominates B if every path from B to exit must go through A.
        Parameters:
        a - the potential post-dominator
        b - the block to test
        Returns:
        true if a post-dominates b
      • strictlyPostDominates

        public boolean strictlyPostDominates​(IRBlock a,
                                             IRBlock b)
        Checks if block A strictly post-dominates block B.
        Parameters:
        a - the potential post-dominator
        b - the block to test
        Returns:
        true if a strictly post-dominates b
      • findMergePoint

        public IRBlock findMergePoint​(IRBlock branchBlock)
        Finds the merge point for an if-then-else by finding the immediate post-dominator of the branch block.
        Parameters:
        branchBlock - the block containing the conditional branch
        Returns:
        the merge point block, or null if not found