Skip to content

bugc: leave the jump past an inlined return out of the inlined body - #347

Merged
gnidan merged 1 commit into
mainfrom
bugc-inline-return-jump
Oct 6, 2026
Merged

gnidan merged 1 commit into
mainfrom
bugc-inline-return-jump

Conversation

@gnidan

@gnidan gnidan commented Oct 6, 2026

Copy link
Copy Markdown
Member

At optimization levels 2 and 3, bugc replaces an inlined call's return with a jump to the caller's continuation. Since #341, the inlined function's return context rides the body's last instruction, and that jump keeps the caller's source range, inline sites and variables. But it also kept a transform: ["inline"] context, though it runs after the return.

ethdebug/format/program/context/transform says "inline" marks an instruction that is part of an inlined function body, with the surrounding invoke/return contexts naming the callee. The jump is past the return, so no invoke/return surrounds it. A debugger that reads the transform then puts the jump in an inlined body that has already returned. In the blog's debugger demo (scores.bug at -O2, where sq is inlined), the Inlining panel read "body of ?, inlined at line -1" on those steps, while the call stack, built from the invoke and return contexts, had no inlined frame.

This removes the transform from that jump, and with it the placement helper that only that site used. A new test in inline-bracket.test.ts checks that every op with the inline transform sits between an inlined invoke and its return.

At optimization levels 2 and 3, the jump from an inlined body to the
caller's continuation runs after the inlined function's return, so it is
the caller's code. It kept a transform: ["inline"] context, so a debugger
that reads the transform put that jump in an inlined body that had
already returned, with no function or call site to name.
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-06 23:50 UTC

gnidan added a commit to ethdebug/argot-post-2026-10 that referenced this pull request Oct 6, 2026
The Inlining panel took its marker from the transform of the
instruction about to run, while the call stack applies each
instruction's context after it runs (contexts are postconditions). So
the panel opened an inlined body one step before the call stack, and
closed it one step before too. On the jump past sq's return, which
bugc marks inline (ethdebug/format#347), it read "body of ?, inlined at
line -1".

Now the panel's marker comes from the call stack: a step is in an
inlined body when its innermost frame is an inlined one, and the panel
names that frame's function and call site. run.mjs checks that the two
agree at every step, that neither reads "?" or "-1", and that sq's
steps run from its inlined invoke to its inlined return.
@gnidan
gnidan merged commit b7ae5fe into main Oct 6, 2026
7 checks passed
@gnidan
gnidan deleted the bugc-inline-return-jump branch October 7, 2026 00:00
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