# loki.analyse.abstract_dfa module

class AbstractDataflowAnalysis

  Bases: `ABC`

  Base interface for dataflow analyses attaching metadata to IR nodes.

  This abstract class defines the common entry points for providing “Attacher” and “Detacher” `Transformation` objects that populate the implicit sets of symbols attached to each IR node when the analysis has been performed.

  For more info, see the `dfa_attached` context.

  get_attacher() → Any

    Returns an instance of the associated “Attacher” `Transformation`.

  get_detacher() → Any

    Returns an instance of the associated “Detacher” `Transformation`.

  abstractmethod attach_dataflow_analysis(module_or_routine)
  abstractmethod detach_dataflow_analysis(module_or_routine)

dfa_attached(module_or_routine, dfa)

  Create a context in which information about defined, live and used symbols is attached to each IR node.

  This makes for each IR node the following properties available:

  - `Node.live_symbols`: symbols defined before the node;

  - `Node.defines_symbols`: symbols (potentially) defined by the node;

  - `Node.uses_symbols`: symbols used by the node that had to be defined before.

  This is an in-place update of nodes and thus existing references to IR nodes remain valid. When leaving the context the information is removed from IR nodes, while existing references remain valid.

  The default analysis, which uses a simplified Reaching Definitions Analysis (see `DataflowAnalysis`) is used, unless a more specialised implementation is provided via the `dfa` argument.

  Parameters:

    - module_or_routine (`Module` or `Subroutine`) – The object for which the IR is to be annotated.

    - dfa (`AbstractDataflowAnalysis`, optional) – Instance of a dataflow analysis object providing “attacher” and “detacher” mechanisms.