[llvm] [SPIRV] Emit NonSemantic DebugGlobalVariable (PR #207230)
Manuel Carrasco via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 13 04:29:50 PDT 2026
================
@@ -0,0 +1,53 @@
+; 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 %}
+
+; Exercise NonSemantic DebugGlobalVariable for a module global with !dbg.
+; The global uses address space 1 so the backend emits a module-scope
+; CrossWorkgroup OpVariable (default-AS globals become function-local copies).
+
+; 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: [[PATH:%[0-9]+]] = OpString "{{[/\\]}}AAAAAAAAAA{{[/\\]}}BBBBBBBB{{[/\\]}}CCCCCCCCC{{[/\\]}}debug-global-variable.c"
+; CHECK-DAG: [[NAME:%[0-9]+]] = OpString "counter"
+; CHECK-DAG: [[STR_INT:%[0-9]+]] = OpString "int"
+; CHECK-DAG: [[C100:%[0-9]+]] = OpConstant [[I32T]] 100
+; CHECK-DAG: [[C5:%[0-9]+]] = OpConstant [[I32T]] 5
+; CHECK-DAG: [[C0:%[0-9]+]] = OpConstant [[I32T]] 0
+; CHECK-DAG: [[C42:%[0-9]+]] = OpConstant [[I32T]] 42
+; CHECK-DAG: [[C32:%[0-9]+]] = OpConstant [[I32T]] 32
+; CHECK-DAG: [[C4ENC:%[0-9]+]] = OpConstant [[I32T]] 4
+; CHECK-DAG: [[DS:%[0-9]+]] = OpExtInst [[VOID]] [[EXT]] DebugSource [[PATH]]
+; CHECK-DAG: [[CU:%[0-9]+]] = OpExtInst [[VOID]] [[EXT]] DebugCompilationUnit [[C100]] [[C5]] [[DS]] [[C0]]
+; CHECK-DAG: [[DTI:%[0-9]+]] = OpExtInst [[VOID]] [[EXT]] DebugTypeBasic [[STR_INT]] [[C32]] [[C4ENC]] [[C0]]
+; CHECK-DAG: [[GV:%[0-9]+]] = OpVariable {{.*}} CrossWorkgroup
+; CHECK-DAG: OpExtInst [[VOID]] [[EXT]] DebugGlobalVariable [[NAME]] [[DTI]] [[DS]] [[C42]] [[C0]] [[CU]] [[NAME]] [[GV]]
+
+target triple = "spirv64-unknown-unknown"
+
+ at g_value = dso_local addrspace(1) global i32 0, align 4, !dbg !0
+
+define spir_func void @use_global() !dbg !9 {
+entry:
+ %v = load i32, ptr addrspace(1) @g_value, align 4, !dbg !10
+ ret void, !dbg !11
+}
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!12, !13, !14, !15}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "counter", linkageName: "counter", scope: !2, file: !3, line: 42, type: !8, isLocal: false, isDefinition: true)
----------------
mgcarrasco wrote:
Thanks, fix the name.
https://github.com/llvm/llvm-project/pull/207230
More information about the llvm-commits
mailing list