◐ Shell
clean mode source ↗

Bytecode parity CFG normalization and jump cleanup by youknowone · Pull Request #7721 · RustPython/RustPython

Reorder try/except/else/finally to emit else+finally before
except handlers matching CPython layout. Add set_no_location
for cleanup blocks. Extend CFG reorder pass to handle true-path
jump-back for generators, break/continue, and assert in loops.
Add stop-iteration error handler awareness to block protection.
remove_nops and remove_redundant_nops_in_blocks repeated
has_jump_predecessor / has_plain_jump_predecessor / target lookups
per block, scanning all blocks each time. With ~200,000 if blocks
this became O(B^2 * I) and timed out test_compile.test_stack_overflow.
Fold the three flags into one O(B * I) pass via
compute_target_predecessor_flags.

youknowone

coderabbitai[bot]

- try_fold_constant_slice now delegates to try_fold_constant_expr so
  slice bounds accept the same constants other folding paths do
  (unary-folded values, __debug__, etc.).
- remove_nops resolves fallthrough predecessors through empty blocks
  via next_nonempty_block before checking ends_with_for_cleanup.
- should_deopt_borrowed_attr_chain ReturnIter matcher now accepts
  Instruction::CallKw alongside Instruction::Call, matching the
  Call/CallKw treatment in the surrounding deopt trigger check.

coderabbitai[bot]

@youknowone youknowone changed the title Bytecode parity cfg Bytecode parity CFG normalization and jump cleanup

Apr 30, 2026

@youknowone

This was referenced

May 1, 2026

This was referenced

May 11, 2026

This was referenced

May 19, 2026