Skip to content

mir-lower: preserve assertion source locations - #1124

Merged
nihalpasham merged 1 commit into
mainfrom
fix/debug-assert-source-locations
Aug 28, 2026
Merged

nihalpasham merged 1 commit into
mainfrom
fix/debug-assert-source-locations

Conversation

@nihalpasham

@nihalpasham nihalpasham commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Out-of-bounds device accesses now stop on the expression that failed, instead
of jumping back to the kernel declaration.

Before
input[tid] ──> branch @ line 494 ──> trap @ line 487
                                         └─ cuda-gdb stops at the function

After
input[tid] ──> branch ──> trap ──> unreachable
                line 494   line 494   line 494
                                         └─ cuda-gdb stops at input[tid]

Closes #1118.

Changes

  • Preserve the MIR assertion's source location on the generated branch, trap,
    and unreachable.
  • Keep the shared llvm.trap declaration locationless.
  • Check all three generated instructions in the lowering regression.

Antoine Martin first found this path and prototyped the behavior in the internal
cuda-devtools branch. This is an independent signed implementation for the
public repository.

Testing

  • mir-lower: 270 unit + 127 integration tests passed.

  • Optimized and unoptimized LLVM shapes keep distinct assertion locations.

  • CUDA 13.3 / RTX 5090: T36 stops on input[tid] at line 494; the old build
    stopped on the function declaration at line 487.

  • just check passes (focused and affected suites pass)

  • Live GPU debugger regression exercised

  • New example added (not needed; focused regression added)

Checklist

  • All commits signed off (git commit -s)
  • SPDX headers on new source files (no new source files)

Questions about the review? Ping us in #contributors on Discord.

Propagate MIR assertion locations to the generated LLVM branch, trap call, and unreachable instruction so cuda-gdb stops on the failing source expression instead of the enclosing function.

Signed-off-by: nihalp <[email protected]>
@nihalpasham nihalpasham added bug Something isn't working debug info Debug information in generated PTX/IR (line/source maps) codegen Device code-generation pipeline (Rust MIR to IR to PTX) IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) labels Aug 21, 2026
@nihalpasham
nihalpasham marked this pull request as ready for review August 28, 2026 11:22
@nihalpasham
nihalpasham merged commit 47c722f into main Aug 28, 2026
50 checks passed
@nihalpasham
nihalpasham deleted the fix/debug-assert-source-locations branch August 28, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working codegen Device code-generation pipeline (Rust MIR to IR to PTX) debug info Debug information in generated PTX/IR (line/source maps) IR-lowering Lowering between dialects (dialect-mir to LLVM dialect)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug info: preserve MIR assert locations on generated traps

1 participant