Reach.Effects (Reach v2.2.0)

Copy Markdown View Source

Effect classification for IR nodes.

Classifies each expression by its side effects — pure computations, IO, mutable state access, message passing, etc. Used by independence queries to determine whether reordering is safe.

Summary

Functions

Classifies the effect of an IR node.

Returns true if two effects conflict (reordering may change behavior).

Returns true if the node has the given effect.

Ensures the effect-classification ETS cache exists.

Infers effects for project-local functions by analyzing their call bodies.

Returns true if the node is pure (no side effects).

Returns true when a module/function/arity is classified as pure.

Returns modules whose functions are pure by default unless explicitly listed otherwise.

Types

effect()

@type effect() ::
  :pure | :read | :write | :io | :send | :receive | :exception | :nif | :unknown

Functions

classify(node)

@spec classify(Reach.IR.Node.t()) :: effect()

Classifies the effect of an IR node.

conflicting?(arg1, arg2)

@spec conflicting?(effect(), effect()) :: boolean()

Returns true if two effects conflict (reordering may change behavior).

effectful?(node, effect)

@spec effectful?(Reach.IR.Node.t(), effect()) :: boolean()

Returns true if the node has the given effect.

ensure_cache()

Ensures the effect-classification ETS cache exists.

infer_local_effects(node_map)

@spec infer_local_effects(%{required(Reach.IR.Node.id()) => Reach.IR.Node.t()}) :: :ok

Infers effects for project-local functions by analyzing their call bodies.

Walks all function definitions and classifies each based on the effects of its callees. Iterates until no new classifications are found (fixed-point). Results are cached in the ETS classify cache.

pure?(node)

@spec pure?(Reach.IR.Node.t()) :: boolean()

Returns true if the node is pure (no side effects).

pure_call?(module, function, arity)

Returns true when a module/function/arity is classified as pure.

pure_modules()

Returns modules whose functions are pure by default unless explicitly listed otherwise.