Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/DebugInfo/DebugInfoLexicalBlockDependency.ll

raw
1 ; This test checks the translation of debug info is correct when:
2 ; - Subprogram contains a lexical block LB and a local variable VAL
3 ; - The parent scope of the local variable VAL is the lexical block LB
4 ; - The parent scope of the lexical block LB is the subprogram.
5
6 ; RUN: llvm-as %s -o %t.bc
7 ; RUN: llvm-spirv %t.bc -o %t.spv
8 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
9 ; RUN: llvm-dis %t.rev.bc -o %t.rev.ll
10 ; RUN: FileCheck %s --input-file %t.rev.ll
11
12 target triple = "spir64-unknown-unknown"
13
14 ; Function Attrs: noinline nounwind
15 define spir_kernel void @test(i64 %value) #0 !dbg !9 {
16 entry:
17 %value.addr = alloca i32, align 1, !dbg !17
18 call void @llvm.dbg.declare(metadata i32* %value.addr, metadata !13, metadata !DIExpression()), !dbg !18
19 %value.trunc = trunc i64 %value to i32, !dbg !17
20 store i32 %value.trunc, i32* %value.addr, align 4, !dbg !17
21 ret void
22 }
23
24 ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
25 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
26
27 attributes #0 = { noinline nounwind }
28 attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
29
30 !llvm.module.flags = !{!0, !1}
31 !llvm.dbg.cu = !{!2}
32 !spirv.MemoryModel = !{!5}
33 !spirv.Source = !{!6}
34 !opencl.spir.version = !{!7}
35 !opencl.ocl.version = !{!7}
36 !opencl.used.extensions = !{!4}
37 !opencl.used.optional.core.features = !{!4}
38 !spirv.Generator = !{!8}
39
40 !0 = !{i32 7, !"Dwarf Version", i32 4}
41 !1 = !{i32 2, !"Debug Info Version", i32 3}
42 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !3, producer: "spirv", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, imports: !4)
43 !3 = !DIFile(filename: "1", directory: "/")
44 !4 = !{}
45 !5 = !{i32 2, i32 2}
46 !6 = !{i32 4, i32 200000}
47 !7 = !{i32 2, i32 0}
48 !8 = !{i16 6, i16 14}
49 !9 = distinct !DISubprogram(name: "test", scope: null, file: !3, line: 13, type: !10, scopeLine: 13, flags: DIFlagArtificial, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagMainSubprogram, unit: !2, templateParams: !4, retainedNodes: !12)
50 !10 = !DISubroutineType(types: !11)
51 !11 = !{null}
52 !12 = !{!13}
53 !13 = !DILocalVariable(name: "value", scope: !14, file: !3, line: 12, type: !15)
54 !14 = distinct !DILexicalBlock(scope: !9, file: !3, line: 13, column: 1)
55 !15 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !16)
56 !16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
57 !17 = !DILocation(line: 13, column: 1, scope: !14)
58 !18 = !DILocation(line: 12, column: 23, scope: !14)
59
60 ; Debug location metadata id of original instruction.
61 ; CHECK: %value.addr = alloca i32, align 1, !dbg ![[#DL:]]
62
63 ; The function contains the local variable VAL in retainedNodes.
64 ; CHECK: ![[#SP:]] = distinct !DISubprogram(name: "test"
65 ; CHECK-SAME: retainedNodes: ![[#NODES:]]
66 ; CHECK: ![[#NODES]] = !{![[#VAL:]]}
67
68 ; The local variable VAL lies in block LB, whose parent scope is the subprogram.
69 ; CHECK: ![[#VAL]] = !DILocalVariable(name: "value", scope: ![[#LB:]]
70 ; CHECK: ![[#LB]] = distinct !DILexicalBlock(scope: ![[#SP]]
71
72 ; The debug location should be attached to block LB.
73 ; CHECK: ![[#DL]] = !DILocation(
74 ; CHECK-SAME: scope: ![[#LB]]
75
76 ; Other lexical blocks are unexpected.
77 ; CHECK-NOT: distinct !DILexicalBlock