[all-commits] [llvm/llvm-project] a0ad24: [SPIRV] Emit NonSemantic DebugDeclare, DebugExpres...

Manuel Carrasco via All-commits all-commits at lists.llvm.org
Fri Sep 11 08:36:35 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a0ad24fcdca9722bdd6bb5770eb5986d15e2e9c1
      https://github.com/llvm/llvm-project/commit/a0ad24fcdca9722bdd6bb5770eb5986d15e2e9c1
  Author: Manuel Carrasco <Manuel.Carrasco at amd.com>
  Date:   2026-09-11 (Fri, 11 Sep 2026)

  Changed paths:
    M llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.cpp
    M llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.h
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare-access-chain.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare-dbg-value-variadic.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare-dead-alloca.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare-expression-unsupported.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare-expression-xderef.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare-function-parameter.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare-int-storage.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare-line-scope.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare-module-scope-variable.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare-null-storage.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare-poison-storage.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare-skip-type.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-declare.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-expression-bit-piece.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-expression-cache.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-expression-operation-cache.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-expression-operations.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-expression-out-of-range.ll
    A llvm/test/CodeGen/SPIRV/debug-info/debug-global-variable-constant-value.ll
    M llvm/test/CodeGen/SPIRV/debug-info/debug-global-variable-init-expr.ll
    M llvm/test/CodeGen/SPIRV/debug-info/debug-local-variable-dbg-value.ll

  Log Message:
  -----------
  [SPIRV] Emit NonSemantic DebugDeclare, DebugExpression and DebugOperation (#222011)

Add support for
[DebugDeclare](https://github.khronos.org/SPIRV-Registry/nonsemantic/NonSemantic.Shader.DebugInfo.html#DebugDeclare),
[DebugExpression](https://github.khronos.org/SPIRV-Registry/nonsemantic/NonSemantic.Shader.DebugInfo.html#DebugExpression)
and
[DebugOperation](https://github.khronos.org/SPIRV-Registry/nonsemantic/NonSemantic.Shader.DebugInfo.html#DebugOperation).

Changes:
- Emit DebugDeclare from an indirect DBG_VALUE whose location register
is defined by OpVariable, which is what the spec requires of the
Variable operand. LLVM IR `#dbg_declare` does not survive as its own
opcode in MIR, `IRTranslator` [lowers
it](https://github.com/llvm/llvm-project/blob/06d0711313b763b65c7e4a9e8613893d7760b6f6/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp#L4592-L4596)
to an indirect DBG_VALUE.
- DebugDeclare has a `Indexes` operand that didn't find necessary to
implement. The SPIRV-LLVM Translator has no support for it either in
both modes (ir <-> spv).
- The following cases are unhandled to avoid emitting invalid code (see
below comment about spirv-val):
- an access chain into a field
([debug-declare-access-chain.ll](https://github.com/llvm/llvm-project/blob/users/mgcarrasco/nsdi-debug-declare-new/llvm/test/CodeGen/SPIRV/debug-info/debug-declare-access-chain.ll))
- an OpFunctionParameter for a byval argument
([debug-declare-function-parameter.ll](https://github.com/llvm/llvm-project/blob/users/mgcarrasco/nsdi-debug-declare-new/llvm/test/CodeGen/SPIRV/debug-info/debug-declare-function-parameter.ll))
- a constant address
([debug-declare-int-storage.ll](https://github.com/llvm/llvm-project/blob/users/mgcarrasco/nsdi-debug-declare-new/llvm/test/CodeGen/SPIRV/debug-info/debug-declare-int-storage.ll))
- a register left without a def after dead storage was erased
([debug-declare-dead-alloca.ll](https://github.com/llvm/llvm-project/blob/users/mgcarrasco/nsdi-debug-declare-new/llvm/test/CodeGen/SPIRV/debug-info/debug-declare-dead-alloca.ll))
- a variadic #dbg_value
([debug-declare-dbg-value-variadic.ll](https://github.com/llvm/llvm-project/blob/users/mgcarrasco/nsdi-debug-declare-new/llvm/test/CodeGen/SPIRV/debug-info/debug-declare-dbg-value-variadic.ll))
- an expression using an unmapped operation
([debug-declare-expression-unsupported.ll](https://github.com/llvm/llvm-project/blob/users/mgcarrasco/nsdi-debug-declare-new/llvm/test/CodeGen/SPIRV/debug-info/debug-declare-expression-unsupported.ll))
- a variable whose DebugLocalVariable was not emitted
([debug-declare-skip-type.ll](https://github.com/llvm/llvm-project/blob/users/mgcarrasco/nsdi-debug-declare-new/llvm/test/CodeGen/SPIRV/debug-info/debug-declare-skip-type.ll))
- Collect expressions from MIR, so DebugExpression and DebugOperation
are emitted at module scope and shared by every declare using the same
DIExpression.
- Map the nine operations the instruction set defines, and reject an
expression whole when an argument does not fit in 32 bits (as per spec).
- Cache DebugLocalVariable result ids, which emitDebugLocalVariable
already returned but nothing stored.
- Add tests for each emitted and skipped case, for the interaction with
DebugLine and DebugScope, and for the expression operations.

spirv-val and the spec disagree in two places, in opposite directions:
- DebugDeclare's Variable operand: spirv-val accepts an
OpFunctionParameter, while the spec names only OpVariable. This patch
follows the spec, so the byval case is skipped even though spirv-val
would take it, see
[debug-declare-function-parameter.ll](https://github.com/llvm/llvm-project/blob/users/mgcarrasco/nsdi-debug-declare-new/llvm/test/CodeGen/SPIRV/debug-info/debug-declare-function-parameter.ll).
- DebugGlobalVariable's Variable operand: spirv-val rejects a
DebugExpression there although the spec permits one,
KhronosGroup/SPIRV-Tools#6469, see
[debug-global-variable-constant-value.ll](https://github.com/llvm/llvm-project/blob/users/mgcarrasco/nsdi-debug-declare-new/llvm/test/CodeGen/SPIRV/debug-info/debug-global-variable-constant-value.ll).



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list