Class DefUseChains


  • public class DefUseChains
    extends Object
    Def-use chains mapping each SSA value to its defining instruction and its uses.
    • Constructor Detail

      • DefUseChains

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

      • getMethod

        public IRMethod getMethod()
        Returns:
        the method
      • compute

        public void compute()
        Computes def-use chains for all values in the method.
      • getDefinition

        public IRInstruction getDefinition​(SSAValue value)
        Gets the instruction that defines the specified value.
        Parameters:
        value - the value to query
        Returns:
        the defining instruction, or null if none exists
      • getUses

        public Set<IRInstruction> getUses​(SSAValue value)
        Gets all instructions that use the specified value.
        Parameters:
        value - the value to query
        Returns:
        the set of instructions that use the value
      • getUsedValues

        public Set<SSAValue> getUsedValues​(IRInstruction instr)
        Gets all values used by the specified instruction.
        Parameters:
        instr - the instruction to query
        Returns:
        the set of values used by the instruction
      • getDefinedValue

        public SSAValue getDefinedValue​(IRInstruction instr)
        Gets the value defined by the specified instruction.
        Parameters:
        instr - the instruction to query
        Returns:
        the defined value, or null if the instruction defines no value
      • hasUses

        public boolean hasUses​(SSAValue value)
        Checks if the specified value has any uses.
        Parameters:
        value - the value to check
        Returns:
        true if the value has at least one use
      • getUseCount

        public int getUseCount​(SSAValue value)
        Gets the number of uses of the specified value.
        Parameters:
        value - the value to query
        Returns:
        the use count
      • isDeadCode

        public boolean isDeadCode​(IRInstruction instr)
        Checks if an instruction is dead code.
        Parameters:
        instr - the instruction to check
        Returns:
        true if the instruction defines a value that has no uses