Repository navigation
bugc: mark a function's return on its exit jump - #349
Merged
Merged
Conversation
gnidan
force-pushed
the
bugc-return-at-exit
branch
from
October 7, 2026 00:21
0346f89 to
5883000
Compare
Contributor
|
Put the return context on the callee's JUMP back to the caller, with the return value at stack slot 0, and leave the continuation JUMPDEST with only the call site's code range. buildCallStack now pops a frame on the return's postcondition step instead of one step later.
gnidan
force-pushed
the
bugc-return-at-exit
branch
from
October 7, 2026 00:29
5883000 to
a42be64
Compare
This was referenced Oct 7, 2026
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.
bugc put a function's
returncontext on the caller's continuationJUMPDEST, one instruction after the callee'sJUMPback. Since instruction contexts are postconditions, and the trace viewer'sbuildCallStackpopped a frame one step after the step that observes areturn, the callee's frame stayed on the call stack for two steps after control was back in the caller. The entry side was already exact.This moves the
returnto the callee's exitJUMP, where the format's documentation (the tracing guide and the return context spec page) already says it goes. After thatJUMPruns, the return value is at stack slot 0, as it was after the continuationJUMPDEST, sodatakeeps the same pointer; it is left out when there is no value. The continuationJUMPDESTkeeps only the call site'scoderange.buildCallStacknow pops a frame on the step that observes thereturn, so a real call's frame is on from the callee's entryJUMPDESTthrough its exitJUMPand gone at the first step back in the caller.A function with several return statements gets a
returnon each exit. Tail-call back-edges and inlined bodies keep their contexts as they were. A new test checks the timing against real traces at every optimization level, for nested calls, recursion and a function with two exits, and reads the return value through each exit'sdatapointer.This aligns bugc with the documented placement and makes frame timing exact for real calls; the larger question of what each edge of a call should be marked with is #348. Known gaps that remain:
invokeand itsreturn, so no step shows its frame. Before, the frame showed for one step, on the caller's next instruction.JUMPDEST. The callee's exit cannot list them, since a function can have several callers.invokeis on the body's first instruction.