Skip to content

Add multi-value debug location infrastructure - #1083

Merged
nihalpasham merged 1 commit into
NVIDIA:mainfrom
uurl:feat/226-debug-multivalue-locations
Aug 20, 2026
Merged

nihalpasham merged 1 commit into
NVIDIA:mainfrom
uurl:feat/226-debug-multivalue-locations

Conversation

@uurl

@uurl uurl commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Closes #1082
Part of #226

Summary

Add generic multi-value debug-location support to the MIR-to-LLVM debug pipeline.

This provides the infrastructure needed for source-variable locations that depend on more than one runtime SSA value, such as a future runtime-indexed projection:

*(base + index * stride)

Changes

  • add mir.dbg_value_list for ordered multi-value debug operands

  • lower it to a new llvm.dbg_value_list marker

  • add a typed DebugValueExpression representation

  • preserve debug expressions through MIR-to-LLVM lowering

  • export multi-value locations through llvm.dbg.value using DIArgList

  • support:

    • DW_OP_LLVM_arg
    • DW_OP_constu
    • DW_OP_plus
    • DW_OP_plus_uconst
    • DW_OP_mul
    • DW_OP_deref
    • DW_OP_stack_value
  • validate DW_OP_LLVM_arg operand indices during export

  • add lowering coverage for operand ordering and expression preservation

  • add LLVM-export coverage for DIArgList

  • parse the emitted debug module with llvm-as

For example, the expression:

*(base + index * 4)

is represented as:

DW_OP_LLVM_arg, 0
DW_OP_LLVM_arg, 1
DW_OP_constu, 4
DW_OP_mul
DW_OP_plus
DW_OP_deref

with the base and index values carried in the corresponding DIArgList.

Why

Existing projected debug locations use static byte offsets. That is sufficient for fields and constant indices, but not for runtime-dependent projections.

A dynamic array index requires both the base address and the runtime index to remain available to the debugger. LLVM's DIArgList plus DW_OP_LLVM_arg model provides the required representation without materializing a synthetic address computation in executable IR.

Non-goals

This PR only introduces the generic multi-value location machinery.

It does not yet translate ProjectionElem::Index from rustc MIR. That will be implemented as a follow-up using this infrastructure.

It also does not change existing single-value dbg.value behavior or migrate the exporter to LLVM debug records.

Validation

Validated locally with:

cargo fmt --all -- --check
cargo test -p llvm-export full_debug_metadata_emits_diarglist_for_multi_value_locations -- --nocapture
cargo test -p llvm-export --all-targets
cargo test -p mir-lower --all-targets
cargo clippy --workspace --all-targets -- -D warnings

The new multi-value debug test also passes the generated LLVM module through an available llvm-as-22, llvm-as-21, or llvm-as parser.

All validation passed.

@nihalpasham nihalpasham added enhancement New feature or request codegen Device code-generation pipeline (Rust MIR to IR to PTX) IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) llvm-export Textual LLVM/NVVM IR exporter (llvm-export crate) debug info Debug information in generated PTX/IR (line/source maps) labels Aug 20, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator
  • Verified end to end: llvm-export 46+70+3, mir-lower 253+117, dialect-mir tests green, workspace clippy zero errors, fmt clean, compile-only smoketest 216/216. The llvm-as parse gate ran for real (llvm-as-21 and -22 both on PATH), so the textual DIArgList/DW_OP_LLVM_arg output is checked against LLVM's own parser.
  • Adopting LLVM 12's variadic dbg.value representation verbatim is the right mechanism, and keeping this producer-free by design (Support multi-value debug locations for runtime-computed variables #1082 non-goals) leaves the device pipeline untouched.
  • Two non-blocking follow-ups worth an issue: enforce the >=2-operand and expression-presence invariants in the Verify impls, and land the ProjectionElem::Index producer so this stops being test-only infrastructure.

@nihalpasham
nihalpasham merged commit 94f68d8 into NVIDIA:main Aug 20, 2026
49 checks passed
@uurl
uurl deleted the feat/226-debug-multivalue-locations branch August 22, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codegen Device code-generation pipeline (Rust MIR to IR to PTX) debug info Debug information in generated PTX/IR (line/source maps) enhancement New feature or request IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) llvm-export Textual LLVM/NVVM IR exporter (llvm-export crate)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multi-value debug locations for runtime-computed variables

2 participants