GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Move free standing `ir::Block` functions to methods by ShaharNaveh · Pull Request #8205 · RustPython/RustPython

Conversation

@ShaharNaveh

@ShaharNaveh ShaharNaveh commented Jul 1, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor
  • Closes #xxxx
  • This PR follows our AI policy

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.

All reactions
ShaharNaveh added 3 commits July 1, 2026 13:20
@ShaharNaveh
Move free standing Block functions to methods
8e361e6
@ShaharNaveh
move more
0da888b
@ShaharNaveh
fix tests
5394f16
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ShaharNaveh ShaharNaveh changed the title Move free standing Block functions to methods Move free standing ir::Block functions to methods Jul 1, 2026
youknowone
youknowone approved these changes Jul 2, 2026
View reviewed changes
@youknowone
youknowone merged commit e7aeaee into RustPython:main Jul 2, 2026
26 checks passed

Uh oh!

There was an error while loading. Please reload this page.

youknowone pushed a commit that referenced this pull request Sep 16, 2026
@ShaharNaveh
Move free standing ir::Block functions to methods (#8205)
7aaf2db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@youknowone youknowone youknowone approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

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.

2 participants

@ShaharNaveh @youknowone
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.