Skip to content

bugc: compose combined debug contexts by gather/flat, not pick#266

Merged
gnidan merged 1 commit into
mainfrom
compiler-combine-gather
Jul 16, 2026
Merged

bugc: compose combined debug contexts by gather/flat, not pick#266
gnidan merged 1 commit into
mainfrom
compiler-combine-gather

Conversation

@gnidan

@gnidan gnidan commented Jul 16, 2026

Copy link
Copy Markdown
Member

combineDebugContexts wrapped multiple combined contexts in a pick
context. But pick means "one of these alternatives is true — choose
one"
(disjunction), whereas the contexts this helper combines — from
constant propagation, common-subexpression elimination, read-write
merging (coalesce), and block merging — all apply simultaneously
(conjunction). That is what gather (and flat composition) mean.

This composes them correctly, following the context-composition guidance:

  • Disjoint discriminator keys → flat — merged into a single object
    with sibling keys (the preferred form).
  • A colliding key (e.g. two code ranges from merged writes)
    gather
    — they cannot be siblings.

Disjoint keys are deliberately not blanket-gathered, which would
re-introduce the over-gathering cleaned up in #258/#259. Enclosing
gather (and legacy pick) wrappers are flattened first so
accumulation re-composes rather than nesting.

Effect: read-write merging (coalesce) now gathers its merged
code ranges instead of pick-ing one. The common single-context case
is unchanged (a normal program emits no gather/pick at O0 or O3).

combineDebugContexts wrapped multiple combined contexts in `pick`,
but pick means "one of these is true (choose one)" — whereas
contexts combined here (constant propagation, CSE, read-write
merging, block merging) ALL apply simultaneously. That is what
`gather` means.

Compose correctly per the context-composition guidance: when the
combined contexts have disjoint discriminator keys, merge them flat
as sibling keys on one object; when a key collides (e.g. two `code`
ranges from merged writes), gather them. Enclosing gather/pick
wrappers are flattened first so they re-compose rather than nest.

Effect: read-write merging (coalesce) now gathers its merged code
ranges instead of picking one.
@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 06:28 UTC

@gnidan
gnidan merged commit 7ee27fc into main Jul 16, 2026
4 checks passed
@gnidan
gnidan deleted the compiler-combine-gather branch July 16, 2026 06:24
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