Skip to content

Commit 8490f30

Browse files
committed
--Added support for the extension SPV_KHR_non_semantic_info
--Added 19 instructions from the documentation. --Added supporting tests for the same.
1 parent 9abae17 commit 8490f30

17 files changed

+2201
-172
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitNonSemanticDI.cpp

Lines changed: 1355 additions & 168 deletions
Large diffs are not rendered by default.

llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class SPIRVGlobalRegistry : public SPIRVIRMapping {
8282
// Intrinsic::spv_assign_ptr_type instructions.
8383
DenseMap<Value *, CallInst *> AssignPtrTypeInstr;
8484

85+
DenseMap<const Metadata *, Register> MDMap;
86+
8587
// Maps OpVariable and OpFunction-related v-regs to its LLVM IR definition.
8688
DenseMap<std::pair<const MachineFunction *, Register>, const Value *> Reg2GO;
8789

@@ -133,6 +135,15 @@ class SPIRVGlobalRegistry : public SPIRVIRMapping {
133135
return It == FunResPointerTypes.end() ? nullptr : It->second;
134136
}
135137

138+
Register getDebugValue(const Metadata *MD) const {
139+
auto It = MDMap.find(MD);
140+
if (It != MDMap.end())
141+
return It->second;
142+
return Register();
143+
}
144+
145+
void addDebugValue(const Metadata *MD, Register Reg) { MDMap[MD] = Reg; }
146+
136147
// A registry of "assign type" records:
137148
// - Add a record.
138149
void addAssignPtrTypeInstr(Value *Val, CallInst *AssignPtrTyCI) {

llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,32 @@ void SPIRVModuleAnalysis::processOtherInstrs(const Module &M) {
654654
MachineOperand Ins = MI.getOperand(3);
655655
namespace NS = SPIRV::NonSemanticExtInst;
656656
static constexpr int64_t GlobalNonSemanticDITy[] = {
657-
NS::DebugSource, NS::DebugCompilationUnit, NS::DebugInfoNone,
658-
NS::DebugTypeBasic, NS::DebugTypePointer};
657+
NS::DebugSource,
658+
NS::DebugCompilationUnit,
659+
NS::DebugInfoNone,
660+
NS::DebugTypeBasic,
661+
NS::DebugTypePointer,
662+
NS::DebugBuildIdentifier,
663+
NS::DebugStoragePath,
664+
NS::DebugSourceContinued,
665+
NS::DebugFunction,
666+
NS::DebugTypeFunction,
667+
NS::DebugFunctionDeclaration,
668+
NS::DebugLexicalBlock,
669+
NS::DebugLexicalBlockDiscriminator,
670+
NS::DebugTypeQualifier,
671+
NS::DebugImportedEntity,
672+
NS::DebugTypedef,
673+
NS::DebugGlobalVariable,
674+
NS::DebugTypeArray,
675+
NS::DebugTypeComposite,
676+
NS::DebugTypeTemplate,
677+
NS::DebugTypeTemplateParameter,
678+
NS::DebugTypeMember,
679+
NS::DebugMacroDef,
680+
NS::DebugMacroUndef,
681+
NS::DebugTypePtrToMember,
682+
NS::DebugTypeInheritance};
659683
bool IsGlobalDI = false;
660684
for (unsigned Idx = 0; Idx < std::size(GlobalNonSemanticDITy); ++Idx)
661685
IsGlobalDI |= Ins.getImm() == GlobalNonSemanticDITy[Idx];
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
; RUN: llc --verify-machineinstrs --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info --print-after=spirv-nonsemantic-debug-info -O0 -mtriple=spirv64-unknown-unknown %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-MIR
2+
; RUN: llc --verify-machineinstrs --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
3+
; RUN: llc --verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_KHR_non_semantic_info %s -o - | FileCheck %s --check-prefix=CHECK-OPTION
4+
; RUN: %if spirv-tools %{ llc --verify-machineinstrs --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
5+
6+
; CHECK-MIR-DAG: [[i32type:%[0-9]+\:type\(s64\)]] = OpTypeInt 32, 0
7+
; CHECK-MIR-DAG: [[i8type:%[0-9]+\:type]] = OpTypeInt 8, 0
8+
; CHECK-MIR-DAG: [[void_type:%[0-9]+\:type]] = OpTypeVoid
9+
; CHECK-MIR-DAG: [[ptr_type:%[0-9]+\:type]] = OpTypePointer 5, [[i8type]]
10+
; CHECK-MIR-DAG: [[func_type:%[0-9]+\:type]] = OpTypeFunction [[void_type]], [[ptr_type]], [[ptr_type]], [[ptr_type]]
11+
; CHECK-MIR-DAG: [[i32_1:%[0-9]+\:iid\(s32\)]] = OpConstantI [[i32type]], 1
12+
; CHECK-MIR-DAG: [[i32_3:%[0-9]+\:iid\(s32\)]] = OpConstantI [[i32type]], 3
13+
; CHECK-MIR-DAG: [[debug_source:%[0-9]+\:id\(s32\)]] = OpExtInst [[void_type]], 3, 35
14+
; CHECK-MIR-DAG: [[string_build_id:%[0-9]+\:id\(s32\)]] = OpString {{[0-9 ,]+}}, 12345
15+
; CHECK-MIR-DAG: [[string_storage_path:%[0-9]+\:id\(s32\)]] = OpString {{[0-9 ,]+}}, 30320
16+
; CHECK-MIR-DAG: [[debug_comp_unit:%[0-9]+\:id\(s32\)]] = OpExtInst [[void_type]], 3, 1, [[i32_3]], [[i32_1]], [[debug_source]]
17+
; CHECK-MIR-DAG: [[debug_build_id:%[0-9]+\:id\(s32\)]] = OpExtInst [[void_type]], 3, 105, [[string_build_id]]
18+
; CHECK-MIR-DAG: [[debug_storage_path:%[0-9]+\:id\(s32\)]] = OpExtInst [[void_type]], 3, 106, [[string_storage_path]]
19+
20+
; CHECK-SPIRV-DAG: [[i32type:%[0-9]+]] = OpTypeInt 32 0
21+
; CHECK-SPIRV-DAG: [[i8type:%[0-9]+]] = OpTypeInt 8 0
22+
; CHECK-SPIRV-DAG: [[void_type:%[0-9]+]] = OpTypeVoid
23+
; CHECK-SPIRV-DAG: [[ptr_type:%[0-9]+]] = OpTypePointer CrossWorkgroup [[i8type]]
24+
; CHECK-SPIRV-DAG: [[func_type:%[0-9]+]] = OpTypeFunction [[void_type]] [[ptr_type]] [[ptr_type]] [[ptr_type]]
25+
; CHECK-SPIRV-DAG: [[i32_1:%[0-9]+]] = OpConstant [[i32type]] 1
26+
; CHECK-SPIRV-DAG: [[i32_3:%[0-9]+]] = OpConstant [[i32type]] 3
27+
; CHECK-SPIRV-DAG: [[string_build_id:%[0-9]+]] = OpString "1234567890"
28+
; CHECK-SPIRV-DAG: [[string_storage_path:%[0-9]+]] = OpString "debug_storage_path.spv"
29+
; CHECK-SPIRV-DAG: [[debug_source:%[0-9]+]] = OpExtInst [[void_type]] {{%[0-9]+}} DebugSource
30+
; CHECK-SPIRV-DAG: [[debug_comp_unit:%[0-9]+]] = OpExtInst [[void_type]] {{%[0-9]+}} DebugCompilationUnit [[i32_3]] [[i32_1]] [[debug_source]]
31+
; CHECK-SPIRV-DAG: [[debug_build_id:%[0-9]+]] = OpExtInst [[void_type]] {{%[0-9]+}} DebugBuildIdentifier [[string_build_id]]
32+
; CHECK-SPIRV-DAG: [[debug_storage_path:%[0-9]+]] = OpExtInst [[void_type]] {{%[0-9]+}} DebugStoragePath [[string_storage_path]]
33+
34+
; CHECK-OPTION-NOT: DebugBuildIdentifier
35+
; CHECK-OPTION-NOT: DebugStoragePath
36+
; CHECK-OPTION-NOT: DebugCompilationUnit
37+
38+
define dso_local spir_kernel void @add_kernel(i32 addrspace(1)* %a, i32 addrspace(1)* %b, i32 addrspace(1)* %res) !dbg !8 {
39+
entry:
40+
ret void, !dbg !10
41+
}
42+
43+
!llvm.dbg.cu = !{!0}
44+
!llvm.module.flags = !{!3, !4, !5}
45+
46+
!0 = distinct !DICompileUnit( language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version test", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugFilename: "debug_storage_path.spv", dwoId: 1234567890, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
47+
!1 = !DIFile(filename: "debug_build_storage.cl", directory: "/path/to/source")
48+
!2 = !{}
49+
!3 = !{i32 7, !"Dwarf Version", i32 1}
50+
!4 = !{i32 2, !"Debug Info Version", i32 3}
51+
!5 = !{i32 1, !"wchar_size", i32 4}
52+
!8 = distinct !DISubprogram(name: "add_kernel", scope: !1, file: !1, line: 1, type: !9, unit: !0, spFlags: DISPFlagDefinition, retainedNodes: !2)
53+
!9 = !DISubroutineType(types: !2)
54+
!10 = !DILocation(line: 2, column: 1, scope: !8)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
; RUN: llc --verify-machineinstrs --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info --print-after=spirv-nonsemantic-debug-info -O0 -mtriple=spirv64-unknown-unknown %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-MIR
2+
; RUN: llc --verify-machineinstrs --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
3+
; RUN: llc --verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_KHR_non_semantic_info %s -o - | FileCheck %s --check-prefix=CHECK-OPTION
4+
; RUN: %if spirv-tools %{ llc --verify-machineinstrs --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
5+
6+
; CHECK-MIR-DAG: [[type_void:%[0-9]+:type]] = OpTypeVoid
7+
; CHECK-MIR-DAG: [[source:%[0-9]+:.*]] = OpExtInst [[type_void]], 3, 35, {{%[0-9]+:.*}}
8+
; CHECK-MIR-DAG: [[compile_unit:%[0-9]+:.*]] = OpExtInst [[type_void]], 3, 1
9+
; CHECK-MIR-DAG: [[type_func:%[0-9]+:.*]] = OpExtInst [[type_void]], 3, 8, {{%[0-9]+:.*}}, [[type_void]]
10+
; CHECK-MIR-DAG: [[func1:%[0-9]+:.*]] = OpExtInst [[type_void]], 3, 20, {{%[0-9]+:.*}}, [[type_func]], [[source]], {{%[0-9]+:.*}}, {{%[0-9]+:.*}}, [[compile_unit]]
11+
; CHECK-MIR-DAG: [[func2:%[0-9]+:.*]] = OpExtInst [[type_void]], 3, 20, {{%[0-9]+:.*}}, [[type_func]], [[source]], {{%[0-9]+:.*}}, {{%[0-9]+:.*}}, [[compile_unit]]
12+
13+
; CHECK-SPIRV: %[[#ext_inst_non_semantic:]] = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
14+
; CHECK-SPIRV: %[[#test1:]] = OpString "test1"
15+
; CHECK-SPIRV: %[[#test2:]] = OpString "test2"
16+
; CHECK-SPIRV: %[[#void:]] = OpTypeVoid
17+
; CHECK-SPIRV: %[[#Ty32:]] = OpTypeInt 32 0
18+
; CHECK-SPIRV: %[[#zero:]] = OpConstant %[[#Ty32]] 0
19+
; CHECK-SPIRV: %[[#debug_source:]] = OpExtInst %[[#void]] %[[#ext_inst_non_semantic]] DebugSource
20+
; CHECK-SPIRV: %[[#debug_compilation:]] = OpExtInst %[[#void]] %[[#ext_inst_non_semantic]] DebugCompilationUnit
21+
; CHECK-SPIRV: %[[#typefunc:]] = OpExtInst %[[#void]] %[[#ext_inst_non_semantic]] DebugTypeFunction %[[#zero]] %[[#void]]
22+
; CHECK-SPIRV: %[[#func1:]] = OpExtInst %[[#void]] %[[#ext_inst_non_semantic]] DebugFunction %[[#test1]] %[[#typefunc]] %[[#debug_source]] %[[#]] %[[#]] %[[#debug_compilation]]
23+
; CHECK-SPIRV: %[[#func2:]] = OpExtInst %[[#void]] %[[#ext_inst_non_semantic]] DebugFunction %[[#test2]] %[[#typefunc]] %[[#debug_source]] %[[#]] %[[#]] %[[#debug_compilation]]
24+
25+
; CHECK-OPTION-NOT: OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
26+
27+
define spir_func void @test1() !dbg !5 {
28+
entry:
29+
%a = alloca i32, align 4
30+
store i32 1, ptr %a, align 4, !dbg !8
31+
ret void
32+
}
33+
34+
define spir_func void @test2() !dbg !9 {
35+
entry:
36+
%b = alloca i32, align 4
37+
store i32 2, ptr %b, align 4, !dbg !11
38+
ret void
39+
}
40+
41+
!llvm.dbg.cu = !{!0}
42+
!llvm.module.flags = !{!2, !3}
43+
44+
!0 = distinct !DICompileUnit(language: DW_LANG_Zig, file: !1, producer: "clang version XX.X", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
45+
!1 = !DIFile(filename: "example.c", directory: "/tmp")
46+
!2 = !{i32 2, !"Debug Info Version", i32 3}
47+
!3 = !{i32 7, !"Dwarf Version", i32 5}
48+
!5 = distinct !DISubprogram(name: "test1", scope: !1, file: !1, line: 1, type: !6, spFlags: DISPFlagDefinition, unit: !0)
49+
!6 = !DISubroutineType(types: !7)
50+
!7 = !{!12}
51+
!8 = !DILocation(line: 1, column: 3, scope: !5)
52+
!9 = distinct !DISubprogram(name: "test2", scope: !1, file: !1, line: 2, type: !6, spFlags: DISPFlagDefinition, unit: !0)
53+
!11 = !DILocation(line: 2, column: 3, scope: !9)
54+
!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
; RUN: llc --verify-machineinstrs --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info --print-after=spirv-nonsemantic-debug-info -O0 -mtriple=spirv64-unknown-unknown %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-MIR
2+
; RUN: llc --verify-machineinstrs --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
3+
; RUN: llc --verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_KHR_non_semantic_info %s -o - | FileCheck %s --check-prefix=CHECK-OPTION
4+
; RUN: %if spirv-tools %{ llc --verify-machineinstrs --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
5+
6+
; CHECK-MIR-DAG: [[i32type:%[0-9]+\:type]] = OpTypeInt 32, 0
7+
; CHECK-MIR-DAG: [[void_type:%[0-9]+\:type\(s64\)]] = OpTypeVoid
8+
; CHECK-MIR-DAG: [[i32_5:%[0-9]+\:iid]] = OpConstantI [[i32type]], 5
9+
; CHECK-MIR-DAG: [[i32_1:%[0-9]+\:iid\(s32\)]] = OpConstantI [[i32type]], 1
10+
; CHECK-MIR-DAG: [[i32_3:%[0-9]+\:iid\(s32\)]] = OpConstantI [[i32type]], 3
11+
; CHECK-MIR-DAG: [[i32_13:%[0-9]+\:iid\(s32\)]] = OpConstantI [[i32type]], 13
12+
; CHECK-MIR-DAG: [[debug_source:%[0-9]+\:id\(s32\)]] = OpExtInst [[void_type]], 3, 35
13+
; CHECK-MIR-DAG: [[debug_comp_unit:%[0-9]+\:id\(s32\)]] = OpExtInst [[void_type]], 3, 1, [[i32_3]], [[i32_5]], [[debug_source]], [[i32_13]]
14+
; CHECK-MIR-DAG: [[debug_info_none:%[0-9]+\:id\(s32\)]] = OpExtInst [[void_type]], 3, 0
15+
; CHECK-MIR-DAG: [[debug_imported_entity:%[0-9]+\:id\(s32\)]] = OpExtInst [[void_type]], 3, 34, {{%[0-9]+\:[a-z0-9\(\)]+}}, {{%[0-9]+\:[a-z0-9\(\)]+}}, [[debug_source]], [[debug_info_none]], [[i32_3]], [[i32_1]], [[debug_comp_unit]]
16+
17+
; CHECK-SPIRV-DAG: [[i32type:%[0-9]+]] = OpTypeInt 32 0
18+
; CHECK-SPIRV-DAG: [[void_type:%[0-9]+]] = OpTypeVoid
19+
; CHECK-SPIRV-DAG: [[debug_source:%[0-9]+]] = OpExtInst [[void_type]] {{%[0-9]+}} DebugSource
20+
; CHECK-SPIRV-DAG: [[debug_comp_unit:%[0-9]+]] = OpExtInst [[void_type]] {{%[0-9]+}} DebugCompilationUnit {{%[0-9]+}} {{%[0-9]+}} [[debug_source]] {{%[0-9]+}}
21+
; CHECK-SPIRV-DAG: [[debug_info_none:%[0-9]+]] = OpExtInst [[void_type]] {{%[0-9]+}} DebugInfoNone
22+
; CHECK-SPIRV-DAG: [[debug_imported_entity:%[0-9]+]] = OpExtInst [[void_type]] {{%[0-9]+}} DebugImportedEntity {{%[0-9]+}} {{%[0-9]+}} [[debug_source]] [[debug_info_none]] {{%[0-9]+}} {{%[0-9]+}} [[debug_comp_unit]]
23+
24+
; CHECK-OPTION-NOT: DebugImportedEntity
25+
26+
define dso_local noundef i32 @main() !dbg !13 {
27+
entry:
28+
%retval = alloca i32, align 4
29+
%r = alloca i32, align 4
30+
store i32 0, ptr %retval, align 4
31+
#dbg_declare(ptr %r, !18, !DIExpression(), !19)
32+
%call = call noundef i32 @_ZN4myns9double_itEi(i32 noundef 5), !dbg !20
33+
store i32 %call, ptr %r, align 4, !dbg !19
34+
%0 = load i32, ptr %r, align 4, !dbg !21
35+
ret i32 %0, !dbg !22
36+
}
37+
38+
declare noundef i32 @_ZN4myns9double_itEi(i32 noundef)
39+
40+
!llvm.dbg.cu = !{!0}
41+
!llvm.module.flags = !{!5, !6, !7, !8, !9, !10, !11}
42+
43+
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version XX.X", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, imports: !2, splitDebugInlining: false, nameTableKind: None)
44+
!1 = !DIFile(filename: "main.cpp", directory: "/tmp", checksumkind: CSK_MD5, checksum: "2ca3a2708747979970bbb428cfe8db65")
45+
!2 = !{!3}
46+
!3 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !0, entity: !4, file: !1, line: 3)
47+
!4 = !DINamespace(name: "myns", scope: null)
48+
!5 = !{i32 7, !"Dwarf Version", i32 5}
49+
!6 = !{i32 2, !"Debug Info Version", i32 3}
50+
!7 = !{i32 1, !"wchar_size", i32 4}
51+
!8 = !{i32 8, !"PIC Level", i32 2}
52+
!9 = !{i32 7, !"PIE Level", i32 2}
53+
!10 = !{i32 7, !"uwtable", i32 2}
54+
!11 = !{i32 7, !"frame-pointer", i32 2}
55+
!13 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 5, type: !14, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !17)
56+
!14 = !DISubroutineType(types: !15, flags: DIFlagPublic)
57+
!15 = !{!16}
58+
!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed, flags: DIFlagPublic)
59+
!17 = !{}
60+
!18 = !DILocalVariable(name: "r", scope: !13, file: !1, line: 6, type: !16)
61+
!19 = !DILocation(line: 6, column: 9, scope: !13)
62+
!20 = !DILocation(line: 6, column: 13, scope: !13)
63+
!21 = !DILocation(line: 7, column: 12, scope: !13)
64+
!22 = !DILocation(line: 7, column: 5, scope: !13)
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
; RUN: llc --verify-machineinstrs --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info --print-after=spirv-nonsemantic-debug-info -O0 -mtriple=spirv64-unknown-unknown %s -o - 2>&1 | FileCheck %s --check-prefix=CHECK-MIR
2+
; RUN: llc --verify-machineinstrs --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
3+
; RUN: llc --verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_KHR_non_semantic_info %s -o - | FileCheck %s --check-prefix=CHECK-OPTION
4+
; RUN: %if spirv-tools %{ llc --verify-machineinstrs --spv-emit-nonsemantic-debug-info --spirv-ext=+SPV_KHR_non_semantic_info -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
5+
6+
; CHECK-MIR-DAG: [[type_void:%[0-9]+:type]] = OpTypeVoid
7+
; CHECK-MIR-DAG: [[source:%[0-9]+:.*]] = OpExtInst [[type_void]], 3, 35, {{%[0-9]+:.*}}
8+
; CHECK-MIR-DAG: [[func1:%[0-9]+:.*]] = OpExtInst [[type_void]], 3, 20, {{%[0-9]+:.*}}
9+
; CHECK-MIR-DAG: [[func2:%[0-9]+:.*]] = OpExtInst [[type_void]], 3, 20, {{%[0-9]+:.*}}
10+
; CHECK-MIR-DAG: [[lex_block1:%[0-9]+:.*]] = OpExtInst [[type_void]], 3, 21, [[source]], {{%[0-9]+:.*}}, {{%[0-9]+:.*}}, [[func1]]
11+
; CHECK-MIR-DAG: [[lex_block_discr:%[0-9]+:.*]] = OpExtInst [[type_void]], 3, 22, [[source]], {{%[0-9]+:.*}}, [[lex_block1]]
12+
; CHECK-MIR-DAG: [[lex_block2:%[0-9]+:.*]] = OpExtInst [[type_void]], 3, 21, [[source]], {{%[0-9]+:.*}}, {{%[0-9]+:.*}}, [[func2]]
13+
14+
; CHECK-SPIRV: %[[#ext_inst_non_semantic:]] = OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
15+
; CHECK-SPIRV: %[[#test1:]] = OpString "test1"
16+
; CHECK-SPIRV: %[[#test2:]] = OpString "test2"
17+
; CHECK-SPIRV: %[[#void:]] = OpTypeVoid
18+
; CHECK-SPIRV: %[[#Ty32:]] = OpTypeInt 32 0
19+
; CHECK-SPIRV: %[[#zero:]] = OpConstant %[[#Ty32]] 0
20+
; CHECK-SPIRV: %[[#debug_source:]] = OpExtInst %[[#void]] %[[#ext_inst_non_semantic]] DebugSource
21+
; CHECK-SPIRV: %[[#func1:]] = OpExtInst %[[#void]] %[[#ext_inst_non_semantic]] DebugFunction %[[#test1]]
22+
; CHECK-SPIRV: %[[#func2:]] = OpExtInst %[[#void]] %[[#ext_inst_non_semantic]] DebugFunction %[[#test2]]
23+
; CHECK-SPIRV: %[[#lex_block:]] = OpExtInst %[[#void]] %[[#ext_inst_non_semantic]] DebugLexicalBlock %[[#debug_source]] %[[#]] %[[#]] %[[#func1]]
24+
; CHECK-SPIRV: %[[#]] = OpExtInst %[[#void]] %[[#ext_inst_non_semantic]] DebugLexicalBlockDiscriminator %[[#debug_source]] %[[#]] %[[#lex_block]]
25+
; CHECK-SPIRV: %[[#]] = OpExtInst %[[#void]] %[[#ext_inst_non_semantic]] DebugLexicalBlock %[[#debug_source]] %[[#]] %[[#]] %[[#func2]]
26+
; CHECK-OPTION-NOT: OpExtInstImport "NonSemantic.Shader.DebugInfo.100"
27+
28+
define spir_func void @test1() !dbg !5 {
29+
entry:
30+
%a = alloca i32, align 4
31+
store i32 1, ptr %a, align 4, !dbg !15
32+
ret void, !dbg !16
33+
}
34+
35+
define spir_func void @test2() !dbg !9 {
36+
entry:
37+
%b = alloca i32, align 4
38+
store i32 2, ptr %b, align 4, !dbg !18
39+
ret void, !dbg !19
40+
}
41+
42+
!llvm.dbg.cu = !{!0}
43+
!llvm.module.flags = !{!2, !3}
44+
45+
!0 = distinct !DICompileUnit(language: DW_LANG_Zig, file: !1, producer: "clang version XX.X", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
46+
!1 = !DIFile(filename: "example.c", directory: "/tmp")
47+
!2 = !{i32 2, !"Debug Info Version", i32 3}
48+
!3 = !{i32 7, !"Dwarf Version", i32 5}
49+
!5 = distinct !DISubprogram(name: "test1", scope: !1, file: !1, line: 1, type: !6, spFlags: DISPFlagDefinition, unit: !0)
50+
!6 = !DISubroutineType(types: !7)
51+
!7 = !{!12}
52+
!9 = distinct !DISubprogram(name: "test2", scope: !1, file: !1, line: 2, type: !6, spFlags: DISPFlagDefinition, unit: !0)
53+
!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
54+
!13 = distinct !DILexicalBlock(scope: !5, file: !1, line: 1, column: 5)
55+
!14 = !DILexicalBlockFile(scope: !13, file: !1, discriminator: 1)
56+
!15 = !DILocation(line: 1, column: 3, scope: !13)
57+
!16 = !DILocation(line: 1, column: 7, scope: !14)
58+
!17 = distinct !DILexicalBlock(scope: !9, file: !1, line: 2, column: 5)
59+
!18 = !DILocation(line: 2, column: 3, scope: !17)
60+
!19 = !DILocation(line: 2, column: 7, scope: !17)

0 commit comments

Comments
 (0)