[llvm] [SPIRV] Emitting DebugSource, DebugCompileUnit (PR #97558)

Michal Paszkowski via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 9 15:56:50 PDT 2024


================
@@ -0,0 +1,129 @@
+; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
+
+source_filename = "example.c"
+target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"
+target triple = "spir"
+
+%struct.A = type { i32, float }
+
+; CHECK-SPIRV: [[ext_inst_non_semantic:%[0-9]+]] = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
+; CHECK-SPIRV: [[filename_str:%[0-9]+]] = OpString "/AAAAAAAAAA/BBBBBBBB/CCCCCCCCC/example.c" 
+; CHECK-SPIRV-DAG: [[type_void:%[0-9]+]] = OpTypeVoid
+; CHECK-SPIRV-DAG: [[type_i32:%[0-9]+]] = OpTypeInt 32 0
+; CHECK-SPIRV-DAG: [[dwarf_version:%[0-9]+]] = OpConstant [[type_i32]] 5 
+; CHECK-SPIRV-DAG: [[debug_info_version:%[0-9]+]] = OpConstant [[type_i32]] 21 
+; CHECK-SPIRV-DAG: [[source_language:%[0-9]+]] = OpConstant [[type_i32]] 3 
+; CHECK-SPIRV: [[debug_source:%[0-9]+]] = OpExtInst [[type_void]] [[ext_inst_non_semantic]] DebugSource [[filename_str]]
+; CHECK-SPIRV: [[debug_compiation_unit:%[0-9]+]] = OpExtInst [[type_void]] [[ext_inst_non_semantic]] DebugCompilationUnit [[source_language]] [[dwarf_version]] [[debug_source]] [[debug_info_version]]
+
+; Function Attrs: convergent noinline norecurse nounwind optnone
+define dso_local spir_func i32 @bar(i32 noundef %n) #0 !dbg !8 {
+entry:
+  %n.addr = alloca i32, align 4
+  store i32 %n, ptr %n.addr, align 4
+    #dbg_declare(ptr %n.addr, !13, !DIExpression(DW_OP_constu, 0, DW_OP_swap, DW_OP_xderef), !14)
+  %0 = load i32, ptr %n.addr, align 4, !dbg !15
----------------
michalpaszkowski wrote:

Please use named virtual registers whenever possible. There are cases where we "go around this rule", but we did have (rightly) comments in the past from other LLVM maintainers that having unnamed vregs makes adjusting tests much more difficult (since the naming needs to be continuous). Some adjustments are made by automated scripts (as it was the case with the transition to opaque pointers).

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


More information about the llvm-commits mailing list