[llvm] [SPIRV] Emit NonSemantic DebugGlobalVariable (PR #207230)
Manuel Carrasco via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 04:37:19 PDT 2026
================
@@ -0,0 +1,47 @@
+; RUN: llc --verify-machineinstrs --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
+
+; This is an edge case: IR that is valid but cannot be correctly encoded in SPIRV.
+
+; A DIGlobalVariable declaration with a null type (isDefinition: false, which the
+; IR verifier permits) and no backing llvm::GlobalVariable. The Type operand
+; falls back to DebugInfoNone, and the Variable operand also falls back to
+; DebugInfoNone because no @g carries this DIGlobalVariable and its
+; DIGlobalVariableExpression has an empty DIExpression.
+;
+; No spirv-val run: DebugInfoNone is not accepted as the Type operand of
----------------
mgcarrasco wrote:
I think it's a good idea to do this (or at least discuss alternative approaches). However, I'd prefer to wait until we have more concrete cases where the spec would need to be relaxed to allow DebugInfoNone as an operand.
I found the following discussion on [debug function pointers](https://github.com/KhronosGroup/SPIRV-Registry/pull/287), where there seemed to be some consensus around either:
1. Relaxing the spec for specific cases, or
2. Finding an alternative way to encode "no type" information.
The current PR follows the behavior of the LLVM-SPIRV translator. If we go with option 2, that would require additional changes, including updates to the translator.
https://github.com/llvm/llvm-project/pull/207230
More information about the llvm-commits
mailing list