Repository navigation
feat(rewrite): worklist-based fixpoint driver - #854
Open
alexcgatea wants to merge 7 commits into
Open
alexcgatea wants to merge 7 commits into
alexcgatea wants to merge 7 commits into
Conversation
…isit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add Statement::owner, the statement owning a statement's body, replacing the walk module's private parent helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each sweep seeds a worklist with the statements under the root in a snapshot walk (PreOrder by default) and adds back the statements a visit's edits may give a new match. Rules may erase the visited statement in every order; skip has no effect in the driver. Add a per-sweep rewrite limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
alexcgatea
force-pushed
the
alex/queue-based-fixpoint-driver
branch
from
November 12, 2026 13:32
6bbcbe3 to
77d2b50
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
RewriteDriverstill runs a fixpoint of sweeps. Each sweep now visits statements from a worklist instead of walking them in place:The worklist is seeded with every statement under the root, in walk order, as a snapshot taken before any rule runs. The default order is
PreOrder.Statements are popped one at a time, and every rule is tried in order at each, as before.
After each statement, the
MutationEvents of its edits add back the statements they may have given a new match. For each statement an event names as changed, replaced or inserted, the sweep adds, top-down:Statement::owner)A statement still in the queue keeps its place, so it is visited once, after the edit. One already visited goes to the back. Only statements under the root are added, so
run_at(root)never leavesroot's tree.When the worklist is empty, dead code is cleaned up. The run ends after the first sweep that changes nothing.
Edits the worklist doesn't follow, such as erasures and CFG edits, are picked up by the next sweep, which starts from every statement again. So correctness never depends on the worklist being complete.
Behaviour changes
DriverError::ErasesRootandDriverError::Walkare removed. Ordinary walks inkirin_ir::walkkeep their edit contract:ALLOWS_ERASING_VISITEDstill decides whether the visited statement may be erased.skiphas no effect in the driver, because its walk is a snapshot. Ordinary walks inkirin_ir::walkstill honour it.interruptis unchanged: it ends the current sweep, and the run continues if that sweep changed something.max_rewrites_per_sweep(default 10,000). A sweep making more rewrites than that fails withDriverError::RewritesExhausted { root, rewrites }.max_sweepsis unchanged.API
RewriteDriver<'r, L, O: WalkOrder = PreOrder>.kirin-irgains a publicStatement::owner(stage), replacing the walk module's privateparenthelper.