Skip to content

fix(cutile-compiler): preserve origins of short-circuit, folded and bool-binding constants - #1528

Open
GiGiKoneti wants to merge 2 commits into
NVIDIA:mainfrom
GiGiKoneti:fix/cutile-short-circuit-spans
Open

GiGiKoneti wants to merge 2 commits into
NVIDIA:mainfrom
GiGiKoneti:fix/cutile-short-circuit-spans

Conversation

@GiGiKoneti

@GiGiKoneti GiGiKoneti commented Oct 16, 2026 •

Copy link
Copy Markdown

Short-circuit and folded constants can inherit a synthetic type's module-header location or an operand's definition instead of the expression that produces them. Pass the expression span into constant construction so Line and Full debug modes preserve the expression's file, line and nested inline callers.

Const-bool bindings in entries, functions and methods use the corresponding callee signature. Resolving caller coordinates in a callee scope could otherwise attach the binding to the wrong file/line.

The new constant_source_locations CPU CI target checks deciding false/true constants, a folded expression on a different line from its operands, and all three binding contexts. It verifies exact cross-file caller chains both in the IR and after bytecode serialization.

Validation: all three regressions pass and fail on the earlier compiler; selectively restoring the old folded-expression span fails its dedicated regression. Existing debug/generated-source tests, assembler/GPU/CUDA-GDB checks, formatting and strict Clippy pass on CUDA 13.3. Combined debug validation in #1613 passes all 35 tests. CI and review remain required before merge.

Part of #1475; v0.5.0 tracking: #1606.

…pression span

Short-circuit boolean operations (`a && b`, `a || b`) generate deciding
constants when the left-hand operand decides the outcome. Previously,
`compile_bool_constant` created constants from synthesized `bool` type
spans, resolving to fallback module-header locations.

Pass the logical expression's span through `compile_bool_constant` and the
shared constant builder (`compile_constant_from_exact_bounds`), ensuring
the resulting constant operation receives the exact expression line while
preserving inlined helper scopes and call chains.

Add regression test in `debug_info.rs` verifying source line attribution
and inline caller provenance for both direct and inlined expressions.

Part of NVIDIA#1475.

Signed-off-by: GiGiKoneti <gigikoneti@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 16, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@elibol

elibol commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Reviewing this against the short-circuit item assigned in #1475. The new test checks a direct || constant and an inlined && constant, including the caller line, which matches that scope.

Before considering those sub-items covered:

  • Run the exact-location checks in both Line and Full, and add a helper from another file. Assert the file, subprogram, and complete nested caller chain as well as the expression line, then verify the relevant location survives bytecode serialization. Include both deciding values (false for &&, true for ||).
  • The diff also changes the constant-folding call to compile_constant_from_exact_bounds to pass the expression span. Please add a dedicated regression that forces that path (for example, a folded arithmetic expression used by the kernel), checks its original expression location and inline chain, and fails before this change. The current boolean test does not establish the constant-folding item in cuTile: audit generated source locations (optional follow-ups to #1379) #1475. If that change remains, describe both covered items in the PR.
  • The shared-builder signature also updates const-bool entry/function/method bindings. Exercise those paths to pin the intended binding/call-site locations, and check compatibility with fix: correct cuTile source locations for generated constants #1385's location fallback rather than relying on it to supply the expression span.

Please record the focused fail-before/pass-after result. Wrapper locations, arrays, reductions, and injected checks remain separate #1475 work; this PR should not close the entire audit or claim to fix backend assertion traps.

…nance

Integrate current main. Attribute inlined boolean bindings to callee definitions instead of resolving caller coordinates in the callee module. Cover deciding false/true constants, a folded expression on a different line from its operands, and entry/function/method bindings in Line and Full modes with exact serialized inline chains.

Signed-off-by: Melih Elibol <1884921+elibol@users.noreply.github.com>
@elibol

elibol commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

/ok to test 64f0ebf

@elibol

elibol commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Pushed 64f0ebf4ae61541eb2b2fe9c2ae4cac465a09e12, merging current main and addressing the outstanding test feedback.

Fixed a const-bool attribution issue in the proposed change: function/method bindings resolved a caller expression span inside the callee scope. They now use the callee signature, matching const-array bindings.

The new CPU CI target checks deciding false/true short-circuit constants, a folded expression on a different line from both operands, and entry/function/method const-bool bindings. It covers Line/Full, cross-file nested callers and exact serialized chains. Regressions fail on the earlier compiler; reverting only the folded-expression span also fails its dedicated test.

All three new tests and the existing debug/generated-source suites pass on CUDA 13.3, including assembler/GPU/CUDA-GDB. Strict Clippy for the new target and formatting pass. Combined source-location/debug-mode validation in #1613 passes all 35 tests. Fresh CI is running. This covers the short-circuit/folded-expression/const-bool portion of #1475; tracked in #1606.

@elibol elibol changed the title fix(cutile-compiler): attribute short-circuit boolean constants to expression span fix(cutile-compiler): preserve origins of short-circuit, folded and bool-binding constants Oct 26, 2026
@elibol
elibol marked this pull request as ready for review October 26, 2026 20:13
@elibol
elibol self-requested a review as a code owner October 26, 2026 20:13

This branch has not been deployed

No deployments
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.

2 participants