(self)
| 396 | jump.hot = True |
| 397 | |
| 398 | def _remove_redundant_jumps(self) -> None: |
| 399 | # Zero-length jumps can be introduced by _insert_continue_label and |
| 400 | # _invert_hot_branches: |
| 401 | for block in self._blocks(): |
| 402 | target = block.target |
| 403 | if target is None: |
| 404 | continue |
| 405 | target = target.resolve() |
| 406 | # Before: |
| 407 | # jmp FOO |
| 408 | # FOO: |
| 409 | # After: |
| 410 | # FOO: |
| 411 | if block.link and target is block.link.resolve(): |
| 412 | block.target = None |
| 413 | block.fallthrough = True |
| 414 | block.instructions.pop() |
| 415 | # Before: |
| 416 | # branch FOO: |
| 417 | # ... |
| 418 | # FOO: |
| 419 | # jump BAR |
| 420 | # After: |
| 421 | # br cond BAR |
| 422 | # ... |
| 423 | elif ( |
| 424 | len(target.instructions) == 1 |
| 425 | and target.instructions[0].kind == InstructionKind.JUMP |
| 426 | ): |
| 427 | assert target.target is not None |
| 428 | assert target.target.label is not None |
| 429 | if block.instructions[ |
| 430 | -1 |
| 431 | ].kind == InstructionKind.SHORT_BRANCH and self._is_far_target( |
| 432 | target.target.label |
| 433 | ): |
| 434 | continue |
| 435 | block.target = target.target |
| 436 | block.instructions[-1] = block.instructions[-1].update_target( |
| 437 | target.target.label |
| 438 | ) |
| 439 | |
| 440 | def _find_live_blocks(self) -> set[_Block]: |
| 441 | live: set[_Block] = set() |
no test coverage detected