Tag all SetAttr ops in the basic blocks that initialize attributes. Initialization ops assume that the previous attribute value is the error value, so there's no need to decref or check for definedness.
(
blocks: list[BasicBlock],
self_reg: Register,
maybe_defined: AnalysisResult[str],
dirty: AnalysisResult[None],
)
| 262 | |
| 263 | |
| 264 | def mark_attr_initialization_ops( |
| 265 | blocks: list[BasicBlock], |
| 266 | self_reg: Register, |
| 267 | maybe_defined: AnalysisResult[str], |
| 268 | dirty: AnalysisResult[None], |
| 269 | ) -> None: |
| 270 | """Tag all SetAttr ops in the basic blocks that initialize attributes. |
| 271 | |
| 272 | Initialization ops assume that the previous attribute value is the error value, |
| 273 | so there's no need to decref or check for definedness. |
| 274 | """ |
| 275 | for block in blocks: |
| 276 | for i, op in enumerate(block.ops): |
| 277 | if isinstance(op, SetAttr) and op.obj is self_reg: |
| 278 | attr = op.attr |
| 279 | if attr not in maybe_defined.before[block, i] and not dirty.after[block, i]: |
| 280 | op.mark_as_initializer() |
| 281 | |
| 282 | |
| 283 | GenAndKill = tuple[set[str], set[str]] |
no test coverage detected
searching dependent graphs…