Dead code analysis
dead_code_analysis
¶
CFGEdge
dataclass
¶
Bases: GenericLatticeAnchor
A lattice anchor representing a control-flow edge between two blocks.
Source code in xdsl/analysis/dead_code_analysis.py
Executable
¶
Bases: AnalysisState
A state that represents whether a block or CFG edge is live.
Source code in xdsl/analysis/dead_code_analysis.py
live: bool = False
instance-attribute
¶
block_content_subscribers: set[DataFlowAnalysis] = set()
instance-attribute
¶
__init__(anchor: LatticeAnchor)
¶
set_to_live() -> ChangeResult
¶
Marks the anchor as live and returns whether the state changed.
on_update(solver: DataFlowSolver) -> None
¶
Source code in xdsl/analysis/dead_code_analysis.py
PredecessorState
¶
Bases: AnalysisState
A state representing the set of live control-flow predecessors of a program point (e.g., a region entry or a call operation).
Source code in xdsl/analysis/dead_code_analysis.py
all_known: bool = True
instance-attribute
¶
known_predecessors: set[Operation] = set()
instance-attribute
¶
successor_inputs: dict[Operation, Sequence[SSAValue]] = {}
instance-attribute
¶
__init__(anchor: LatticeAnchor)
¶
set_has_unknown_predecessors() -> ChangeResult
¶
Marks that not all predecessors can be known.
join(predecessor: Operation, inputs: Sequence[SSAValue] | None = None) -> ChangeResult
¶
Add a known predecessor and its successor inputs.
Source code in xdsl/analysis/dead_code_analysis.py
DeadCodeAnalysis
¶
Bases: DataFlowAnalysis
This analysis identifies executable code paths. It is a foundational analysis that other dataflow analyses can depend on to correctly handle control flow.
NOTE: Due to the lack of control flow interfaces in xDSL (e.g., BranchOpInterface, RegionBranchOpInterface, CallOpInterface), the analysis does not handle control flow at all. Essentially, only the entry block of the top-level op's first region is marked as live.