Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/DebugInfo/Generic/c-and-cpp-mixed.ll

raw
1 ;; This test checks that two DICompileUnits resulted in a link of C and C++
2 ;; object files are being translated correctly
3
4 ; RUN: llvm-as < %s -o %t.bc
5 ; RUN: llvm-spirv %t.bc -o %t.spv
6 ; RUN: llvm-spirv --to-text %t.spv -o - | FileCheck %s --check-prefix=CHECK-SPIRV
7 ; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o - | llvm-dis -o %t.ll
8 ; RUN: FileCheck < %t.ll %s --check-prefix=CHECK-LLVM
9
10 ; CHECK-SPIRV: String [[#Foo:]] "foo"
11 ; CHECK-SPIRV: String [[#Main:]] "main"
12 ; CHECK-SPIRV: ExtInst [[#]] [[#CU1:]] [[#]] DebugCompilationUnit
13 ; CHECK-SPIRV: ExtInst [[#]] [[#CU2:]] [[#]] DebugCompilationUnit
14 ; CHECK-SPIRV: ExtInst [[#]] [[#Func1:]] [[#]] DebugFunction [[#Foo]] [[#]] [[#]] [[#]] [[#]] [[#CU1]]
15 ; CHECK-SPIRV: ExtInst [[#]] [[#Func2:]] [[#]] DebugFunction [[#Main]] [[#]] [[#]] [[#]] [[#]] [[#CU2]]
16 ; CHECK-SPIRV: ExtInst [[#]] [[#]] [[#]] DebugLexicalBlock [[#]] [[#]] [[#]] [[#Func1]]
17 ; CHECK-SPIRV: ExtInst [[#]] [[#]] [[#]] DebugLexicalBlock [[#]] [[#]] [[#]] [[#Func2]]
18
19 ; CHECK-LLVM: define spir_func void @foo() #0 !dbg ![[#Func1:]] {
20 ; CHECK-LLVM: entry:
21 ; CHECK-LLVM: %puts = call spir_func i32 @puts(ptr nocapture @str) #0, !dbg ![[#Puts1Loc:]]
22 ; CHECK-LLVM: ret void, !dbg ![[#Ret1:]]
23 ; CHECK-LLVM: }
24
25 ; CHECK-LLVM: define spir_func i32 @main(i32 %argc, ptr nocapture %argv) #0 !dbg ![[#Func2:]] {
26 ; CHECK-LLVM: entry:
27 ; CHECK-LLVM: call void @llvm.dbg.value(metadata i32 %argc, metadata ![[#Fun2Param1:]], metadata !DIExpression()), !dbg ![[#Fun2Param1Loc:]]
28 ; CHECK-LLVM: call void @llvm.dbg.value(metadata ptr %argv, metadata ![[#Fun2Param2:]], metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg ![[#Fun2Param2Loc:]]
29 ; CHECK-LLVM: %0 = bitcast ptr @str1 to ptr, !dbg ![[#Puts2Loc:]]
30 ; CHECK-LLVM: %puts = call spir_func i32 @puts(ptr nocapture %0) #0, !dbg ![[#Puts2Loc]]
31 ; CHECK-LLVM: call spir_func void @foo() #0, !dbg ![[#CallFoo:]]
32 ; CHECK-LLVM: ret i32 0, !dbg ![[#Ret2:]]
33 ; CHECK-LLVM: }
34
35 ; CHECK-LLVM: !llvm.dbg.cu = !{![[#CU1:]], ![[#CU2:]]}
36 ; CHECK-LLVM: ![[#CU1]] = distinct !DICompileUnit(language: DW_LANG_OpenCL, file: ![[#File:]], producer: "clang version 14", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
37 ; CHECK-LLVM: ![[#File]] = !DIFile(filename: "foo.c", directory: "/tmp")
38 ; CHECK-LLVM: ![[#CU2]] = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: ![[#File]], producer: "clang version 14", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
39 ; CHECK-LLVM: ![[#Empty:]] = !{}
40 ; CHECK-LLVM: ![[#Func1]] = distinct !DISubprogram(name: "foo", scope: null, file: ![[#File]], line: 5, type: ![[#Func1T:]], scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: ![[#CU1]], templateParams: ![[#Empty]], retainedNodes: ![[#Empty]])
41 ; CHECK-LLVM: ![[#Func1T]] = !DISubroutineType(types: ![[#Func1TP:]])
42 ; CHECK-LLVM: ![[#Func1TP]] = !{null}
43 ; CHECK-LLVM: ![[#Puts1Loc]] = !DILocation(line: 6, column: 3, scope: ![[#Puts1Scope:]])
44 ; CHECK-LLVM: ![[#Puts1Scope]] = distinct !DILexicalBlock(scope: ![[#Func1]], file: ![[#File]], line: 5, column: 16)
45 ; CHECK-LLVM: ![[#Ret1]] = !DILocation(line: 7, column: 1, scope: ![[#Puts1Scope]])
46 ; CHECK-LLVM: ![[#Func2]] = distinct !DISubprogram(name: "main", scope: null, file: ![[#File]], line: 11, type: ![[#Func2T:]], scopeLine: 11, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: ![[#CU2]], templateParams: ![[#Empty]], retainedNodes: ![[#Fun2Params:]])
47 ; CHECK-LLVM: ![[#Func2T]] = !DISubroutineType(types: ![[#Func2TP:]])
48 ; CHECK-LLVM: ![[#Func2TP]] = !{![[#Func2TP1:]],
49 ; CHECK-LLVM-SAME: ![[#Func2TP1]], ![[#Func2TP2:]]
50 ; CHECK-LLVM: ![[#Func2TP1]] = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
51 ; CHECK-LLVM: ![[#Func2TP2]] = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
52 ; CHECK-LLVM: ![[#Fun2Params]] = !{![[#Fun2Param1]], ![[#Fun2Param2]]}
53 ; CHECK-LLVM: ![[#Fun2Param1]] = !DILocalVariable(name: "argc", arg: 1, scope: ![[#Func2]], file: ![[#File]], line: 11, type: ![[#Func2TP1]])
54 ; CHECK-LLVM: ![[#Fun2Param2]] = !DILocalVariable(name: "argv", arg: 2, scope: ![[#Func2]], file: ![[#File]], line: 11, type: ![[#Func2TP2]])
55 ; CHECK-LLVM: ![[#Fun2Param1Loc:]] = !DILocation(line: 11, column: 14, scope: ![[#Func2]])
56 ; CHECK-LLVM: ![[#Fun2Param2Loc:]] = !DILocation(line: 11, column: 26, scope: ![[#Func2]])
57 ; CHECK-LLVM: ![[#Puts2Loc]] = !DILocation(line: 12, column: 3, scope: ![[#Puts2Scope:]]
58 ; CHECK-LLVM: ![[#Puts2Scope]] = distinct !DILexicalBlock(scope: ![[#Func2]], file: ![[#File]], line: 11, column: 34)
59 ; CHECK-LLVM: ![[#CallFoo]] = !DILocation(line: 13, column: 3, scope: ![[#Puts2Scope]])
60 ; CHECK-LLVM: ![[#Ret2]] = !DILocation(line: 14, column: 3, scope: ![[#Puts2Scope]])
61
62
63 target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
64 target triple = "spir64-unknown-unknown"
65
66 ; ModuleID = 'test.bc'
67
68 @str = private unnamed_addr constant [4 x i8] c"FOO\00"
69 @str1 = private unnamed_addr constant [6 x i8] c"Main!\00"
70
71 define void @foo() nounwind !dbg !5 {
72 entry:
73 %puts = tail call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @str, i32 0, i32 0)), !dbg !23
74 ret void, !dbg !25
75 }
76
77 declare i32 @puts(i8* nocapture) nounwind
78
79 define i32 @main(i32 %argc, i8** nocapture %argv) nounwind !dbg !12 {
80 entry:
81 tail call void @llvm.dbg.value(metadata i32 %argc, metadata !21, metadata !DIExpression()), !dbg !26
82 ; Avoid talking about the pointer size in debug info because that's target dependent
83 tail call void @llvm.dbg.value(metadata i8** %argv, metadata !22, metadata !DIExpression(DW_OP_deref, DW_OP_deref)), !dbg !27
84 %puts = tail call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str1, i32 0, i32 0)), !dbg !28
85 tail call void @foo() nounwind, !dbg !30
86 ret i32 0, !dbg !31
87 }
88
89 declare void @llvm.dbg.value(metadata, metadata, metadata) nounwind readnone
90
91 !llvm.dbg.cu = !{!0, !9}
92 !llvm.module.flags = !{!33}
93
94 !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 14", isOptimized: true, emissionKind: FullDebug, file: !32, enums: !1, retainedTypes: !1, globals: !1, imports: !1)
95 !1 = !{}
96 !5 = distinct !DISubprogram(name: "foo", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 5, file: !32, scope: !6, type: !7, retainedNodes: !1)
97 !6 = !DIFile(filename: "foo.c", directory: "/tmp")
98 !7 = !DISubroutineType(types: !8)
99 !8 = !{null}
100 !9 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, producer: "clang version 4", isOptimized: true, emissionKind: FullDebug, file: !32, enums: !1, retainedTypes: !1, globals: !1, imports: !1)
101 !12 = distinct !DISubprogram(name: "main", line: 11, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !9, scopeLine: 11, file: !32, scope: !6, type: !13, retainedNodes: !19)
102 !13 = !DISubroutineType(types: !14)
103 !14 = !{!15, !15, !18}
104 !15 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
105 !18 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
106 !19 = !{!21, !22}
107 !21 = !DILocalVariable(name: "argc", line: 11, arg: 1, scope: !12, file: !6, type: !15)
108 !22 = !DILocalVariable(name: "argv", line: 11, arg: 2, scope: !12, file: !6, type: !18)
109 !23 = !DILocation(line: 6, column: 3, scope: !24)
110 !24 = distinct !DILexicalBlock(line: 5, column: 16, file: !32, scope: !5)
111 !25 = !DILocation(line: 7, column: 1, scope: !24)
112 !26 = !DILocation(line: 11, column: 14, scope: !12)
113 !27 = !DILocation(line: 11, column: 26, scope: !12)
114 !28 = !DILocation(line: 12, column: 3, scope: !29)
115 !29 = distinct !DILexicalBlock(line: 11, column: 34, file: !32, scope: !12)
116 !30 = !DILocation(line: 13, column: 3, scope: !29)
117 !31 = !DILocation(line: 14, column: 3, scope: !29)
118 !32 = !DIFile(filename: "foo.c", directory: "/tmp")
119 !33 = !{i32 1, !"Debug Info Version", i32 3}