(ir: FuncIR, strict_traceback_checks: bool)
| 40 | |
| 41 | |
| 42 | def insert_exception_handling(ir: FuncIR, strict_traceback_checks: bool) -> None: |
| 43 | # Generate error block if any ops may raise an exception. If an op |
| 44 | # fails without its own error handler, we'll branch to this |
| 45 | # block. The block just returns an error value. |
| 46 | error_label: BasicBlock | None = None |
| 47 | for block in ir.blocks: |
| 48 | adjust_error_kinds(block) |
| 49 | if error_label is None and any(op.can_raise() for op in block.ops): |
| 50 | error_label = add_default_handler_block(ir) |
| 51 | if error_label: |
| 52 | ir.blocks = split_blocks_at_errors( |
| 53 | ir.blocks, error_label, ir.traceback_name, strict_traceback_checks |
| 54 | ) |
| 55 | |
| 56 | |
| 57 | def add_default_handler_block(ir: FuncIR) -> BasicBlock: |
searching dependent graphs…