Dead code elimination
dead_code_elimination
¶
RemoveUnusedOperations
¶
Bases: RewritePattern
Removes operations annotated with the Pure trait, where results have no uses.
Source code in xdsl/transforms/dead_code_elimination.py
LiveSet
dataclass
¶
Source code in xdsl/transforms/dead_code_elimination.py
changed: bool = field(default=True)
class-attribute
instance-attribute
¶
__init__(changed: bool = True, _live_ops: set[Operation] = set[Operation]()) -> None
¶
is_live(op: Operation) -> bool
¶
set_live(op: Operation)
¶
propagate_op_liveness(op: Operation)
¶
Source code in xdsl/transforms/dead_code_elimination.py
propagate_region_liveness(region: Region)
¶
Source code in xdsl/transforms/dead_code_elimination.py
delete_dead(region: Region, listener: PatternRewriterListener | None)
¶
Source code in xdsl/transforms/dead_code_elimination.py
DeadCodeElimination
dataclass
¶
Bases: ModulePass
Source code in xdsl/transforms/dead_code_elimination.py
would_be_trivially_dead(op: Operation)
¶
Returns if the operation would be dead if all its results were dead.
Source code in xdsl/transforms/dead_code_elimination.py
is_trivially_dead(op: Operation)
¶
Returns if the operation has no observable effect.
result_only_effects(rootOp: Operation) -> bool
¶
Returns if we can ensure the operation would have no observable effect beyond its returned values.
cf MLIR's WouldOpBeTriviallyDead: https://mlir.llvm.org/doxygen/namespacemlir.html#a655db45ed8c23d04d5ed5ee0abe041ad
We have one key difference here: - MLIR discard any allocation from an operation on its own result for this analysis - xDSL discard any allocation effect of any nested operation on any value defined by the root operation or its children.
Source code in xdsl/transforms/dead_code_elimination.py
dce(op: ModuleOp)
¶
Removes operations annotated with the Pure trait, where results have no uses.
Modifies input module in-place.