xref: /llvm-project/mlir/test/Target/LLVMIR/Import/debug-info.ll (revision 89f2d50cda2462d744e2ef08d662265a8d598e2a)
112b68ad8STobias Gysi; RUN: mlir-translate -import-llvm -mlir-print-debuginfo -split-input-file %s | FileCheck %s
212b68ad8STobias Gysi
37d5b4ebbSChristian Ulmann; CHECK: #[[$UNKNOWN_LOC:.+]] = loc(unknown)
43589885dSTobias Gysi
53589885dSTobias Gysi; CHECK-LABEL: @module_loc(
63589885dSTobias Gysidefine i32 @module_loc(i32 %0) {
712b68ad8STobias Gysientry:
812b68ad8STobias Gysi  br label %next
912b68ad8STobias Gysiend:
107d5b4ebbSChristian Ulmann  ; CHECK: ^{{.*}}(%{{.+}}: i32 loc(unknown)):
1112b68ad8STobias Gysi  %1 = phi i32 [ %2, %next ]
1212b68ad8STobias Gysi  ret i32 %1
1312b68ad8STobias Gysinext:
147d5b4ebbSChristian Ulmann  ; CHECK: = llvm.mul %{{.+}}, %{{.+}} : i32 loc(#[[$UNKNOWN_LOC]])
1512b68ad8STobias Gysi  %2 = mul i32 %0, %0
1612b68ad8STobias Gysi  br label %end
1712b68ad8STobias Gysi}
1812b68ad8STobias Gysi
19aef89c8bSRiver Riddle; // -----
2012b68ad8STobias Gysi
213f63889dSTobias Gysi; CHECK-LABEL: @instruction_loc
223f63889dSTobias Gysidefine i32 @instruction_loc(i32 %arg1) {
23aef89c8bSRiver Riddle  ; CHECK: llvm.add {{.*}} loc(#[[FILE_LOC:.*]])
243f63889dSTobias Gysi  %1 = add i32 %arg1, %arg1, !dbg !5
253f63889dSTobias Gysi
26aef89c8bSRiver Riddle  ; CHECK: llvm.mul {{.*}} loc(#[[CALLSITE_LOC:.*]])
273f63889dSTobias Gysi  %2 = mul i32 %1, %1, !dbg !7
283f63889dSTobias Gysi
293f63889dSTobias Gysi  ret i32 %2
303f63889dSTobias Gysi}
31aef89c8bSRiver Riddle
32aef89c8bSRiver Riddle; CHECK-DAG: #[[RAW_FILE_LOC:.+]] = loc("debug-info.ll":1:2)
33bae1fdeaSChristian Ulmann; CHECK-DAG: #[[SP:.+]] =  #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #{{.*}}, scope = #{{.*}}, name = "instruction_loc"
34bae1fdeaSChristian Ulmann; CHECK-DAG: #[[CALLEE:.+]] =  #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #{{.*}}, scope = #{{.*}}, name = "callee"
35aef89c8bSRiver Riddle; CHECK-DAG: #[[FILE_LOC]] = loc(fused<#[[SP]]>[#[[RAW_FILE_LOC]]])
362ea60f41SBilly Zhu; CHECK-DAG: #[[RAW_CALLEE_LOC:.+]] = loc("debug-info.ll":7:4)
372ea60f41SBilly Zhu; CHECK-DAG: #[[CALLEE_LOC:.+]] = loc(fused<#[[CALLEE]]>[#[[RAW_CALLEE_LOC]]])
38aef89c8bSRiver Riddle; CHECK-DAG: #[[RAW_CALLER_LOC:.+]] = loc("debug-info.ll":2:2)
39aef89c8bSRiver Riddle; CHECK-DAG: #[[CALLER_LOC:.+]] = loc(fused<#[[SP]]>[#[[RAW_CALLER_LOC]]])
402ea60f41SBilly Zhu; CHECK-DAG: #[[CALLSITE_LOC:.+]] = loc(callsite(#[[CALLEE_LOC]] at #[[CALLER_LOC]]))
413f63889dSTobias Gysi
423f63889dSTobias Gysi!llvm.dbg.cu = !{!1}
433f63889dSTobias Gysi!llvm.module.flags = !{!0}
443f63889dSTobias Gysi!0 = !{i32 2, !"Debug Info Version", i32 3}
453f63889dSTobias Gysi!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
463f63889dSTobias Gysi!2 = !DIFile(filename: "debug-info.ll", directory: "/")
4736fa80b0STobias Gysi!3 = distinct !DISubprogram(name: "instruction_loc", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
4836fa80b0STobias Gysi!4 = distinct !DISubprogram(name: "callee", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
493f63889dSTobias Gysi!5 = !DILocation(line: 1, column: 2, scope: !3)
503f63889dSTobias Gysi!6 = !DILocation(line: 2, column: 2, scope: !3)
513f63889dSTobias Gysi!7 = !DILocation(line: 7, column: 4, scope: !4, inlinedAt: !6)
523f63889dSTobias Gysi
533f63889dSTobias Gysi; // -----
543f63889dSTobias Gysi
553f63889dSTobias Gysi; CHECK-LABEL: @lexical_block
563f63889dSTobias Gysidefine i32 @lexical_block(i32 %arg1) {
57aef89c8bSRiver Riddle  ; CHECK: llvm.add {{.*}} loc(#[[LOC0:.*]])
583f63889dSTobias Gysi  %1 = add i32 %arg1, %arg1, !dbg !6
593f63889dSTobias Gysi
60aef89c8bSRiver Riddle  ; CHECK: llvm.mul {{.*}} loc(#[[LOC1:.*]])
613f63889dSTobias Gysi  %2 = mul i32 %arg1, %arg1, !dbg !7
623f63889dSTobias Gysi
633f63889dSTobias Gysi  ret i32 %2
643f63889dSTobias Gysi}
65aef89c8bSRiver Riddle; CHECK: #[[FILE:.+]] = #llvm.di_file<"debug-info.ll" in "/">
66bae1fdeaSChristian Ulmann; CHECK: #[[SP:.+]] = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit =
67aef89c8bSRiver Riddle; CHECK: #[[LB0:.+]] = #llvm.di_lexical_block<scope = #[[SP]]>
68aef89c8bSRiver Riddle; CHECK: #[[LB1:.+]] = #llvm.di_lexical_block<scope = #[[SP]], file = #[[FILE]], line = 2, column = 2>
69aef89c8bSRiver Riddle; CHECK: #[[LOC0]] = loc(fused<#[[LB0]]>[{{.*}}])
70aef89c8bSRiver Riddle; CHECK: #[[LOC1]] = loc(fused<#[[LB1]]>[{{.*}}])
713f63889dSTobias Gysi
723f63889dSTobias Gysi!llvm.dbg.cu = !{!1}
733f63889dSTobias Gysi!llvm.module.flags = !{!0}
743f63889dSTobias Gysi!0 = !{i32 2, !"Debug Info Version", i32 3}
753f63889dSTobias Gysi!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
763f63889dSTobias Gysi!2 = !DIFile(filename: "debug-info.ll", directory: "/")
7736fa80b0STobias Gysi!3 = distinct !DISubprogram(name: "lexical_block", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
783f63889dSTobias Gysi!4 = !DILexicalBlock(scope: !3)
793f63889dSTobias Gysi!5 = !DILexicalBlock(scope: !3, file: !2, line: 2, column: 2)
803f63889dSTobias Gysi!6 = !DILocation(line: 1, column: 2, scope: !4)
813f63889dSTobias Gysi!7 = !DILocation(line: 2, column: 2, scope: !5)
823f63889dSTobias Gysi
833f63889dSTobias Gysi; // -----
843f63889dSTobias Gysi
853f63889dSTobias Gysi; CHECK-LABEL: @lexical_block_file
863f63889dSTobias Gysidefine i32 @lexical_block_file(i32 %arg1) {
87aef89c8bSRiver Riddle  ; CHECK: llvm.add {{.*}} loc(#[[LOC0:.*]])
883f63889dSTobias Gysi  %1 = add i32 %arg1, %arg1, !dbg !6
893f63889dSTobias Gysi
90aef89c8bSRiver Riddle  ; CHECK: llvm.mul {{.*}} loc(#[[LOC1:.*]])
913f63889dSTobias Gysi  %2 = mul i32 %arg1, %arg1, !dbg !7
923f63889dSTobias Gysi
933f63889dSTobias Gysi  ret i32 %2
943f63889dSTobias Gysi}
95aef89c8bSRiver Riddle; CHECK: #[[FILE:.+]] = #llvm.di_file<"debug-info.ll" in "/">
96bae1fdeaSChristian Ulmann; CHECK: #[[SP:.+]] = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit =
97aef89c8bSRiver Riddle; CHECK: #[[LB0:.+]] = #llvm.di_lexical_block_file<scope = #[[SP]], discriminator = 0>
98aef89c8bSRiver Riddle; CHECK: #[[LB1:.+]] = #llvm.di_lexical_block_file<scope = #[[SP]], file = #[[FILE]], discriminator = 0>
99aef89c8bSRiver Riddle; CHECK: #[[LOC0]] = loc(fused<#[[LB0]]>[
100aef89c8bSRiver Riddle; CHECK: #[[LOC1]] = loc(fused<#[[LB1]]>[
1013f63889dSTobias Gysi
1023f63889dSTobias Gysi!llvm.dbg.cu = !{!1}
1033f63889dSTobias Gysi!llvm.module.flags = !{!0}
1043f63889dSTobias Gysi!0 = !{i32 2, !"Debug Info Version", i32 3}
1053f63889dSTobias Gysi!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
1063f63889dSTobias Gysi!2 = !DIFile(filename: "debug-info.ll", directory: "/")
10736fa80b0STobias Gysi!3 = distinct !DISubprogram(name: "lexical_block_file", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
1083f63889dSTobias Gysi!4 = !DILexicalBlockFile(scope: !3, discriminator: 0)
1093f63889dSTobias Gysi!5 = !DILexicalBlockFile(scope: !3, file: !2, discriminator: 0)
1103f63889dSTobias Gysi!6 = !DILocation(line: 1, column: 2, scope: !4)
1113f63889dSTobias Gysi!7 = !DILocation(line: 2, column: 2, scope: !5)
1123f63889dSTobias Gysi
1133f63889dSTobias Gysi; // -----
1143f63889dSTobias Gysi
115873ea451SChristian Ulmann; CHECK-DAG: #[[NULL:.+]] = #llvm.di_null_type
116f61f42b9STobias Gysi; CHECK-DAG: #[[INT1:.+]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int1">
117f61f42b9STobias Gysi; CHECK-DAG: #[[INT2:.+]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int2", sizeInBits = 32, encoding = DW_ATE_signed>
118873ea451SChristian Ulmann; CHECK-DAG: #llvm.di_subroutine_type<types = #[[NULL]], #[[INT1]], #[[INT2]]>
1193f63889dSTobias Gysi
1203f63889dSTobias Gysidefine void @basic_type() !dbg !3 {
1213f63889dSTobias Gysi  ret void
1223f63889dSTobias Gysi}
1233f63889dSTobias Gysi
1243f63889dSTobias Gysi!llvm.dbg.cu = !{!1}
1253f63889dSTobias Gysi!llvm.module.flags = !{!0}
1263f63889dSTobias Gysi!0 = !{i32 2, !"Debug Info Version", i32 3}
1273f63889dSTobias Gysi!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
1283f63889dSTobias Gysi!2 = !DIFile(filename: "debug-info.ll", directory: "/")
12936fa80b0STobias Gysi!3 = distinct !DISubprogram(name: "basic_type", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !4)
1303f63889dSTobias Gysi!4 = !DISubroutineType(types: !5)
1313f63889dSTobias Gysi!5 = !{null, !6, !7}
1323f63889dSTobias Gysi!6 = !DIBasicType(name: "int1")
1333f63889dSTobias Gysi!7 = !DIBasicType(name: "int2", encoding: DW_ATE_signed, size: 32)
1343f63889dSTobias Gysi
1353f63889dSTobias Gysi; // -----
1363f63889dSTobias Gysi
1373f63889dSTobias Gysi; CHECK: #[[INT:.+]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int">
13836fa80b0STobias Gysi; CHECK: #[[PTR1:.+]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #[[INT]]>
1394095a326SChristian Ulmann; CHECK: #[[PTR2:.+]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, name = "mypointer", baseType = #[[INT]], sizeInBits = 64, alignInBits = 32, offsetInBits = 4, extraData = #[[INT]]>
1405c35b63dSWilliam G Hatch; CHECK: #[[PTR3:.+]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #[[INT]], dwarfAddressSpace = 3>
1415c35b63dSWilliam G Hatch; CHECK: #llvm.di_subroutine_type<types = #[[PTR1]], #[[PTR2]], #[[PTR3]]>
1423f63889dSTobias Gysi
1433f63889dSTobias Gysidefine void @derived_type() !dbg !3 {
1443f63889dSTobias Gysi  ret void
1453f63889dSTobias Gysi}
1463f63889dSTobias Gysi
1473f63889dSTobias Gysi!llvm.dbg.cu = !{!1}
1483f63889dSTobias Gysi!llvm.module.flags = !{!0}
1493f63889dSTobias Gysi!0 = !{i32 2, !"Debug Info Version", i32 3}
1503f63889dSTobias Gysi!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
1513f63889dSTobias Gysi!2 = !DIFile(filename: "debug-info.ll", directory: "/")
15236fa80b0STobias Gysi!3 = distinct !DISubprogram(name: "derived_type", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !4)
1533f63889dSTobias Gysi!4 = !DISubroutineType(types: !5)
1545c35b63dSWilliam G Hatch!5 = !{!7, !8, !9}
1553f63889dSTobias Gysi!6 = !DIBasicType(name: "int")
1563f63889dSTobias Gysi!7 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6)
1574095a326SChristian Ulmann!8 = !DIDerivedType(name: "mypointer", tag: DW_TAG_pointer_type, baseType: !6, size: 64, align: 32, offset: 4, extraData: !6)
1585c35b63dSWilliam G Hatch!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !6, dwarfAddressSpace: 3)
1593f63889dSTobias Gysi
1603f63889dSTobias Gysi; // -----
1613f63889dSTobias Gysi
162446fc42dSRiver Riddle; CHECK-DAG: #[[INT:.+]] = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "int">
163446fc42dSRiver Riddle; CHECK-DAG: #[[FILE:.+]] = #llvm.di_file<"debug-info.ll" in "/">
16450d837e3SAbid Qadeer; CHECK-DAG: #[[VAR:.+]] = #llvm.di_local_variable<{{.*}}name = "size">
16550d837e3SAbid Qadeer; CHECK-DAG: #[[GV:.+]] = #llvm.di_global_variable<{{.*}}name = "gv"{{.*}}>
1664ce93d53SChristian Ulmann; CHECK-DAG: #[[COMP1:.+]] = #llvm.di_composite_type<tag = DW_TAG_array_type, name = "array1", line = 10, baseType = #[[INT]], sizeInBits = 128, alignInBits = 32>
16736fa80b0STobias Gysi; CHECK-DAG: #[[COMP2:.+]] = #llvm.di_composite_type<{{.*}}, file = #[[FILE]], scope = #[[FILE]], baseType = #[[INT]]>
16836fa80b0STobias Gysi; CHECK-DAG: #[[COMP3:.+]] = #llvm.di_composite_type<{{.*}}, flags = Vector, elements = #llvm.di_subrange<count = 4 : i64>>
16936fa80b0STobias Gysi; CHECK-DAG: #[[COMP4:.+]] = #llvm.di_composite_type<{{.*}}, flags = Vector, elements = #llvm.di_subrange<lowerBound = 0 : i64, upperBound = 4 : i64, stride = 1 : i64>>
17050d837e3SAbid Qadeer; CHECK-DAG: #[[COMP5:.+]] = #llvm.di_composite_type<{{.*}}, name = "var_elements"{{.*}}elements = #llvm.di_subrange<count = #[[VAR]], stride = #[[GV]]>>
17150d837e3SAbid Qadeer; CHECK-DAG: #[[COMP6:.+]] = #llvm.di_composite_type<{{.*}}, name = "expr_elements"{{.*}}elements = #llvm.di_subrange<count = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(16), DW_OP_deref]>>>
172*89f2d50cSAbid Qadeer; CHECK-DAG: #[[COMP7:.+]] = #llvm.di_composite_type<{{.*}}, name = "expr_elements2"{{.*}}elements = #llvm.di_generic_subrange<count = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(16), DW_OP_deref]>, lowerBound = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(24), DW_OP_deref]>, stride = #llvm.di_expression<[DW_OP_push_object_address, DW_OP_plus_uconst(32), DW_OP_deref]>>>
173*89f2d50cSAbid Qadeer; CHECK-DAG: #llvm.di_subroutine_type<types = #[[COMP1]], #[[COMP2]], #[[COMP3]], #[[COMP4]], #[[COMP5]], #[[COMP6]], #[[COMP7]]>
17450d837e3SAbid Qadeer
17550d837e3SAbid Qadeer@gv = external global i64
1763f63889dSTobias Gysi
1773f63889dSTobias Gysidefine void @composite_type() !dbg !3 {
1783f63889dSTobias Gysi  ret void
1793f63889dSTobias Gysi}
1803f63889dSTobias Gysi
1813f63889dSTobias Gysi!llvm.dbg.cu = !{!1}
1823f63889dSTobias Gysi!llvm.module.flags = !{!0}
1833f63889dSTobias Gysi!0 = !{i32 2, !"Debug Info Version", i32 3}
1843f63889dSTobias Gysi!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
1853f63889dSTobias Gysi!2 = !DIFile(filename: "debug-info.ll", directory: "/")
18636fa80b0STobias Gysi!3 = distinct !DISubprogram(name: "composite_type", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, type: !4)
1873f63889dSTobias Gysi!4 = !DISubroutineType(types: !5)
188*89f2d50cSAbid Qadeer!5 = !{!7, !8, !9, !10, !18, !22, !24}
1893f63889dSTobias Gysi!6 = !DIBasicType(name: "int")
1904ce93d53SChristian Ulmann!7 = !DICompositeType(tag: DW_TAG_array_type, name: "array1", line: 10, size: 128, align: 32, baseType: !6)
1913f63889dSTobias Gysi!8 = !DICompositeType(tag: DW_TAG_array_type, name: "array2", file: !2, scope: !2, baseType: !6)
1924ce93d53SChristian Ulmann!9 = !DICompositeType(tag: DW_TAG_array_type, name: "array3", flags: DIFlagVector, elements: !13, baseType: !6)
1934ce93d53SChristian Ulmann!10 = !DICompositeType(tag: DW_TAG_array_type, name: "array4", flags: DIFlagVector, elements: !14, baseType: !6)
1943f63889dSTobias Gysi!11 = !DISubrange(count: 4)
1953f63889dSTobias Gysi!12 = !DISubrange(lowerBound: 0, upperBound: 4, stride: 1)
1963f63889dSTobias Gysi!13 = !{!11}
1973f63889dSTobias Gysi!14 = !{!12}
19850d837e3SAbid Qadeer!15 = !DISubrange(count: !16, stride: !23)
199e594c45eSChristian Ulmann!16 = !DILocalVariable(scope: !3, name: "size")
200e594c45eSChristian Ulmann!17 = !{!15}
20150d837e3SAbid Qadeer!18 = !DICompositeType(tag: DW_TAG_array_type, name: "var_elements", flags: DIFlagVector, elements: !17, baseType: !6)
20250d837e3SAbid Qadeer!19 = !DISubrange(count: !20)
20350d837e3SAbid Qadeer!20 = !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 16, DW_OP_deref)
20450d837e3SAbid Qadeer!21 = !{!19}
20550d837e3SAbid Qadeer!22 = !DICompositeType(tag: DW_TAG_array_type, name: "expr_elements", flags: DIFlagVector, elements: !21, baseType: !6)
20650d837e3SAbid Qadeer!23 = !DIGlobalVariable(name: "gv", scope: !1, file: !2, line: 3, type: !6, isLocal: false, isDefinition: false)
207*89f2d50cSAbid Qadeer!24 = !DICompositeType(tag: DW_TAG_array_type, name: "expr_elements2", elements: !29, baseType: !6)
208*89f2d50cSAbid Qadeer!25 = !DIGenericSubrange(count: !26, lowerBound: !27, stride: !28)
209*89f2d50cSAbid Qadeer!26 = !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 16, DW_OP_deref)
210*89f2d50cSAbid Qadeer!27 = !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 24, DW_OP_deref)
211*89f2d50cSAbid Qadeer!28 = !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 32, DW_OP_deref)
212*89f2d50cSAbid Qadeer!29 = !{!25}
21350d837e3SAbid Qadeer
214e594c45eSChristian Ulmann
2153f63889dSTobias Gysi; // -----
2163f63889dSTobias Gysi
217f61f42b9STobias Gysi; CHECK-DAG: #[[FILE:.+]] = #llvm.di_file<"debug-info.ll" in "/">
2186f633685SBilly Zhu; CHECK-DAG: #[[CU:.+]] = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #[[FILE]], isOptimized = false, emissionKind = None, nameTableKind = None>
219f61f42b9STobias Gysi; Verify an empty subroutine types list is supported.
220f61f42b9STobias Gysi; CHECK-DAG: #[[SP_TYPE:.+]] = #llvm.di_subroutine_type<callingConvention = DW_CC_normal>
221bae1fdeaSChristian Ulmann; CHECK-DAG: #[[SP:.+]] = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #[[CU]], scope = #[[FILE]], name = "subprogram", linkageName = "subprogram", file = #[[FILE]], line = 42, scopeLine = 42, subprogramFlags = Definition, type = #[[SP_TYPE]]>
2223f63889dSTobias Gysi
2233f63889dSTobias Gysidefine void @subprogram() !dbg !3 {
2243f63889dSTobias Gysi  ret void
2253f63889dSTobias Gysi}
2263f63889dSTobias Gysi
2273f63889dSTobias Gysi!llvm.dbg.cu = !{!1}
2283f63889dSTobias Gysi!llvm.module.flags = !{!0}
2293f63889dSTobias Gysi!0 = !{i32 2, !"Debug Info Version", i32 3}
2306f633685SBilly Zhu!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, nameTableKind: None)
2313f63889dSTobias Gysi!2 = !DIFile(filename: "debug-info.ll", directory: "/")
2323f63889dSTobias Gysi!3 = distinct !DISubprogram(name: "subprogram", linkageName: "subprogram", scope: !2, file: !2, line: 42, scopeLine: 42, spFlags: DISPFlagDefinition, unit: !1, type: !4)
2333f63889dSTobias Gysi!4 = !DISubroutineType(cc: DW_CC_normal, types: !5)
234f61f42b9STobias Gysi!5 = !{}
2353f63889dSTobias Gysi!6 = !DIBasicType(name: "int")
2363f63889dSTobias Gysi
2373f63889dSTobias Gysi; // -----
2383f63889dSTobias Gysi
2393f63889dSTobias Gysi; CHECK-LABEL: @func_loc
2403f63889dSTobias Gysidefine void @func_loc() !dbg !3 {
2413f63889dSTobias Gysi  ret void
2423f63889dSTobias Gysi}
24318e5055dSTobias Gysi; CHECK-DAG: #[[NAME_LOC:.+]] = loc("func_loc")
24418e5055dSTobias Gysi; CHECK-DAG: #[[FILE_LOC:.+]] = loc("debug-info.ll":42:0)
245bae1fdeaSChristian Ulmann; CHECK-DAG: #[[SP:.+]] =  #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #{{.*}}, scope = #{{.*}}, name = "func_loc", file = #{{.*}}, line = 42, subprogramFlags = Definition>
24618e5055dSTobias Gysi
24718e5055dSTobias Gysi; CHECK: loc(fused<#[[SP]]>[#[[NAME_LOC]], #[[FILE_LOC]]]
2483f63889dSTobias Gysi
2493f63889dSTobias Gysi!llvm.dbg.cu = !{!1}
2503f63889dSTobias Gysi!llvm.module.flags = !{!0}
2513f63889dSTobias Gysi!0 = !{i32 2, !"Debug Info Version", i32 3}
2523f63889dSTobias Gysi!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
2533f63889dSTobias Gysi!2 = !DIFile(filename: "debug-info.ll", directory: "/")
25418e5055dSTobias Gysi!3 = distinct !DISubprogram(name: "func_loc", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1, line: 42)
2553f63889dSTobias Gysi
2563f63889dSTobias Gysi; // -----
2573f63889dSTobias Gysi
2583f63889dSTobias Gysi; Verify the module location is set to the source filename.
2593f63889dSTobias Gysi; CHECK: loc("debug-info.ll":0:0)
2603f63889dSTobias Gysisource_filename = "debug-info.ll"
261be4b4940STobias Gysi
262be4b4940STobias Gysi; // -----
263be4b4940STobias Gysi
264c04d08c2SChristian Ulmann; NOTE: The debug intrinsics are reordered as a side-effect of the dominance-
265c04d08c2SChristian Ulmann;       preserving measures needed to import LLVM IR.
266c04d08c2SChristian Ulmann
267ac1b69b9STobias Gysi; CHECK: #[[FILE:.+]] = #llvm.di_file<
268be4b4940STobias Gysi; CHECK: #[[$SP:.+]] = #llvm.di_subprogram<
269ac1b69b9STobias Gysi; CHECK: #[[$LABEL:.+]] = #llvm.di_label<scope = #[[$SP]], name = "label", file = #[[FILE]], line = 42>
270be4b4940STobias Gysi; CHECK: #[[$VAR1:.+]] = #llvm.di_local_variable<scope = #[[$SP]], name = "arg">
271c04d08c2SChristian Ulmann; CHECK: #[[$VAR0:.+]] = #llvm.di_local_variable<scope = #[[$SP]], name = "arg", file = #[[FILE]], line = 1, arg = 1, alignInBits = 32, type = #{{.*}}>
272be4b4940STobias Gysi
273be4b4940STobias Gysi; CHECK-LABEL: @intrinsic
274be4b4940STobias Gysi; CHECK-SAME:  %[[ARG0:[a-zA-Z0-9]+]]
275be4b4940STobias Gysi; CHECK-SAME:  %[[ARG1:[a-zA-Z0-9]+]]
276be4b4940STobias Gysidefine void @intrinsic(i64 %0, ptr %1) {
277c04d08c2SChristian Ulmann  ; CHECK: llvm.intr.dbg.declare #[[$VAR1]] = %[[ARG1]] : !llvm.ptr loc(#[[LOC1:.+]])
2786da578ceSJustin Wilson  ; CHECK: llvm.intr.dbg.value #[[$VAR0]] #llvm.di_expression<[DW_OP_deref, DW_OP_constu(3), DW_OP_plus, DW_OP_LLVM_convert(4, DW_ATE_signed)]> = %[[ARG0]] : i64 loc(#[[LOC0:.+]])
2796da578ceSJustin Wilson  ; CHECK: llvm.intr.dbg.value #[[$VAR0]] #llvm.di_expression<[DW_OP_deref, DW_OP_constu(3), DW_OP_plus, DW_OP_LLVM_fragment(3, 7)]> = %[[ARG0]] : i64 loc(#[[LOC0:.+]])
2806da578ceSJustin Wilson  call void @llvm.dbg.value(metadata i64 %0, metadata !5, metadata !DIExpression(DW_OP_deref, DW_OP_constu, 3, DW_OP_plus, DW_OP_LLVM_fragment, 3, 7)), !dbg !7
2816da578ceSJustin Wilson  call void @llvm.dbg.value(metadata i64 %0, metadata !5, metadata !DIExpression(DW_OP_deref, DW_OP_constu, 3, DW_OP_plus, DW_OP_LLVM_convert, 4, DW_ATE_signed)), !dbg !7
282be4b4940STobias Gysi  call void @llvm.dbg.declare(metadata ptr %1, metadata !6, metadata !DIExpression()), !dbg !9
283ac1b69b9STobias Gysi  ; CHECK: llvm.intr.dbg.label #[[$LABEL]] loc(#[[LOC1:.+]])
284ac1b69b9STobias Gysi  call void @llvm.dbg.label(metadata !10), !dbg !9
285be4b4940STobias Gysi  ret void
286be4b4940STobias Gysi}
287be4b4940STobias Gysi
288aef89c8bSRiver Riddle; CHECK: #[[LOC1]] = loc(fused<#[[$SP]]>[{{.*}}])
289c04d08c2SChristian Ulmann; CHECK: #[[LOC0]] = loc(fused<#[[$SP]]>[{{.*}}])
290be4b4940STobias Gysi
291be4b4940STobias Gysideclare void @llvm.dbg.value(metadata, metadata, metadata)
292be4b4940STobias Gysideclare void @llvm.dbg.declare(metadata, metadata, metadata)
293ac1b69b9STobias Gysideclare void @llvm.dbg.label(metadata)
294be4b4940STobias Gysi
295be4b4940STobias Gysi!llvm.dbg.cu = !{!1}
296be4b4940STobias Gysi!llvm.module.flags = !{!0}
297be4b4940STobias Gysi!0 = !{i32 2, !"Debug Info Version", i32 3}
298be4b4940STobias Gysi!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
299be4b4940STobias Gysi!2 = !DIFile(filename: "debug-info.ll", directory: "/")
30036fa80b0STobias Gysi!3 = distinct !DISubprogram(name: "intrinsic", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
301be4b4940STobias Gysi!4 = !DIBasicType(name: "int")
302be4b4940STobias Gysi!5 = !DILocalVariable(scope: !3, name: "arg", file: !2, line: 1, arg: 1, align: 32, type: !4);
303be4b4940STobias Gysi!6 = !DILocalVariable(scope: !3, name: "arg")
304be4b4940STobias Gysi!7 = !DILocation(line: 1, column: 2, scope: !3)
305be4b4940STobias Gysi!8 = !DILocation(line: 2, column: 2, scope: !3)
306be4b4940STobias Gysi!9 = !DILocation(line: 3, column: 2, scope: !3)
307ac1b69b9STobias Gysi!10 = !DILabel(scope: !3, name: "label", file: !2, line: 42)
308838fdefcSTobias Gysi
309838fdefcSTobias Gysi; // -----
310838fdefcSTobias Gysi
311838fdefcSTobias Gysi; CHECK-LABEL: @class_method
312d148f8d7STobias Gysidefine void @class_method() {
313838fdefcSTobias Gysi  ; CHECK: llvm.return loc(#[[LOC:.+]])
314d148f8d7STobias Gysi  ret void, !dbg !9
315838fdefcSTobias Gysi}
316838fdefcSTobias Gysi
31775197553STobias Gysi; Verify the cyclic subprogram is handled correctly.
31875197553STobias Gysi; CHECK-DAG: #[[SP_SELF:.+]] = #llvm.di_subprogram<recId = [[REC_ID:.+]], isRecSelf = true>
31975197553STobias Gysi; CHECK-DAG: #[[COMP:.+]] = #llvm.di_composite_type<tag = DW_TAG_class_type, name = "class_name", file = #{{.*}}, line = 42, flags = "TypePassByReference|NonTrivial", elements = #[[SP_SELF]]>
32075197553STobias Gysi; CHECK-DAG: #[[COMP_PTR:.+]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #[[COMP]], sizeInBits = 64>
321dd866040SBilly Zhu; CHECK-DAG: #[[SP_TYPE:.+]] = #llvm.di_subroutine_type<types = #{{.*}}, #[[COMP_PTR]]>
32275197553STobias Gysi; CHECK-DAG: #[[SP:.+]] = #llvm.di_subprogram<recId = [[REC_ID]], id = [[SP_ID:.+]], compileUnit = #{{.*}}, scope = #[[COMP]], name = "class_method", file = #{{.*}}, subprogramFlags = Definition, type = #[[SP_TYPE]]>
32375197553STobias Gysi; CHECK-DAG: #[[LOC]] = loc(fused<#[[SP]]>
324838fdefcSTobias Gysi
325838fdefcSTobias Gysi!llvm.dbg.cu = !{!1}
326838fdefcSTobias Gysi!llvm.module.flags = !{!0}
327838fdefcSTobias Gysi!0 = !{i32 2, !"Debug Info Version", i32 3}
328838fdefcSTobias Gysi!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
329838fdefcSTobias Gysi!2 = !DIFile(filename: "debug-info.ll", directory: "/")
330d148f8d7STobias Gysi!3 = !DICompositeType(tag: DW_TAG_class_type, name: "class_name", file: !2, line: 42, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !4)
331d148f8d7STobias Gysi!4 = !{!5}
332d148f8d7STobias Gysi!5 = distinct !DISubprogram(name: "class_method", scope: !3, file: !2, type: !6, spFlags: DISPFlagDefinition, unit: !1)
333d148f8d7STobias Gysi!6 = !DISubroutineType(types: !7)
334d148f8d7STobias Gysi!7 = !{null, !8}
335d148f8d7STobias Gysi!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
336d148f8d7STobias Gysi!9 = !DILocation(line: 1, column: 2, scope: !5)
337d148f8d7STobias Gysi
338d148f8d7STobias Gysi; // -----
339d148f8d7STobias Gysi
3401e8dad3bSBilly Zhu; Verify the cyclic composite type is handled correctly.
34175197553STobias Gysi; CHECK-DAG: #[[COMP_SELF:.+]] = #llvm.di_composite_type<recId = [[REC_ID:.+]], isRecSelf = true>
342dd866040SBilly Zhu; CHECK-DAG: #[[COMP_PTR_INNER:.+]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #[[COMP_SELF]]>
343dd866040SBilly Zhu; CHECK-DAG: #[[FIELD:.+]] = #llvm.di_derived_type<tag = DW_TAG_member, name = "call_field", baseType = #[[COMP_PTR_INNER]]>
34475197553STobias Gysi; CHECK-DAG: #[[COMP:.+]] = #llvm.di_composite_type<recId = [[REC_ID]], tag = DW_TAG_class_type, name = "class_field", file = #{{.*}}, line = 42, flags = "TypePassByReference|NonTrivial", elements = #[[FIELD]]>
345dd866040SBilly Zhu; CHECK-DAG: #[[COMP_PTR_OUTER:.+]] = #llvm.di_derived_type<tag = DW_TAG_pointer_type, baseType = #[[COMP]]>
346dd866040SBilly Zhu; CHECK-DAG: #[[VAR0:.+]] = #llvm.di_local_variable<scope = #{{.*}}, name = "class_field", file = #{{.*}}, type = #[[COMP_PTR_OUTER]]>
347d148f8d7STobias Gysi
3481e8dad3bSBilly Zhu; CHECK: @class_field
349d148f8d7STobias Gysi; CHECK-SAME:  %[[ARG0:[a-zA-Z0-9]+]]
350d148f8d7STobias Gysidefine void @class_field(ptr %arg1) {
3511e8dad3bSBilly Zhu  ; CHECK: llvm.intr.dbg.value #[[VAR0]] = %[[ARG0]] : !llvm.ptr
352d148f8d7STobias Gysi  call void @llvm.dbg.value(metadata ptr %arg1, metadata !7, metadata !DIExpression()), !dbg !9
353d148f8d7STobias Gysi  ret void
354d148f8d7STobias Gysi}
355d148f8d7STobias Gysi
356d148f8d7STobias Gysideclare void @llvm.dbg.value(metadata, metadata, metadata)
357d148f8d7STobias Gysi
358d148f8d7STobias Gysi!llvm.dbg.cu = !{!1}
359d148f8d7STobias Gysi!llvm.module.flags = !{!0}
360d148f8d7STobias Gysi!0 = !{i32 2, !"Debug Info Version", i32 3}
361d148f8d7STobias Gysi!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
362d148f8d7STobias Gysi!2 = !DIFile(filename: "debug-info.ll", directory: "/")
363d148f8d7STobias Gysi!3 = !DICompositeType(tag: DW_TAG_class_type, name: "class_field", file: !2, line: 42, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !4)
364d148f8d7STobias Gysi!4 = !{!6}
365d148f8d7STobias Gysi!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, flags: DIFlagArtificial | DIFlagObjectPointer)
366d148f8d7STobias Gysi!6 = !DIDerivedType(tag: DW_TAG_member, name: "call_field", file: !2, baseType: !5)
367d148f8d7STobias Gysi!7 = !DILocalVariable(scope: !8, name: "class_field", file: !2, type: !5);
368d148f8d7STobias Gysi!8 = distinct !DISubprogram(name: "class_field", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
369d148f8d7STobias Gysi!9 = !DILocation(line: 1, column: 2, scope: !8)
370873ea451SChristian Ulmann
371873ea451SChristian Ulmann; // -----
372873ea451SChristian Ulmann
373873ea451SChristian Ulmann; CHECK-DAG: #[[NULL:.+]] = #llvm.di_null_type
374873ea451SChristian Ulmann; CHECK-DAG: #llvm.di_subroutine_type<types = #[[NULL]], #[[NULL]]>
375873ea451SChristian Ulmann
376873ea451SChristian Ulmanndeclare !dbg !3 void @variadic_func()
377873ea451SChristian Ulmann
378873ea451SChristian Ulmann!llvm.dbg.cu = !{!1}
379873ea451SChristian Ulmann!llvm.module.flags = !{!0}
380873ea451SChristian Ulmann!0 = !{i32 2, !"Debug Info Version", i32 3}
381873ea451SChristian Ulmann!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
382873ea451SChristian Ulmann!2 = !DIFile(filename: "debug-info.ll", directory: "/")
383873ea451SChristian Ulmann!3 = !DISubprogram(name: "variadic_func", scope: !2, file: !2, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, type: !4)
384873ea451SChristian Ulmann!4 = !DISubroutineType(types: !5)
385873ea451SChristian Ulmann!5 = !{null, null}
38628542e99SChristian Ulmann
38728542e99SChristian Ulmann; // -----
38828542e99SChristian Ulmann
38928542e99SChristian Ulmanndefine void @dbg_use_before_def(ptr %arg) {
390b808648aSChristian Ulmann  ; CHECK: llvm.getelementptr
391b808648aSChristian Ulmann  ; CHECK-NEXT: llvm.intr.dbg.value
39228542e99SChristian Ulmann  call void @llvm.dbg.value(metadata ptr %dbg_arg, metadata !7, metadata !DIExpression()), !dbg !9
39328542e99SChristian Ulmann  %dbg_arg = getelementptr double, ptr %arg, i64 16
39428542e99SChristian Ulmann  ret void
39528542e99SChristian Ulmann}
39628542e99SChristian Ulmann
39728542e99SChristian Ulmanndeclare void @llvm.dbg.value(metadata, metadata, metadata)
39828542e99SChristian Ulmann
39928542e99SChristian Ulmann!llvm.dbg.cu = !{!1}
40028542e99SChristian Ulmann!llvm.module.flags = !{!0}
40128542e99SChristian Ulmann!0 = !{i32 2, !"Debug Info Version", i32 3}
40228542e99SChristian Ulmann!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
40328542e99SChristian Ulmann!2 = !DIFile(filename: "debug-info.ll", directory: "/")
40428542e99SChristian Ulmann!3 = !DICompositeType(tag: DW_TAG_class_type, name: "class_field", file: !2, line: 42, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !4)
40528542e99SChristian Ulmann!4 = !{!6}
40628542e99SChristian Ulmann!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, flags: DIFlagArtificial | DIFlagObjectPointer)
40728542e99SChristian Ulmann!6 = !DIDerivedType(tag: DW_TAG_member, name: "call_field", file: !2, baseType: !5)
40828542e99SChristian Ulmann!7 = !DILocalVariable(scope: !8, name: "var", file: !2, type: !5);
40928542e99SChristian Ulmann!8 = distinct !DISubprogram(name: "dbg_use_before_def", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
41028542e99SChristian Ulmann!9 = !DILocation(line: 1, column: 2, scope: !8)
411e133cb9cSChristian Ulmann
412e133cb9cSChristian Ulmann; // -----
413e133cb9cSChristian Ulmann
414c04d08c2SChristian Ulmann; This test checks that broken dominance doesn't break the metadata import.
415c04d08c2SChristian Ulmann
416c04d08c2SChristian Ulmann; CHECK-LABEL: @dbg_broken_dominance
417c04d08c2SChristian Ulmanndefine void @dbg_broken_dominance(ptr %arg, i1 %cond) {
418c04d08c2SChristian Ulmann  br i1 %cond, label %b1, label %b2
419c04d08c2SChristian Ulmannb1:
420c04d08c2SChristian Ulmann  br label %b3
421c04d08c2SChristian Ulmannb2:
422c04d08c2SChristian Ulmann  %dbg_arg = getelementptr double, ptr %arg, i64 16
423c04d08c2SChristian Ulmann  ; CHECK: llvm.getelementptr
424c04d08c2SChristian Ulmann  ; CHECK-NEXT: llvm.intr.dbg.value
425c04d08c2SChristian Ulmann  br label %b3
426c04d08c2SChristian Ulmannb3:
427c04d08c2SChristian Ulmann  call void @llvm.dbg.value(metadata ptr %dbg_arg, metadata !7, metadata !DIExpression()), !dbg !9
428c04d08c2SChristian Ulmann  ret void
429c04d08c2SChristian Ulmann}
430c04d08c2SChristian Ulmann
431c04d08c2SChristian Ulmanndeclare void @llvm.dbg.value(metadata, metadata, metadata)
432c04d08c2SChristian Ulmann
433c04d08c2SChristian Ulmann!llvm.dbg.cu = !{!1}
434c04d08c2SChristian Ulmann!llvm.module.flags = !{!0}
435c04d08c2SChristian Ulmann!0 = !{i32 2, !"Debug Info Version", i32 3}
436c04d08c2SChristian Ulmann!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
437c04d08c2SChristian Ulmann!2 = !DIFile(filename: "debug-info.ll", directory: "/")
438c04d08c2SChristian Ulmann!3 = !DICompositeType(tag: DW_TAG_class_type, name: "class_field", file: !2, line: 42, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !4)
439c04d08c2SChristian Ulmann!4 = !{!6}
440c04d08c2SChristian Ulmann!5 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, flags: DIFlagArtificial | DIFlagObjectPointer)
441c04d08c2SChristian Ulmann!6 = !DIDerivedType(tag: DW_TAG_member, name: "call_field", file: !2, baseType: !5)
442c04d08c2SChristian Ulmann!7 = !DILocalVariable(scope: !8, name: "var", file: !2, type: !5);
443c04d08c2SChristian Ulmann!8 = distinct !DISubprogram(name: "dbg_use_before_def", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
444c04d08c2SChristian Ulmann!9 = !DILocation(line: 1, column: 2, scope: !8)
445c04d08c2SChristian Ulmann
446c04d08c2SChristian Ulmann; // -----
447c04d08c2SChristian Ulmann
448b808648aSChristian Ulmanndeclare i64 @callee()
449b808648aSChristian Ulmanndeclare i32 @personality(...)
450b808648aSChristian Ulmann
451b808648aSChristian Ulmann; CHECK-LABEL: @dbg_broken_dominance_invoke
452b808648aSChristian Ulmanndefine void @dbg_broken_dominance_invoke() personality ptr @personality {
453b808648aSChristian Ulmann  %1 = invoke i64 @callee()
454b808648aSChristian Ulmann          to label %b1 unwind label %b2
455b808648aSChristian Ulmannb1:
456b808648aSChristian Ulmann; CHECK: llvm.intr.dbg.value
457b808648aSChristian Ulmann  call void @llvm.dbg.value(metadata i64 %1, metadata !7, metadata !DIExpression()), !dbg !9
458b808648aSChristian Ulmann  ret void
459b808648aSChristian Ulmannb2:
460b808648aSChristian Ulmann  %2 = landingpad { ptr, i32 }
461b808648aSChristian Ulmann          cleanup
462b808648aSChristian Ulmann  ret void
463b808648aSChristian Ulmann}
464b808648aSChristian Ulmann
465b808648aSChristian Ulmanndeclare void @llvm.dbg.value(metadata, metadata, metadata)
466b808648aSChristian Ulmann
467b808648aSChristian Ulmann!llvm.dbg.cu = !{!1}
468b808648aSChristian Ulmann!llvm.module.flags = !{!0}
469b808648aSChristian Ulmann!0 = !{i32 2, !"Debug Info Version", i32 3}
470b808648aSChristian Ulmann!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
471b808648aSChristian Ulmann!2 = !DIFile(filename: "debug-info.ll", directory: "/")
472b808648aSChristian Ulmann!7 = !DILocalVariable(scope: !8, name: "var", file: !2);
473b808648aSChristian Ulmann!8 = distinct !DISubprogram(name: "dbg_broken_dominance_invoke", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
474b808648aSChristian Ulmann!9 = !DILocation(line: 1, column: 2, scope: !8)
475b808648aSChristian Ulmann
476b808648aSChristian Ulmann; // -----
477b808648aSChristian Ulmann
478b808648aSChristian Ulmanndeclare i64 @callee()
479b808648aSChristian Ulmanndeclare i32 @personality(...)
480b808648aSChristian Ulmann
481b808648aSChristian Ulmann; CHECK-LABEL: @dbg_broken_dominance_invoke_reordered
482b808648aSChristian Ulmanndefine void @dbg_broken_dominance_invoke_reordered() personality ptr @personality {
483b808648aSChristian Ulmann  %1 = invoke i64 @callee()
484b808648aSChristian Ulmann          to label %b2 unwind label %b1
485b808648aSChristian Ulmannb1:
486b808648aSChristian Ulmann; CHECK: landingpad
487b808648aSChristian Ulmann; CHECK: llvm.intr.dbg.value
488b808648aSChristian Ulmann  %2 = landingpad { ptr, i32 }
489b808648aSChristian Ulmann          cleanup
490b808648aSChristian Ulmann  call void @llvm.dbg.value(metadata i64 %1, metadata !7, metadata !DIExpression()), !dbg !9
491b808648aSChristian Ulmann  ret void
492b808648aSChristian Ulmannb2:
493b808648aSChristian Ulmann  ret void
494b808648aSChristian Ulmann}
495b808648aSChristian Ulmann
496b808648aSChristian Ulmanndeclare void @llvm.dbg.value(metadata, metadata, metadata)
497b808648aSChristian Ulmann
498b808648aSChristian Ulmann!llvm.dbg.cu = !{!1}
499b808648aSChristian Ulmann!llvm.module.flags = !{!0}
500b808648aSChristian Ulmann!0 = !{i32 2, !"Debug Info Version", i32 3}
501b808648aSChristian Ulmann!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
502b808648aSChristian Ulmann!2 = !DIFile(filename: "debug-info.ll", directory: "/")
503b808648aSChristian Ulmann!7 = !DILocalVariable(scope: !8, name: "var", file: !2);
504b808648aSChristian Ulmann!8 = distinct !DISubprogram(name: "dbg_broken_dominance_invoke", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
505b808648aSChristian Ulmann!9 = !DILocation(line: 1, column: 2, scope: !8)
506b808648aSChristian Ulmann
507b808648aSChristian Ulmann; // -----
508b808648aSChristian Ulmann
509e133cb9cSChristian Ulmann; CHECK-DAG: #[[NAMESPACE:.+]] = #llvm.di_namespace<name = "std", exportSymbols = false>
510bae1fdeaSChristian Ulmann; CHECK-DAG: #[[SUBPROGRAM:.+]] =  #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #{{.*}}, scope = #[[NAMESPACE]], name = "namespace"
511e133cb9cSChristian Ulmann
512e133cb9cSChristian Ulmanndefine void @namespace(ptr %arg) {
513e133cb9cSChristian Ulmann  call void @llvm.dbg.value(metadata ptr %arg, metadata !7, metadata !DIExpression()), !dbg !9
514e133cb9cSChristian Ulmann  ret void
515e133cb9cSChristian Ulmann}
516e133cb9cSChristian Ulmann
517e133cb9cSChristian Ulmanndeclare void @llvm.dbg.value(metadata, metadata, metadata)
518e133cb9cSChristian Ulmann
519e133cb9cSChristian Ulmann!llvm.dbg.cu = !{!1}
520e133cb9cSChristian Ulmann!llvm.module.flags = !{!0}
521e133cb9cSChristian Ulmann!0 = !{i32 2, !"Debug Info Version", i32 3}
522e133cb9cSChristian Ulmann!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
523e133cb9cSChristian Ulmann!2 = !DIFile(filename: "debug-info.ll", directory: "/")
524e133cb9cSChristian Ulmann!7 = !DILocalVariable(scope: !8, name: "var")
525e133cb9cSChristian Ulmann!8 = distinct !DISubprogram(name: "namespace", scope: !10, file: !2, unit: !1);
526e133cb9cSChristian Ulmann!9 = !DILocation(line: 1, column: 2, scope: !8)
527e133cb9cSChristian Ulmann!10 = !DINamespace(name: "std", scope: null)
528d9391a37SChristian Ulmann
529d9391a37SChristian Ulmann; // -----
530d9391a37SChristian Ulmann
531bae1fdeaSChristian Ulmann; CHECK-DAG: #[[SUBPROGRAM:.+]] =  #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #{{.*}}, scope = #{{.*}}, name = "noname_variable"
532d9391a37SChristian Ulmann; CHECK-DAG: #[[LOCAL_VARIABLE:.+]] =  #llvm.di_local_variable<scope = #[[SUBPROGRAM]]>
533d9391a37SChristian Ulmann
534d9391a37SChristian Ulmanndefine void @noname_variable(ptr %arg) {
535d9391a37SChristian Ulmann  call void @llvm.dbg.value(metadata ptr %arg, metadata !7, metadata !DIExpression()), !dbg !9
536d9391a37SChristian Ulmann  ret void
537d9391a37SChristian Ulmann}
538d9391a37SChristian Ulmann
539d9391a37SChristian Ulmanndeclare void @llvm.dbg.value(metadata, metadata, metadata)
540d9391a37SChristian Ulmann
541d9391a37SChristian Ulmann!llvm.dbg.cu = !{!1}
542d9391a37SChristian Ulmann!llvm.module.flags = !{!0}
543d9391a37SChristian Ulmann!0 = !{i32 2, !"Debug Info Version", i32 3}
544d9391a37SChristian Ulmann!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
545d9391a37SChristian Ulmann!2 = !DIFile(filename: "debug-info.ll", directory: "/")
546d9391a37SChristian Ulmann!7 = !DILocalVariable(scope: !8)
547d9391a37SChristian Ulmann!8 = distinct !DISubprogram(name: "noname_variable", scope: !2, file: !2, unit: !1);
548d9391a37SChristian Ulmann!9 = !DILocation(line: 1, column: 2, scope: !8)
54922b49fccSChristian Ulmann
55022b49fccSChristian Ulmann; // -----
55122b49fccSChristian Ulmann
552bae1fdeaSChristian Ulmann; CHECK: #[[SUBPROGRAM:.*]] = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #{{.*}}, scope = #{{.*}}, file = #{{.*}}, subprogramFlags = Definition>
55322b49fccSChristian Ulmann; CHECK: #[[FUNC_LOC:.*]] = loc(fused<#[[SUBPROGRAM]]>[{{.*}}])
55422b49fccSChristian Ulmanndefine void @noname_subprogram(ptr %arg) !dbg !8 {
55522b49fccSChristian Ulmann  ret void
55622b49fccSChristian Ulmann}
55722b49fccSChristian Ulmann
55822b49fccSChristian Ulmann!llvm.dbg.cu = !{!1}
55922b49fccSChristian Ulmann!llvm.module.flags = !{!0}
56022b49fccSChristian Ulmann!0 = !{i32 2, !"Debug Info Version", i32 3}
56122b49fccSChristian Ulmann!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
56222b49fccSChristian Ulmann!2 = !DIFile(filename: "debug-info.ll", directory: "/")
56322b49fccSChristian Ulmann!8 = distinct !DISubprogram(scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1);
5647e9d7db4SChristian Ulmann
5657e9d7db4SChristian Ulmann; // -----
5667e9d7db4SChristian Ulmann
5677e9d7db4SChristian Ulmann; CHECK:      #[[MODULE:.+]] = #llvm.di_module<
5687e9d7db4SChristian Ulmann; CHECK-SAME: file = #{{.*}}, scope = #{{.*}}, name = "module",
5697e9d7db4SChristian Ulmann; CHECK-SAME: configMacros = "bar", includePath = "/",
5707e9d7db4SChristian Ulmann; CHECK-SAME: apinotes = "/", line = 42, isDecl = true
5717e9d7db4SChristian Ulmann; CHECK-SAME: >
572bae1fdeaSChristian Ulmann; CHECK: #[[SUBPROGRAM:.+]] = #llvm.di_subprogram<id = distinct[{{.*}}]<>, compileUnit = #{{.*}}, scope = #[[MODULE]], name = "func_in_module"
5737e9d7db4SChristian Ulmann
5747e9d7db4SChristian Ulmanndefine void @func_in_module(ptr %arg) !dbg !8 {
5757e9d7db4SChristian Ulmann  ret void
5767e9d7db4SChristian Ulmann}
5777e9d7db4SChristian Ulmann
5787e9d7db4SChristian Ulmann!llvm.dbg.cu = !{!1}
5797e9d7db4SChristian Ulmann!llvm.module.flags = !{!0}
5807e9d7db4SChristian Ulmann!0 = !{i32 2, !"Debug Info Version", i32 3}
5817e9d7db4SChristian Ulmann!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
5827e9d7db4SChristian Ulmann!2 = !DIFile(filename: "debug-info.ll", directory: "/")
5837e9d7db4SChristian Ulmann!8 = distinct !DISubprogram(name: "func_in_module", scope: !10, file: !2, unit: !1);
5847e9d7db4SChristian Ulmann!10 = !DIModule(scope: !2, name: "module", configMacros: "bar", includePath: "/", apinotes: "/", file: !2, line: 42, isDecl: true)
5854ce93d53SChristian Ulmann
5864ce93d53SChristian Ulmann; // -----
5874ce93d53SChristian Ulmann
588b3037ae1SChristian Ulmann; Verifies that import compile units respect the distinctness of the input.
589b3037ae1SChristian Ulmann; CHECK-LABEL: @distinct_cu_func0
590b3037ae1SChristian Ulmanndefine void @distinct_cu_func0() !dbg !4 {
591b3037ae1SChristian Ulmann  ret void
592b3037ae1SChristian Ulmann}
593b3037ae1SChristian Ulmann
594b3037ae1SChristian Ulmanndefine void @distinct_cu_func1() !dbg !5 {
595b3037ae1SChristian Ulmann  ret void
596b3037ae1SChristian Ulmann}
597b3037ae1SChristian Ulmann
598b3037ae1SChristian Ulmann!llvm.dbg.cu = !{!0, !1}
599b3037ae1SChristian Ulmann!llvm.module.flags = !{!3}
600b3037ae1SChristian Ulmann
601b3037ae1SChristian Ulmann; CHECK-COUNT-2: #llvm.di_compile_unit<id = distinct[{{[0-9]+}}]<>
602b3037ae1SChristian Ulmann
603b3037ae1SChristian Ulmann!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !2, producer: "clang")
604b3037ae1SChristian Ulmann!1 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !2, producer: "clang")
605b3037ae1SChristian Ulmann!2 = !DIFile(filename: "other.cpp", directory: "/")
606b3037ae1SChristian Ulmann!3 = !{i32 2, !"Debug Info Version", i32 3}
607b3037ae1SChristian Ulmann!4 = distinct !DISubprogram(name: "func", linkageName: "func", scope: !6, file: !6, line: 1, scopeLine: 1, flags: DIFlagArtificial, spFlags: DISPFlagDefinition, unit: !0)
608b3037ae1SChristian Ulmann!5 = distinct !DISubprogram(name: "func", linkageName: "func", scope: !6, file: !6, line: 1, scopeLine: 1, flags: DIFlagArtificial, spFlags: DISPFlagDefinition, unit: !1)
609b3037ae1SChristian Ulmann!6 = !DIFile(filename: "file.hpp", directory: "/")
610bae1fdeaSChristian Ulmann
611bae1fdeaSChristian Ulmann; // -----
612bae1fdeaSChristian Ulmann
613bae1fdeaSChristian Ulmann; CHECK-LABEL: @declaration
614bae1fdeaSChristian Ulmanndeclare !dbg !1 void @declaration()
615bae1fdeaSChristian Ulmann
61675197553STobias Gysi; CHECK: #[[SP:.+]] = #llvm.di_subprogram<
617bae1fdeaSChristian Ulmann; CHECK-NOT: id = distinct
618aeeb7d56STobias Gysi; CHECK-NOT: subprogramFlags =
61975197553STobias Gysi; CHECK: loc(fused<#[[SP]]>
620bae1fdeaSChristian Ulmann
621bae1fdeaSChristian Ulmann!llvm.module.flags = !{!0}
622bae1fdeaSChristian Ulmann!0 = !{i32 2, !"Debug Info Version", i32 3}
623aeeb7d56STobias Gysi!1 = !DISubprogram(name: "declaration", scope: !2, file: !2, flags: DIFlagPrototyped, spFlags: 0)
624bae1fdeaSChristian Ulmann!2 = !DIFile(filename: "debug-info.ll", directory: "/")
62581a7b645SBilly Zhu
62681a7b645SBilly Zhu; // -----
62781a7b645SBilly Zhu
62881a7b645SBilly Zhu; Ensure that repeated occurence of recursive subtree does not result in
62981a7b645SBilly Zhu; duplicate MLIR entries.
63081a7b645SBilly Zhu;
63181a7b645SBilly Zhu; +--> B:B1 ----+
63281a7b645SBilly Zhu; |     ^       v
63381a7b645SBilly Zhu; A <---+------ B
63481a7b645SBilly Zhu; |     v       ^
63581a7b645SBilly Zhu; +--> B:B2 ----+
63681a7b645SBilly Zhu; This should result in only one B instance.
63781a7b645SBilly Zhu
63881a7b645SBilly Zhu; CHECK-DAG: #[[B1_INNER:.+]] = #llvm.di_derived_type<{{.*}}name = "B:B1", baseType = #[[B_SELF:.+]]>
63981a7b645SBilly Zhu; CHECK-DAG: #[[B2_INNER:.+]] = #llvm.di_derived_type<{{.*}}name = "B:B2", baseType = #[[B_SELF]]>
64075197553STobias Gysi; CHECK-DAG: #[[B_INNER:.+]] = #llvm.di_composite_type<recId = [[B_RECID:.+]], tag = DW_TAG_class_type, name = "B", {{.*}}elements = #[[B1_INNER]], #[[B2_INNER]]
64181a7b645SBilly Zhu
64281a7b645SBilly Zhu; CHECK-DAG: #[[B1_OUTER:.+]] = #llvm.di_derived_type<{{.*}}name = "B:B1", baseType = #[[B_INNER]]>
64381a7b645SBilly Zhu; CHECK-DAG: #[[B2_OUTER:.+]] = #llvm.di_derived_type<{{.*}}name = "B:B2", baseType = #[[B_INNER]]>
64475197553STobias Gysi; CHECK-DAG: #[[A_OUTER:.+]] = #llvm.di_composite_type<recId = [[A_RECID:.+]], tag = DW_TAG_class_type, name = "A", {{.*}}elements = #[[B1_OUTER]], #[[B2_OUTER]]
64581a7b645SBilly Zhu
64675197553STobias Gysi; CHECK-DAG: #[[A_SELF:.+]] = #llvm.di_composite_type<recId = [[A_RECID]]
64775197553STobias Gysi; CHECK-DAG: #[[B_SELF:.+]] = #llvm.di_composite_type<recId = [[B_RECID]]
64881a7b645SBilly Zhu
64981a7b645SBilly Zhu; CHECK: #llvm.di_subprogram<{{.*}}scope = #[[A_OUTER]]
65081a7b645SBilly Zhu
65181a7b645SBilly Zhudefine void @class_field(ptr %arg1) !dbg !18 {
65281a7b645SBilly Zhu  ret void
65381a7b645SBilly Zhu}
65481a7b645SBilly Zhu
65581a7b645SBilly Zhu!llvm.dbg.cu = !{!1}
65681a7b645SBilly Zhu!llvm.module.flags = !{!0}
65781a7b645SBilly Zhu!0 = !{i32 2, !"Debug Info Version", i32 3}
65881a7b645SBilly Zhu!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
65981a7b645SBilly Zhu!2 = !DIFile(filename: "debug-info.ll", directory: "/")
66081a7b645SBilly Zhu
66181a7b645SBilly Zhu!3 = !DICompositeType(tag: DW_TAG_class_type, name: "A", file: !2, line: 42, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !4)
66281a7b645SBilly Zhu!4 = !{!7, !8}
66381a7b645SBilly Zhu
66481a7b645SBilly Zhu!5 = !DICompositeType(tag: DW_TAG_class_type, name: "B", scope: !3, file: !2, line: 42, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !9)
66581a7b645SBilly Zhu!7 = !DIDerivedType(tag: DW_TAG_member, name: "B:B1", file: !2, baseType: !5)
66681a7b645SBilly Zhu!8 = !DIDerivedType(tag: DW_TAG_member, name: "B:B2", file: !2, baseType: !5)
66781a7b645SBilly Zhu!9 = !{!7, !8}
66881a7b645SBilly Zhu
66981a7b645SBilly Zhu!18 = distinct !DISubprogram(name: "A", scope: !3, file: !2, spFlags: DISPFlagDefinition, unit: !1)
67081a7b645SBilly Zhu
67181a7b645SBilly Zhu; // -----
67281a7b645SBilly Zhu
67381a7b645SBilly Zhu; Ensure that recursive cycles with multiple entry points are cached correctly.
67481a7b645SBilly Zhu;
67581a7b645SBilly Zhu; +---- A ----+
67681a7b645SBilly Zhu; v           v
67781a7b645SBilly Zhu; B <-------> C
67881a7b645SBilly Zhu; This should result in a cached instance of B --> C --> B_SELF to be reused
67981a7b645SBilly Zhu; when visiting B from C (after visiting B from A).
68081a7b645SBilly Zhu
68181a7b645SBilly Zhu; CHECK-DAG: #[[A:.+]] = #llvm.di_composite_type<{{.*}}name = "A", {{.*}}elements = #[[TO_B_OUTER:.+]], #[[TO_C_OUTER:.+]]>
68281a7b645SBilly Zhu; CHECK-DAG: #llvm.di_subprogram<{{.*}}scope = #[[A]],
68381a7b645SBilly Zhu
68481a7b645SBilly Zhu; CHECK-DAG: #[[TO_B_OUTER]] = #llvm.di_derived_type<{{.*}}name = "->B", {{.*}}baseType = #[[B_OUTER:.+]]>
68575197553STobias Gysi; CHECK-DAG: #[[B_OUTER]] = #llvm.di_composite_type<recId = [[B_RECID:.+]], tag = DW_TAG_class_type, name = "B", {{.*}}elements = #[[TO_C_INNER:.+]]>
68681a7b645SBilly Zhu; CHECK-DAG: #[[TO_C_INNER]] = #llvm.di_derived_type<{{.*}}name = "->C", {{.*}}baseType = #[[C_INNER:.+]]>
68781a7b645SBilly Zhu; CHECK-DAG: #[[C_INNER]] = #llvm.di_composite_type<{{.*}}name = "C", {{.*}}elements = #[[TO_B_SELF:.+]]>
68881a7b645SBilly Zhu; CHECK-DAG: #[[TO_B_SELF]] = #llvm.di_derived_type<{{.*}}name = "->B", {{.*}}baseType = #[[B_SELF:.+]]>
68975197553STobias Gysi; CHECK-DAG: #[[B_SELF]] = #llvm.di_composite_type<recId = [[B_RECID]], isRecSelf = true>
69081a7b645SBilly Zhu
69181a7b645SBilly Zhu; CHECK-DAG: #[[TO_C_OUTER]] = #llvm.di_derived_type<{{.*}}name = "->C", {{.*}}baseType = #[[C_OUTER:.+]]>
69281a7b645SBilly Zhu; CHECK-DAG: #[[C_OUTER]] = #llvm.di_composite_type<{{.*}}name = "C", {{.*}}elements = #[[TO_B_OUTER]]>
69381a7b645SBilly Zhu
69481a7b645SBilly Zhudefine void @class_field(ptr %arg1) !dbg !18 {
69581a7b645SBilly Zhu  ret void
69681a7b645SBilly Zhu}
69781a7b645SBilly Zhu
69881a7b645SBilly Zhu!llvm.dbg.cu = !{!1}
69981a7b645SBilly Zhu!llvm.module.flags = !{!0}
70081a7b645SBilly Zhu!0 = !{i32 2, !"Debug Info Version", i32 3}
70181a7b645SBilly Zhu!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
70281a7b645SBilly Zhu!2 = !DIFile(filename: "debug-info.ll", directory: "/")
70381a7b645SBilly Zhu
70481a7b645SBilly Zhu!3 = !DICompositeType(tag: DW_TAG_class_type, name: "A", file: !2, line: 42, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !4)
70581a7b645SBilly Zhu!5 = !DICompositeType(tag: DW_TAG_class_type, name: "B", file: !2, line: 42, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !10)
70681a7b645SBilly Zhu!6 = !DICompositeType(tag: DW_TAG_class_type, name: "C", file: !2, line: 42, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !9)
70781a7b645SBilly Zhu
70881a7b645SBilly Zhu!7 = !DIDerivedType(tag: DW_TAG_member, name: "->B", file: !2, baseType: !5)
70981a7b645SBilly Zhu!8 = !DIDerivedType(tag: DW_TAG_member, name: "->C", file: !2, baseType: !6)
71081a7b645SBilly Zhu!4 = !{!7, !8}
71181a7b645SBilly Zhu!9 = !{!7}
71281a7b645SBilly Zhu!10 = !{!8}
71381a7b645SBilly Zhu
71481a7b645SBilly Zhu!18 = distinct !DISubprogram(name: "SP", scope: !3, file: !2, spFlags: DISPFlagDefinition, unit: !1)
71581a7b645SBilly Zhu
71681a7b645SBilly Zhu; // -----
71781a7b645SBilly Zhu
71881a7b645SBilly Zhu; Ensures that replacing a nested mutually recursive decl does not result in
71981a7b645SBilly Zhu; nested duplicate recursive decls.
72081a7b645SBilly Zhu;
72181a7b645SBilly Zhu; A ---> B <--> C
72281a7b645SBilly Zhu; ^             ^
72381a7b645SBilly Zhu; +-------------+
72481a7b645SBilly Zhu
72575197553STobias Gysi; CHECK-DAG: #[[A:.+]] = #llvm.di_composite_type<recId = [[A_RECID:.+]], tag = DW_TAG_class_type, name = "A", {{.*}}elements = #[[A_TO_B:.+]], #[[A_TO_C:.+]]>
72681a7b645SBilly Zhu; CHECK-DAG: #llvm.di_subprogram<{{.*}}scope = #[[A]],
72781a7b645SBilly Zhu; CHECK-DAG: #[[A_TO_B]] = #llvm.di_derived_type<{{.*}}name = "->B", {{.*}}baseType = #[[B_FROM_A:.+]]>
72881a7b645SBilly Zhu; CHECK-DAG: #[[A_TO_C]] = #llvm.di_derived_type<{{.*}}name = "->C", {{.*}}baseType = #[[C_FROM_A:.+]]>
72981a7b645SBilly Zhu
73075197553STobias Gysi; CHECK-DAG: #[[B_FROM_A]] = #llvm.di_composite_type<recId = [[B_RECID:.+]], tag = DW_TAG_class_type, name = "B", {{.*}}elements = #[[B_TO_C:.+]]>
73181a7b645SBilly Zhu; CHECK-DAG: #[[B_TO_C]] = #llvm.di_derived_type<{{.*}}name = "->C", {{.*}}baseType = #[[C_FROM_B:.+]]>
73275197553STobias Gysi; CHECK-DAG: #[[C_FROM_B]] = #llvm.di_composite_type<recId = [[C_RECID:.+]], tag = DW_TAG_class_type, name = "C", {{.*}}elements = #[[TO_A_SELF:.+]], #[[TO_B_SELF:.+]], #[[TO_C_SELF:.+]]>
73381a7b645SBilly Zhu
73475197553STobias Gysi; CHECK-DAG: #[[C_FROM_A]] = #llvm.di_composite_type<recId = [[C_RECID]], tag = DW_TAG_class_type, name = "C", {{.*}}elements = #[[TO_A_SELF]], #[[A_TO_B:.+]], #[[TO_C_SELF]]
73581a7b645SBilly Zhu
73681a7b645SBilly Zhu; CHECK-DAG: #[[TO_A_SELF]] = #llvm.di_derived_type<{{.*}}name = "->A", {{.*}}baseType = #[[A_SELF:.+]]>
73781a7b645SBilly Zhu; CHECK-DAG: #[[TO_B_SELF]] = #llvm.di_derived_type<{{.*}}name = "->B", {{.*}}baseType = #[[B_SELF:.+]]>
73881a7b645SBilly Zhu; CHECK-DAG: #[[TO_C_SELF]] = #llvm.di_derived_type<{{.*}}name = "->C", {{.*}}baseType = #[[C_SELF:.+]]>
73975197553STobias Gysi; CHECK-DAG: #[[A_SELF]] = #llvm.di_composite_type<recId = [[A_RECID]], isRecSelf = true>
74075197553STobias Gysi; CHECK-DAG: #[[B_SELF]] = #llvm.di_composite_type<recId = [[B_RECID]], isRecSelf = true>
74175197553STobias Gysi; CHECK-DAG: #[[C_SELF]] = #llvm.di_composite_type<recId = [[C_RECID]], isRecSelf = true>
74281a7b645SBilly Zhu
74381a7b645SBilly Zhudefine void @class_field(ptr %arg1) !dbg !18 {
74481a7b645SBilly Zhu  ret void
74581a7b645SBilly Zhu}
74681a7b645SBilly Zhu
74781a7b645SBilly Zhu!llvm.dbg.cu = !{!1}
74881a7b645SBilly Zhu!llvm.module.flags = !{!0}
74981a7b645SBilly Zhu!0 = !{i32 2, !"Debug Info Version", i32 3}
75081a7b645SBilly Zhu!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
75181a7b645SBilly Zhu!2 = !DIFile(filename: "debug-info.ll", directory: "/")
75281a7b645SBilly Zhu
75381a7b645SBilly Zhu!3 = !DICompositeType(tag: DW_TAG_class_type, name: "A", file: !2, line: 42, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !9)
75481a7b645SBilly Zhu!4 = !DICompositeType(tag: DW_TAG_class_type, name: "B", file: !2, line: 42, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !10)
75581a7b645SBilly Zhu!5 = !DICompositeType(tag: DW_TAG_class_type, name: "C", file: !2, line: 42, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !11)
75681a7b645SBilly Zhu
75781a7b645SBilly Zhu!6 = !DIDerivedType(tag: DW_TAG_member, name: "->A", file: !2, baseType: !3)
75881a7b645SBilly Zhu!7 = !DIDerivedType(tag: DW_TAG_member, name: "->B", file: !2, baseType: !4)
75981a7b645SBilly Zhu!8 = !DIDerivedType(tag: DW_TAG_member, name: "->C", file: !2, baseType: !5)
76081a7b645SBilly Zhu
76181a7b645SBilly Zhu!9 = !{!7, !8} ; A -> B, C
76281a7b645SBilly Zhu!10 = !{!8} ; B -> C
76381a7b645SBilly Zhu!11 = !{!6, !7, !8} ; C -> A, B, C
76481a7b645SBilly Zhu
76581a7b645SBilly Zhu!18 = distinct !DISubprogram(name: "SP", scope: !3, file: !2, spFlags: DISPFlagDefinition, unit: !1)
7664f320e6aSAbid Qadeer
7674f320e6aSAbid Qadeer; // -----
7684f320e6aSAbid Qadeer
7694f320e6aSAbid Qadeer; Verify the string type is handled correctly
7704f320e6aSAbid Qadeer
7714f320e6aSAbid Qadeerdefine void @string_type(ptr %arg1) {
7724f320e6aSAbid Qadeer  call void @llvm.dbg.value(metadata ptr %arg1, metadata !4, metadata !DIExpression()), !dbg !10
7734f320e6aSAbid Qadeer  call void @llvm.dbg.value(metadata ptr %arg1, metadata !9, metadata !DIExpression()), !dbg !10
7744f320e6aSAbid Qadeer  ret void
7754f320e6aSAbid Qadeer}
7764f320e6aSAbid Qadeer
7774f320e6aSAbid Qadeer!llvm.dbg.cu = !{!1}
7784f320e6aSAbid Qadeer!llvm.module.flags = !{!0}
7794f320e6aSAbid Qadeer!0 = !{i32 2, !"Debug Info Version", i32 3}
7804f320e6aSAbid Qadeer!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2)
7814f320e6aSAbid Qadeer!2 = !DIFile(filename: "debug-info.ll", directory: "/")
7824f320e6aSAbid Qadeer!3 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
7834f320e6aSAbid Qadeer!4 = !DILocalVariable(scope: !5, name: "string_size", file: !2, type: !3);
7844f320e6aSAbid Qadeer!5 = distinct !DISubprogram(name: "test", scope: !2, file: !2, spFlags: DISPFlagDefinition, unit: !1)
7854f320e6aSAbid Qadeer!6 = !DIStringType(name: "character(*)", stringLength: !4, size: 32, align: 8, stringLengthExpression: !8, stringLocationExpression: !7)
7864f320e6aSAbid Qadeer!7 = !DIExpression(DW_OP_push_object_address, DW_OP_deref)
7874f320e6aSAbid Qadeer!8 = !DIExpression(DW_OP_push_object_address, DW_OP_plus_uconst, 8)
788ef8de68fSWalter Erquinigo!9 = !DILocalVariable(scope: !5, name: "str", file: !2, type: !6, flags: 64);
7894f320e6aSAbid Qadeer!10 = !DILocation(line: 1, column: 2, scope: !5)
7904f320e6aSAbid Qadeer
7914f320e6aSAbid Qadeer; CHECK: #[[VAR:.+]] = #llvm.di_local_variable<{{.*}}name = "string_size"{{.*}}>
7924f320e6aSAbid Qadeer; CHECK: #llvm.di_string_type<tag = DW_TAG_string_type, name = "character(*)"
7934f320e6aSAbid Qadeer; CHECK-SAME: sizeInBits = 32
7944f320e6aSAbid Qadeer; CHECK-SAME: alignInBits = 8
7954f320e6aSAbid Qadeer; CHECK-SAME: stringLength = #[[VAR]]
7964f320e6aSAbid Qadeer; CHECK-SAME: stringLengthExp = <[DW_OP_push_object_address, DW_OP_plus_uconst(8)]>
7974f320e6aSAbid Qadeer; CHECK-SAME: stringLocationExp = <[DW_OP_push_object_address, DW_OP_deref]>>
798ef8de68fSWalter Erquinigo; CHECK: #di_local_variable1 = #llvm.di_local_variable<scope = #di_subprogram, name = "str", file = #di_file, type = #di_string_type, flags = Artificial>
799bc4bedd5SAbid Qadeer
800bc4bedd5SAbid Qadeer; // -----
801bc4bedd5SAbid Qadeer
802bc4bedd5SAbid Qadeer; Test that imported entities for a functions are handled correctly.
803bc4bedd5SAbid Qadeer
804bc4bedd5SAbid Qadeerdefine void @imp_fn() !dbg !12 {
805bc4bedd5SAbid Qadeer  ret void
806bc4bedd5SAbid Qadeer}
807bc4bedd5SAbid Qadeer
808bc4bedd5SAbid Qadeer!llvm.module.flags = !{!10}
809bc4bedd5SAbid Qadeer!llvm.dbg.cu = !{!4}
810bc4bedd5SAbid Qadeer
811bc4bedd5SAbid Qadeer!2 = !DIModule(scope: !4, name: "mod1", file: !3, line: 1)
812bc4bedd5SAbid Qadeer!3 = !DIFile(filename: "test.f90", directory: "")
813bc4bedd5SAbid Qadeer!4 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !3)
814bc4bedd5SAbid Qadeer!8 = !DIModule(scope: !4, name: "mod1", file: !3, line: 5)
815bc4bedd5SAbid Qadeer!10 = !{i32 2, !"Debug Info Version", i32 3}
816bc4bedd5SAbid Qadeer!12 = distinct !DISubprogram(name: "imp_fn", linkageName: "imp_fn", scope: !3, file: !3, line: 10, type: !14, scopeLine: 10, spFlags: DISPFlagDefinition, unit: !4, retainedNodes: !16)
817bc4bedd5SAbid Qadeer!14 = !DISubroutineType(cc: DW_CC_program, types: !15)
818bc4bedd5SAbid Qadeer!15 = !{}
819bc4bedd5SAbid Qadeer!16 = !{!17}
820bc4bedd5SAbid Qadeer!17 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !12, entity: !8, file: !3, line: 1, elements: !15)
821bc4bedd5SAbid Qadeer
822bc4bedd5SAbid Qadeer; CHECK-DAG: #[[M:.+]] = #llvm.di_module<{{.*}}name = "mod1"{{.*}}>
82375197553STobias Gysi; CHECK-DAG:  #[[SP_REC:.+]] = #llvm.di_subprogram<recId = distinct{{.*}}<>, isRecSelf = true>
82475197553STobias Gysi; CHECK-DAG: #[[IE:.+]] = #llvm.di_imported_entity<tag = DW_TAG_imported_module, scope = #[[SP_REC]], entity = #[[M]]{{.*}}>
82575197553STobias Gysi; CHECK-DAG: #[[SP:.+]] = #llvm.di_subprogram<{{.*}}name = "imp_fn"{{.*}}retainedNodes = #[[IE]]>
8262918e779SWalter Erquinigo
8272918e779SWalter Erquinigo; // -----
8282918e779SWalter Erquinigo
8292918e779SWalter Erquinigo; Test that annotations are handled correctly
8302918e779SWalter Erquinigo
8312918e779SWalter Erquinigo; CHECK-LABEL: @fn_with_annotations
8322918e779SWalter Erquinigo
8332918e779SWalter Erquinigodefine void @fn_with_annotations() !dbg !12 {
8342918e779SWalter Erquinigo  ret void
8352918e779SWalter Erquinigo}
8362918e779SWalter Erquinigo
8372918e779SWalter Erquinigo!llvm.module.flags = !{!10}
8382918e779SWalter Erquinigo!llvm.dbg.cu = !{!4}
8392918e779SWalter Erquinigo
8402918e779SWalter Erquinigo!2 = !DIModule(scope: !4, name: "mod1", file: !3, line: 1)
8412918e779SWalter Erquinigo!3 = !DIFile(filename: "test.f90", directory: "")
8422918e779SWalter Erquinigo!4 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !3)
8432918e779SWalter Erquinigo!8 = !DIModule(scope: !4, name: "mod1", file: !3, line: 5)
8442918e779SWalter Erquinigo!10 = !{i32 2, !"Debug Info Version", i32 3}
8452918e779SWalter Erquinigo!12 = distinct !DISubprogram(name: "fn_with_annotations", linkageName: "fn_with_annotations", scope: !3, file: !3, line: 10, type: !14, scopeLine: 10, spFlags: DISPFlagDefinition, unit: !4, annotations: !16)
8462918e779SWalter Erquinigo!14 = !DISubroutineType(cc: DW_CC_program, types: !15)
8472918e779SWalter Erquinigo!15 = !{}
8482918e779SWalter Erquinigo!16 = !{!17}
8492918e779SWalter Erquinigo!17 = !{!"foo", !"bar"}
8502918e779SWalter Erquinigo
8512918e779SWalter Erquinigo
8522918e779SWalter Erquinigo; CHECK-DAG: #llvm.di_subprogram<{{.*}}name = "fn_with_annotations"{{.*}}annotations = #llvm.di_annotation<name = "foo", value = "bar">>
85336c34ec9SAbid Qadeer
85436c34ec9SAbid Qadeer; // -----
85536c34ec9SAbid Qadeer
85636c34ec9SAbid Qadeer@block = common global [4 x i8] zeroinitializer, !dbg !0
85736c34ec9SAbid Qadeer
85836c34ec9SAbid Qadeerdefine void @test() !dbg !3 {
85936c34ec9SAbid Qadeer  ret void
86036c34ec9SAbid Qadeer}
86136c34ec9SAbid Qadeer
86236c34ec9SAbid Qadeer!llvm.module.flags = !{!10}
86336c34ec9SAbid Qadeer!llvm.dbg.cu = !{!7}
86436c34ec9SAbid Qadeer
86536c34ec9SAbid Qadeer!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
86636c34ec9SAbid Qadeer!1 = distinct !DIGlobalVariable(name: "alpha", scope: !2, file: !4, type: !9)
86736c34ec9SAbid Qadeer!2 = !DICommonBlock(scope: !3, declaration: null, name: "block", file: !4, line: 3)
86836c34ec9SAbid Qadeer!3 = distinct !DISubprogram(name: "test", scope: !4, file: !4, spFlags: DISPFlagDefinition, unit: !7)
86936c34ec9SAbid Qadeer!4 = !DIFile(filename: "test.f90", directory: "")
87036c34ec9SAbid Qadeer!7 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !4)
87136c34ec9SAbid Qadeer!9 = !DIBasicType(name: "integer", size: 32, encoding: DW_ATE_signed)
87236c34ec9SAbid Qadeer!10 = !{i32 2, !"Debug Info Version", i32 3}
87336c34ec9SAbid Qadeer
87436c34ec9SAbid Qadeer; CHECK: #[[FILE:.+]] = #llvm.di_file<"test.f90" in "">
87536c34ec9SAbid Qadeer; CHECK: #[[SP:.+]] = #llvm.di_subprogram<{{.*}}name = "test"{{.*}}>
87636c34ec9SAbid Qadeer; CHECK: #llvm.di_common_block<scope = #[[SP]], name = "block", file = #[[FILE]], line = 3>
877cd12ffb6SAbid Qadeer
878cd12ffb6SAbid Qadeer; // -----
879cd12ffb6SAbid Qadeer
880cd12ffb6SAbid Qadeer@data = external global i64, !dbg !0, !dbg !5
881cd12ffb6SAbid Qadeer
882cd12ffb6SAbid Qadeer!llvm.module.flags = !{!8}
883cd12ffb6SAbid Qadeer!llvm.dbg.cu = !{!2}
884cd12ffb6SAbid Qadeer
885cd12ffb6SAbid Qadeer!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
886cd12ffb6SAbid Qadeer!1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 2, type: !7)
887cd12ffb6SAbid Qadeer!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, globals: !4)
888cd12ffb6SAbid Qadeer!3 = !DIFile(filename: "test.c", directory: "")
889cd12ffb6SAbid Qadeer!4 = !{!0, !5}
890cd12ffb6SAbid Qadeer!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
891cd12ffb6SAbid Qadeer!6 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 3, type: !7)
892cd12ffb6SAbid Qadeer!7 = !DIBasicType(name: "int", size: 32)
893cd12ffb6SAbid Qadeer!8 = !{i32 2, !"Debug Info Version", i32 3}
894cd12ffb6SAbid Qadeer
895cd12ffb6SAbid Qadeer
896cd12ffb6SAbid Qadeer; CHECK: #[[VAR1:.+]] =  #llvm.di_global_variable<{{.*}}name = "a"{{.*}}>
897cd12ffb6SAbid Qadeer; CHECK: #[[VAR2:.+]] =  #llvm.di_global_variable<{{.*}}name = "b"{{.*}}>
898cd12ffb6SAbid Qadeer; CHECK: #[[EXP1:.+]] =  #llvm.di_global_variable_expression<var = #[[VAR1]], expr = <>>
899cd12ffb6SAbid Qadeer; CHECK: #[[EXP2:.+]] =  #llvm.di_global_variable_expression<var = #[[VAR2]], expr = <>>
900cd12ffb6SAbid Qadeer; CHECK: llvm.mlir.global external @data() {{{.*}}dbg_exprs = [#[[EXP1]], #[[EXP2]]]} : i64
901