[all-commits] [llvm/llvm-project] 3eecc4: [SPIRV] Emit NonSemantic DebugValue (#224158)
Diego Novillo via All-commits
all-commits at lists.llvm.org
Wed Sep 23 08:47:51 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 3eecc4081d4ee225eda7375eee9f79e065f3c411
https://github.com/llvm/llvm-project/commit/3eecc4081d4ee225eda7375eee9f79e065f3c411
Author: Diego Novillo <dnovillo at nvidia.com>
Date: 2026-09-23 (Wed, 23 Sep 2026)
Changed paths:
M llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.cpp
M llvm/lib/Target/SPIRV/SPIRVNonSemanticDebugHandler.h
M llvm/lib/Target/SPIRV/SPIRVPostLegalizer.cpp
M llvm/test/CodeGen/SPIRV/debug-info/debug-declare-dbg-value-variadic.ll
M llvm/test/CodeGen/SPIRV/debug-info/debug-declare.ll
M llvm/test/CodeGen/SPIRV/debug-info/debug-inlined-at.ll
M llvm/test/CodeGen/SPIRV/debug-info/debug-line-selection-merge.ll
M llvm/test/CodeGen/SPIRV/debug-info/debug-local-variable-dbg-value.ll
M llvm/test/CodeGen/SPIRV/debug-info/debug-type-pointer.ll
A llvm/test/CodeGen/SPIRV/debug-info/debug-value-constant-existing-type.ll
A llvm/test/CodeGen/SPIRV/debug-info/debug-value-constant.ll
A llvm/test/CodeGen/SPIRV/debug-info/debug-value-cross-block.ll
A llvm/test/CodeGen/SPIRV/debug-info/debug-value-merge-region.ll
A llvm/test/CodeGen/SPIRV/debug-info/debug-value-module-scope.ll
A llvm/test/CodeGen/SPIRV/debug-info/debug-value-postlegalizer-order.ll
A llvm/test/CodeGen/SPIRV/debug-info/debug-value-typedef-cycle.ll
A llvm/test/CodeGen/SPIRV/debug-info/debug-value-unsupported.ll
A llvm/test/CodeGen/SPIRV/debug-info/debug-value.ll
Log Message:
-----------
[SPIRV] Emit NonSemantic DebugValue (#224158)
This adds support for emitting `DebugValue` in
`SPIRVNonSemanticDebugHandler` for `DBG_VALUE` records.
NOTE: Much of the new code was necessary to emit constants and their
types at module scope. I also added a bunch of tests as I started
getting into corner cases.
Since
[`DebugValue`](https://github.khronos.org/SPIRV-Registry/nonsemantic/NonSemantic.Shader.DebugInfo.html#DebugValue)
cannot have forward references, it can only reference already emitted
instructions. `DebugValue` cannot come after merge instructions either,
and SPIR-V requires an id defined in a function block to dominate a
non-phi use. The change has four parts:
1. `analyzeDebugRecords()` resolves placement and availability before
emission begins. Each record stays at its source position unless it lies
between a merge instruction and its terminator, in which case it moves
before the merge. A register value is accepted only when its definition
dominates the record. Records without a legal value are dropped.
2. A constant assignment needs a typed SPIR-V result id, but Machine IR
carries only untyped immediates. The type comes from the variable, and
`buildConstDbgValue()` decides whether the value is sign or zero
extended. The backend reuses a module `OpConstant` with that type and
value, or emits one alongside the line and column constants.
3. Debug info must be removable without changing what the module
requires. The handler creates `OpTypeBool` and 32-bit scalar types,
which need no capability, and reuses 8, 16 and 64-bit types only when
the module already defines them. Any other constant assignment is
dropped.
5. `SPIRVPostLegalizer::generateAssignType` placed `ASSIGN_TYPE` after a
`DBG_VALUE` naming the same register, because `updateRegType()` advances
the insertion point past the debug record. This change resets the
insertion point to just after the definition, so `ASSIGN_TYPE` comes
before the record that names it.
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