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
71 72 73 74 75 76 77 78 | |
match_and_rewrite(op: Operation, rewriter: PatternRewriter)
Source code in xdsl/transforms/dead_code_elimination.py
76 77 78 | |
LiveSet
dataclass
Source code in xdsl/transforms/dead_code_elimination.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
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
Source code in xdsl/transforms/dead_code_elimination.py
97 98 | |
set_live(op: Operation)
Source code in xdsl/transforms/dead_code_elimination.py
100 101 102 103 | |
propagate_op_liveness(op: Operation)
Source code in xdsl/transforms/dead_code_elimination.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
propagate_region_liveness(region: Region)
Source code in xdsl/transforms/dead_code_elimination.py
121 122 123 124 125 126 127 128 | |
delete_dead(region: Region, listener: PatternRewriterListener | None)
Source code in xdsl/transforms/dead_code_elimination.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
DeadCodeElimination
dataclass
Bases: ModulePass
Source code in xdsl/transforms/dead_code_elimination.py
164 165 166 167 168 | |
name = 'dce'
class-attribute
instance-attribute
apply(ctx: Context, op: ModuleOp) -> None
Source code in xdsl/transforms/dead_code_elimination.py
167 168 | |
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
22 23 24 25 26 27 28 29 30 | |
is_trivially_dead(op: Operation)
Returns if the operation has no observable effect.
Source code in xdsl/transforms/dead_code_elimination.py
33 34 35 36 37 38 39 | |
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
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
dce(op: ModuleOp)
Removes operations annotated with the Pure trait, where results have no uses.
Modifies input module in-place.
Source code in xdsl/transforms/dead_code_elimination.py
81 82 83 84 85 86 87 88 89 | |
region_dce(region: Region, listener: PatternRewriterListener | None = None) -> bool
Source code in xdsl/transforms/dead_code_elimination.py
153 154 155 156 157 158 159 160 161 | |