Skip to content

Support multi-value debug locations for runtime-computed variables #1082

Closed

Description

@uurl

Summary

Full device debug metadata currently supports variable locations that can be described from a single SSA value or a statically projected address.

Some source-level variable locations, however, depend on multiple runtime SSA values. A runtime-indexed projection is the motivating example:

*(base + index * stride)

LLVM represents these locations with a DIArgList and a DIExpression containing DW_OP_LLVM_arg selectors.

This issue tracks the generic multi-value debug-location infrastructure needed to represent and export those expressions.

Part of #226.

Motivation

Static projections can be represented with fixed byte offsets, but runtime-dependent locations cannot be encoded with DW_OP_plus_uconst alone.

For example, a runtime array projection requires both:

  • the base address
  • the runtime index value

and a location expression equivalent to:

base + index * stride

The debug pipeline therefore needs a way to carry multiple ordered SSA operands together with a typed location expression.

Proposed scope

  • add a MIR debug marker carrying multiple ordered SSA values

  • preserve the marker through MIR-to-LLVM lowering

  • add an LLVM-export marker carrying the same ordered operands

  • introduce a typed representation for the required debug-expression operations

  • export multi-value locations as:

    llvm.dbg.value(
        metadata !DIArgList(...),
        metadata !<variable>,
        metadata !DIExpression(...)
    )
  • support the initial expression operations required for computed addresses:

    • DW_OP_LLVM_arg
    • DW_OP_constu
    • DW_OP_plus
    • DW_OP_plus_uconst
    • DW_OP_mul
    • DW_OP_deref
    • DW_OP_stack_value
  • reject invalid operand references and malformed multi-value locations

  • validate emitted IR with llvm-as

Non-goals

This issue does not yet add Rust MIR ProjectionElem::Index translation.

Runtime-indexed array projections will be implemented separately on top of this infrastructure.

It also does not:

  • migrate existing debug intrinsics to LLVM debug records
  • add slice or subslice projections
  • add fat-pointer projections
  • add multiple runtime-index projections
  • change existing single-value debug-location behavior

Acceptance criteria

  • multi-value debug operands survive MIR-to-LLVM lowering in order
  • typed debug expressions survive lowering unchanged
  • LLVM export emits DIArgList
  • DW_OP_LLVM_arg references are bounds-checked
  • generated multi-value debug IR parses successfully with llvm-as
  • existing debug-info behavior remains unchanged
  • relevant unit tests and workspace Clippy remain green

Activity

  1. changed the title [-]Support multi-value debug locations for computed variable locations[/-] [+]Support multi-value debug locations for computed variables[/+] on Aug 20, 2026
  2. changed the title [-]Support multi-value debug locations for computed variables[/-] [+]Support multi-value debug locations for runtime-computed variables[/+] on Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions