[llvm] [SPIRV] Emit NonSemantic DebugGlobalVariable (PR #207230)

Manuel Carrasco via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 04:29:24 PDT 2026


================
@@ -0,0 +1,43 @@
+; RUN: llc --verify-machineinstrs --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc --verify-machineinstrs --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
+
+; A default-address-space global with !dbg. Such globals do not become a
+; module-scope OpVariable (they are turned into function-local copies), so no
+; result id is registered for them. The DIGlobalVariable is still emitted, but
+; its Variable operand falls back to DebugInfoNone.
+
+; CHECK-DAG: [[EXT:%[0-9]+]] = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
+; CHECK-DAG: [[VOID:%[0-9]+]] = OpTypeVoid
+; CHECK-DAG: [[I32T:%[0-9]+]] = OpTypeInt 32 0
+; CHECK-DAG: [[NAME:%[0-9]+]] = OpString "localas"
+; CHECK-DAG: [[STR_INT:%[0-9]+]] = OpString "int"
+; CHECK-DAG: [[C42:%[0-9]+]] = OpConstant [[I32T]] 42
+; CHECK-DAG: [[NONE:%[0-9]+]] = OpExtInst [[VOID]] [[EXT]] DebugInfoNone
+; CHECK-DAG: [[DS:%[0-9]+]] = OpExtInst [[VOID]] [[EXT]] DebugSource
+; CHECK-DAG: [[DTI:%[0-9]+]] = OpExtInst [[VOID]] [[EXT]] DebugTypeBasic [[STR_INT]]
+; CHECK-DAG: OpExtInst [[VOID]] [[EXT]] DebugGlobalVariable [[NAME]] [[DTI]] [[DS]] [[C42]] {{%[0-9]+}} {{%[0-9]+}} [[NAME]] [[NONE]]
+
+target triple = "spirv64-unknown-unknown"
+
+ at g = dso_local global i32 0, align 4, !dbg !0
+
+define spir_func void @f() !dbg !9 {
+entry:
+  ret void, !dbg !10
+}
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!12, !13}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "localas", linkageName: "localas", scope: !2, file: !3, line: 42, type: !8, isLocal: false, isDefinition: true)
----------------
mgcarrasco wrote:

Thanks, updated the name. The lines represent source lines so they don't have to match the IR.

https://github.com/llvm/llvm-project/pull/207230


More information about the llvm-commits mailing list