Skip to content

ethdebug: Attach semantic debug info to Yul nodes and survive the text round trip - #8

Open
djolertrk wants to merge 1 commit into
feature/ethdebug-semantic-builderfrom
feature/ethdebug-yul-side-table
Open

djolertrk wants to merge 1 commit into
feature/ethdebug-semantic-builderfrom
feature/ethdebug-yul-side-table

Conversation

@djolertrk

Copy link
Copy Markdown
Collaborator

Attach the scope records of the side table to Yul AST nodes through DebugData, keyed by (AST ID, instance), and keep them across the Yul -> text -> Yul reparse the compiler performs after optimization: records are collected from the AST into the retained table before printing and reattached by their @ast-id annotations after parsing.

Attaching re-checks every pointer against the current code: a materialized variable (or update) whose pointer reads a generated Yul local that no longer exists becomes optimized-out instead of keeping a stale pointer. The check is scoped per object.

Scope instances travel in the new @ast-id-instance annotation next to @ast-id, so passes that clone code can give each copy its own records; code generation only produces instance 0. Contract-level scopes attach to the top-level block of each object, which now carries the contract's AST ID. Blocks generated by the function grouper and hoister keep locations only, so they do not inherit another node's identity.

CompilerStack stores the attached table on the contract; it pairs with the unoptimized IR, whose generated locals it references. The golden tests now show Contract.semantic as attached.

@djolertrk
djolertrk added this pull request to stack #6 October 5, 2026 08:19
@djolertrk

Copy link
Copy Markdown
Collaborator Author

cc @cameel

@djolertrk
djolertrk force-pushed the feature/ethdebug-yul-side-table branch from 7f09c73 to ca84699 Compare October 8, 2026 13:47
@djolertrk
djolertrk force-pushed the feature/ethdebug-yul-side-table branch from ca84699 to 7d89200 Compare October 9, 2026 10:51
@djolertrk
djolertrk force-pushed the feature/ethdebug-yul-side-table branch from 7d89200 to f82d0f4 Compare October 9, 2026 12:45
@djolertrk
djolertrk force-pushed the feature/ethdebug-yul-side-table branch from f82d0f4 to af85835 Compare October 16, 2026 12:00
…t round trip

Attach the scope records of the side table to Yul AST nodes through
DebugData, keyed by (AST ID, instance), and keep them across the
Yul -> text -> Yul reparse the compiler performs after optimization:
records are collected from the AST into the retained table before
printing and reattached by their @ast-id annotations after parsing.

Attaching re-checks every pointer against the current code: a
materialized variable (or update) whose pointer reads a generated Yul
local that no longer exists becomes optimized-out instead of keeping a
stale pointer. The check is scoped per object.

Scope instances travel in the new @ast-id-instance annotation next to
@ast-id, so passes that clone code can give each copy its own records;
code generation only produces instance 0. Contract-level scopes attach
to the top-level block of each object, which now carries the contract's
AST ID. Blocks generated by the function grouper and hoister keep
locations only, so they do not inherit another node's identity.

CompilerStack stores the attached table on the contract; it pairs with
the unoptimized IR, whose generated locals it references. The golden
tests now show Contract.semantic as attached.
@djolertrk
djolertrk force-pushed the feature/ethdebug-yul-side-table branch from af85835 to 664ca54 Compare October 19, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant