GeezerVison is showing github.com — Move free standing `ir::Block` functions to methods by ShaharNaveh · Pull Request #8205 · RustPython/RustPython
Conversation
ShaharNaveh
commented
Jul 1, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Summary by CodeRabbit
-
Refactor
- Streamlined internal block-handling logic in the code generation pipeline.
- Improved consistency across control-flow handling, optimization passes, and instruction management.
-
Tests
- Updated unit coverage to match the revised block-handling behavior and helper APIs.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Jul 1, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

📝 Walkthrough
Walkthrough
Basic-block helper free functions in the codegen IR module were converted into methods on the Block type. All call sites in CFG construction, optimization passes (fallthrough checks, static swaps, constant folding, jump normalization), and unit tests were updated to use the new method-based API. No public API signatures changed.
Changes
Block Method Refactor
| Layer / File(s) |
Summary |
New Block methods and removal of old free functions crates/codegen/src/ir.rs |
Free functions for basic-block slot management, fallthrough/cold checks, and static-swap optimization are turned into Block methods, replacing the earlier standalone implementations. |
CFG builder and Blocks wiring crates/codegen/src/ir.rs |
Blocks CFG passes and CFG builder helpers now call Block methods for clearing blocks, fallthrough checks, and last/raw-first instruction access. |
Optimization pass call-site updates crates/codegen/src/ir.rs |
Load-fast threading, line-number propagation, nop/pair removal, stackdepth calculation, warm/cold marking, cold-block pushing, jump insertion/normalization/removal, CodeInfo helpers, prefix instruction insertion, local-unsafe scanning, exception target labeling, and debug dump logic all switch to the new Block methods. |
Constant folding path updates crates/codegen/src/ir.rs |
Unary/binary op folding, tuple-of-constants folding, and list/set folding use get_const_loading_instrs and nop_out Block methods. |
Unit test updates for new Block APIs crates/codegen/src/ir.rs |
Tests for slot allocation/clearing, static swaps, line-number propagation, and jump threading are updated to call the new Block methods. |
Estimated code review effort: 4 (Complex) | ~60 minutes
Possibly related PRs
- RustPython/RustPython#7541: Both PRs modify the constant/list/set folding paths in the same file that this PR rewires to use the new
Block methods.
- RustPython/RustPython#7578: Both PRs modify CFG block/instruction utilities in the same file, one via jump-threading logic and this one via helper-to-method refactoring.
- RustPython/RustPython#8142: Both PRs refactor CFG/block handling in the same file at the block/CFG utility layer.
Suggested reviewers: youknowone
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name |
Status |
Explanation |
| Description Check |
✅ Passed |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Docstring Coverage |
✅ Passed |
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
✅ Passed |
Check skipped because no linked issues were found for this pull request. |
| Title check |
✅ Passed |
The title accurately summarizes the main refactor of moving free-standing Block helpers into methods. |
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
ShaharNaveh
changed the title
Move free standing Block functions to methods
Move free standing ir::Block functions to methods
Jul 1, 2026
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|