Repository navigation
Conversation
A backward liveness pass over the DFA, run at the end of compile_ir. A register is live at a state if some path from it reads it before writing it: as the source of a Copy whose destination is live, or of a final operation writing a cell an action reads. Writes to dead registers are dropped, as are final operations writing a cell no binding names, and the cells left are renumbered densely, the bindings following. Dead writes come from rules that a higher-priority rule beats on some or all of their matches: the tag was written on a transition shared with the winning rule's path, but never read there. They also come from anything that later prunes the automaton, such as shortest match or unused boundary tags. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
A backward liveness pass over the DFA that removes the register writes no path reads, run at the end of
compile_ir.The pass
remove_dead ~rootstakes as roots the cells the bindings read. A register is live on entering a state if some path from it reads it before writing it: as the source of a transitionCopywhose destination is live, or as the source of a final operation writing a root. Liveness is a fixpoint over that equation; thenAbout a hundred self-contained lines. The liveness it computes is the input #210 needs, so that draft can adopt it when it is rebased.
Where dead writes come from
Rules that a higher-priority rule beats on some or all of their matches: the tag was written on a transition shared with the winning rule's path, and is never read there. Anything that later prunes the automaton also produces them: shortest match (#180), or unused boundary tags if the rest of #193 is revisited.
Verified effect
Each test pattern was generated with and without the pass before being pinned.
Plus 'a', Plus 'b'beats(Plus 'a' as x), (Plus 'b' | Plus 'c')on every'b'tail. The write of x's end on the'b'transition goes, the one on'c'stays, and cells drop from 3 to 2. A runtime test checks x on both tails and the cell count.init_mem 1). Dropping it too would need the PPX to skip the bindings of rules that never accept; left as is for now.No pre-existing expect block changes: master's automata have no dead writes outside these shapes.
🤖 Generated with Claude Code