Skip to content

bugc: preserve the call-site source range through inlining#267

Merged
gnidan merged 1 commit into
mainfrom
compiler-o3-callsite
Jul 16, 2026
Merged

bugc: preserve the call-site source range through inlining#267
gnidan merged 1 commit into
mainfrom
compiler-o3-callsite

Conversation

@gnidan

@gnidan gnidan commented Jul 16, 2026

Copy link
Copy Markdown
Member

Follow-up to #263 (call-site source range on invoke/return), covering
the inlined case.

When a call is inlined at O2/O3, the real call instruction — which
mapped to the call expression (square(a)) — is replaced by the
spliced callee body, and jump-optimization folds the entry jump that
carried the call-site range. So the inlined code mapped only to the
callee's definition (x * x); the call site itself mapped to no
instruction, and stepping-by-source couldn't reach it.

This gathers the call-site code range onto the entry inlined
instruction, alongside the callee-body range it collides with. Two
source ranges genuinely apply to that instruction — the call site and
the callee body — so they gather (per the context-composition
guidance: colliding keys gather). The callee-body context keeps its
invoke/transform siblings as a single gather child, so consumers
that walk gather still find those discriminators on a leaf rather than
as siblings of gather.

Verified: at O2 and O3 the inlined instruction carries two distinct
code ranges, one of which is the call expression; O0 is unaffected
(no inlining); runtime behavior unchanged at every level.

Deferred (unchanged from #263): the TCO back-edge JUMP still needs the
call-site loc threaded into the tail-call IR object — separate.

When a call is inlined, the real call instruction — which mapped to
the call expression (e.g. `square(a)`) — is replaced by the spliced
callee body, and jump-optimization later folds the entry jump that
carried the call-site range. So at O2/O3 the call site mapped to no
instruction, even though the callee body still mapped (to the
callee's source).

Preserve it: gather the call-site `code` range onto the entry
inlined instruction, alongside the callee-body range it collides
with. Two source ranges apply to that instruction (the call site and
the callee body), so they gather. The callee-body context keeps its
invoke/transform siblings as a single gather child, so consumers
still find those discriminators on a leaf rather than as siblings of
`gather`.
@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-16 07:08 UTC

@gnidan
gnidan merged commit 815102a into main Jul 16, 2026
4 checks passed
@gnidan
gnidan deleted the compiler-o3-callsite branch July 16, 2026 07:04
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