Skip to content

Commit f362824

Browse files
committed
Add support for creating a SetType, a Subrangetype, a dynamic array type
and for replacing arrays to the C inteface
1 parent bac7e21 commit f362824

File tree

4 files changed

+127
-91
lines changed

4 files changed

+127
-91
lines changed

llvm/include/llvm-c/DebugInfo.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -703,15 +703,15 @@ LLVMDIBuilderCreateArrayType(LLVMDIBuilderRef Builder, uint64_t Size,
703703

704704
/**
705705
* Create debugging information entry for a set.
706-
* @param Builder The DIBuilder.
707-
* \param Scope The scope this module is imported into.
706+
* \param Builder The DIBuilder.
707+
* \param Scope The scope in which the set is defined.
708708
* \param Name A name that uniquely identifies this set.
709709
* \param NameLen The length of the C string passed to \c Name.
710710
* \param File File where the set is located.
711711
* \param Line Line number of the declaration.
712712
* \param SizeInBits Set size.
713713
* \param AlignInBits Set alignment.
714-
* @param BaseTy The base type of the set.
714+
* \param BaseTy The base type of the set.
715715
*/
716716
LLVMMetadataRef LLVMDIBuilderCreateSetType(
717717
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
@@ -721,8 +721,8 @@ LLVMMetadataRef LLVMDIBuilderCreateSetType(
721721
/**
722722
* Create a descriptor for a subrange with dynamic bounds.
723723
* \param Builder The DIBuilder.
724-
* \param Scope The scope this module is imported into.
725-
* \param Name A name that uniquely identifies this set.
724+
* \param Scope The scope in which the subrange is defined.
725+
* \param Name A name that uniquely identifies this subrange.
726726
* \param NameLen The length of the C string passed to \c Name.
727727
* \param LineNo Line number.
728728
* \param File File where the subrange is located.
@@ -737,9 +737,8 @@ LLVMMetadataRef LLVMDIBuilderCreateSetType(
737737
*/
738738
LLVMMetadataRef LLVMDIBuilderCreateSubrangeType(
739739
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
740-
size_t NameLen, unsigned LineNo, LLVMMetadataRef File,
741-
uint64_t SizeInBits, uint32_t AlignInBits,
742-
LLVMDIFlags Flags, LLVMMetadataRef BaseTy,
740+
size_t NameLen, unsigned LineNo, LLVMMetadataRef File, uint64_t SizeInBits,
741+
uint32_t AlignInBits, LLVMDIFlags Flags, LLVMMetadataRef BaseTy,
743742
LLVMMetadataRef LowerBound, LLVMMetadataRef UpperBound,
744743
LLVMMetadataRef Stride, LLVMMetadataRef Bias);
745744

@@ -759,11 +758,11 @@ LLVMMetadataRef LLVMDIBuilderCreateSubrangeType(
759758
*/
760759
LLVMMetadataRef LLVMDIBuilderCreateDynamicArrayType(
761760
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
762-
size_t NameLen, unsigned LineNo, LLVMMetadataRef File,
763-
uint64_t Size, uint32_t AlignInBits,
764-
LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts,
765-
LLVMMetadataRef DataLocation, LLVMMetadataRef Associated,
766-
LLVMMetadataRef Allocated, LLVMMetadataRef Rank, LLVMMetadataRef BitStride);
761+
size_t NameLen, unsigned LineNo, LLVMMetadataRef File, uint64_t Size,
762+
uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts,
763+
unsigned NumSubscripts, LLVMMetadataRef DataLocation,
764+
LLVMMetadataRef Associated, LLVMMetadataRef Allocated, LLVMMetadataRef Rank,
765+
LLVMMetadataRef BitStride);
767766

768767
/**
769768
* Replace arrays.

llvm/lib/IR/DebugInfo.cpp

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,32 +1332,29 @@ LLVMMetadataRef LLVMDIBuilderCreateSetType(
13321332

13331333
LLVMMetadataRef LLVMDIBuilderCreateSubrangeType(
13341334
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1335-
size_t NameLen, unsigned LineNo, LLVMMetadataRef File,
1336-
uint64_t SizeInBits, uint32_t AlignInBits,
1337-
LLVMDIFlags Flags, LLVMMetadataRef BaseTy,
1335+
size_t NameLen, unsigned LineNo, LLVMMetadataRef File, uint64_t SizeInBits,
1336+
uint32_t AlignInBits, LLVMDIFlags Flags, LLVMMetadataRef BaseTy,
13381337
LLVMMetadataRef LowerBound, LLVMMetadataRef UpperBound,
1339-
LLVMMetadataRef Stride, LLVMMetadataRef Bias
1340-
) {
1338+
LLVMMetadataRef Stride, LLVMMetadataRef Bias) {
13411339
return wrap(unwrap(Builder)->createSubrangeType(
1342-
{Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1343-
unwrapDI<DIScope>(Scope), SizeInBits, AlignInBits,
1344-
map_from_llvmDIFlags(Flags), unwrapDI<DIType>(BaseTy),
1345-
unwrap<DIExpression>(LowerBound), unwrap<DIExpression>(UpperBound),
1346-
unwrap<DIExpression>(Stride), unwrap<DIExpression>(Bias)));
1340+
{Name, NameLen}, unwrapDI<DIFile>(File), LineNo, unwrapDI<DIScope>(Scope),
1341+
SizeInBits, AlignInBits, map_from_llvmDIFlags(Flags),
1342+
unwrapDI<DIType>(BaseTy), unwrap<DIExpression>(LowerBound),
1343+
unwrap<DIExpression>(UpperBound), unwrap<DIExpression>(Stride),
1344+
unwrap<DIExpression>(Bias)));
13471345
}
13481346

13491347
LLVMMetadataRef LLVMDIBuilderCreateDynamicArrayType(
13501348
LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
1351-
size_t NameLen, unsigned LineNo, LLVMMetadataRef File,
1352-
uint64_t Size, uint32_t AlignInBits,
1353-
LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts,
1354-
LLVMMetadataRef DataLocation, LLVMMetadataRef Associated,
1355-
LLVMMetadataRef Allocated, LLVMMetadataRef Rank, LLVMMetadataRef BitStride) {
1349+
size_t NameLen, unsigned LineNo, LLVMMetadataRef File, uint64_t Size,
1350+
uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts,
1351+
unsigned NumSubscripts, LLVMMetadataRef DataLocation,
1352+
LLVMMetadataRef Associated, LLVMMetadataRef Allocated, LLVMMetadataRef Rank,
1353+
LLVMMetadataRef BitStride) {
13561354
auto Subs =
13571355
unwrap(Builder)->getOrCreateArray({unwrap(Subscripts), NumSubscripts});
13581356
return wrap(unwrap(Builder)->createArrayType(
1359-
unwrapDI<DIScope>(Scope),
1360-
{Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
1357+
unwrapDI<DIScope>(Scope), {Name, NameLen}, unwrapDI<DIFile>(File), LineNo,
13611358
Size, AlignInBits, unwrapDI<DIType>(Ty), Subs,
13621359
unwrap<DIExpression>(DataLocation), unwrap<DIExpression>(Associated),
13631360
unwrap<DIExpression>(Allocated), unwrap<DIExpression>(Rank),
@@ -1367,8 +1364,8 @@ LLVMMetadataRef LLVMDIBuilderCreateDynamicArrayType(
13671364
void LLVMReplaceArrays(LLVMDIBuilderRef Builder, LLVMMetadataRef *T,
13681365
LLVMMetadataRef *Elements, unsigned NumElements) {
13691366
auto Arr = unwrap<DICompositeType>(*T);
1370-
auto Elts = unwrap(Builder)->getOrCreateArray({unwrap(Elements),
1371-
NumElements});
1367+
auto Elts =
1368+
unwrap(Builder)->getOrCreateArray({unwrap(Elements), NumElements});
13721369
unwrap(Builder)->replaceArrays(Arr, Elts);
13731370
}
13741371

llvm/test/Bindings/llvm-c/debug_info_new_format.ll

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,36 @@
33

44
; CHECK: ; ModuleID = 'debuginfo.c'
55
; CHECK-NEXT: source_filename = "debuginfo.c"
6-
7-
; CHECK: define i64 @foo(i64 %0, i64 %1, <10 x i64> %2) !dbg !36 {
6+
7+
; CHECK: define i64 @foo(i64 %0, i64 %1, <10 x i64> %2) !dbg !39 {
88
; CHECK-NEXT: entry:
9-
; CHECK-NEXT: #dbg_declare(i64 0, !43, !DIExpression(), !50)
10-
; CHECK-NEXT: #dbg_declare(i64 0, !44, !DIExpression(), !50)
11-
; CHECK-NEXT: #dbg_declare(i64 0, !45, !DIExpression(), !50)
12-
; CHECK-NEXT: #dbg_label(!51, !50)
9+
; CHECK-NEXT: #dbg_declare(i64 0, !44, !DIExpression(), !51)
10+
; CHECK-NEXT: #dbg_declare(i64 0, !45, !DIExpression(), !51)
11+
; CHECK-NEXT: #dbg_declare(i64 0, !46, !DIExpression(), !51)
12+
; CHECK-NEXT: #dbg_label(!52, !51)
1313
; CHECK-NEXT: br label %vars
14-
; CHECK-NEXT: #dbg_label(!52, !50)
14+
; CHECK-NEXT: #dbg_label(!53, !51)
1515
; CHECK-NEXT: br label %vars
16-
; CHECK: vars:
16+
; CHECK: vars: ; preds = %entry, %entry
1717
; CHECK-NEXT: %p1 = phi i64 [ 0, %entry ]
1818
; CHECK-NEXT: %p2 = phi i64 [ 0, %entry ]
19-
; CHECK-NEXT: #dbg_value(i64 0, !46, !DIExpression(DW_OP_constu, 0, DW_OP_stack_value), !53)
20-
; CHECK-NEXT: #dbg_value(i64 1, !48, !DIExpression(DW_OP_constu, 1, DW_OP_stack_value), !53)
19+
; CHECK-NEXT: #dbg_value(i64 0, !47, !DIExpression(DW_OP_constu, 0, DW_OP_stack_value), !54)
20+
; CHECK-NEXT: #dbg_value(i64 1, !49, !DIExpression(DW_OP_constu, 1, DW_OP_stack_value), !54)
2121
; CHECK-NEXT: %a = add i64 %p1, %p2
2222
; CHECK-NEXT: ret i64 0
2323
; CHECK-NEXT: }
24-
24+
2525
; CHECK: !llvm.dbg.cu = !{!0}
26-
; CHECK-NEXT: !FooType = !{!33}
26+
; CHECK-NEXT: !FooType = !{!28}
2727
; CHECK-NEXT: !EnumTest = !{!3}
28-
; CHECK-NEXT: !LargeEnumTest = !{!11}
29-
30-
; CHECK: !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "llvm-c-test", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !16, imports: !24, macros: !28, splitDebugInlining: false, sysroot: "/")
28+
; CHECK-NEXT: !SubrangeType = !{!33}
29+
; CHECK-NEXT: !SetType1 = !{!34}
30+
; CHECK-NEXT: !SetType2 = !{!35}
31+
; CHECK-NEXT: !DynType = !{!36}
32+
33+
; CHECK: !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "llvm-c-test", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !11, imports: !19, macros: !23, splitDebugInlining: false, sysroot: "/")
3134
; CHECK-NEXT: !1 = !DIFile(filename: "debuginfo.c", directory: ".")
32-
; CHECK-NEXT: !2 = !{!3, !11}
35+
; CHECK-NEXT: !2 = !{!3}
3336
; CHECK-NEXT: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "EnumTest", scope: !4, file: !1, baseType: !6, size: 64, elements: !7)
3437
; CHECK-NEXT: !4 = !DINamespace(name: "NameSpace", scope: !5)
3538
; CHECK-NEXT: !5 = !DIModule(scope: null, name: "llvm-c-test", includePath: "/test/include/llvm-c-test.h")
@@ -38,46 +41,47 @@
3841
; CHECK-NEXT: !8 = !DIEnumerator(name: "Test_A", value: 0, isUnsigned: true)
3942
; CHECK-NEXT: !9 = !DIEnumerator(name: "Test_B", value: 1, isUnsigned: true)
4043
; CHECK-NEXT: !10 = !DIEnumerator(name: "Test_B", value: 2, isUnsigned: true)
41-
; CHECK-NEXT: !11 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "LargeEnumTest", scope: !4, file: !1, baseType: !12, size: 128, elements: !13)
42-
; CHECK-NEXT: !12 = !DIBasicType(name: "UInt128", size: 128)
43-
; CHECK-NEXT: !13 = !{!14, !15}
44-
; CHECK-NEXT: !14 = !DIEnumerator(name: "Test_D", value: 100000000000000000000000000000000000000)
45-
; CHECK-NEXT: !15 = !DIEnumerator(name: "Test_E", value: -1)
46-
; CHECK-NEXT: !16 = !{!17, !21}
47-
; CHECK-NEXT: !17 = !DIGlobalVariableExpression(var: !18, expr: !DIExpression(DW_OP_constu, 0, DW_OP_stack_value))
48-
; CHECK-NEXT: !18 = distinct !DIGlobalVariable(name: "globalClass", scope: !5, file: !1, line: 1, type: !19, isLocal: true, isDefinition: true)
49-
; CHECK-NEXT: !19 = !DICompositeType(tag: DW_TAG_structure_type, name: "TestClass", scope: !1, file: !1, line: 42, size: 64, flags: DIFlagObjcClassComplete, elements: !20)
50-
; CHECK-NEXT: !20 = !{}
51-
; CHECK-NEXT: !21 = !DIGlobalVariableExpression(var: !22, expr: !DIExpression(DW_OP_constu, 0, DW_OP_stack_value))
52-
; CHECK-NEXT: !22 = distinct !DIGlobalVariable(name: "global", scope: !5, file: !1, line: 1, type: !23, isLocal: true, isDefinition: true)
53-
; CHECK-NEXT: !23 = !DIDerivedType(tag: DW_TAG_typedef, name: "int64_t", scope: !1, file: !1, line: 42, baseType: !6)
54-
; CHECK-NEXT: !24 = !{!25, !27}
55-
; CHECK-NEXT: !25 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !5, entity: !26, file: !1, line: 42)
56-
; CHECK-NEXT: !26 = !DIModule(scope: null, name: "llvm-c-test-import", includePath: "/test/include/llvm-c-test-import.h")
57-
; CHECK-NEXT: !27 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !5, entity: !25, file: !1, line: 42)
58-
; CHECK-NEXT: !28 = !{!29}
59-
; CHECK-NEXT: !29 = !DIMacroFile(file: !1, nodes: !30)
60-
; CHECK-NEXT: !30 = !{!31, !32}
61-
; CHECK-NEXT: !31 = !DIMacro(type: DW_MACINFO_define, name: "SIMPLE_DEFINE")
62-
; CHECK-NEXT: !32 = !DIMacro(type: DW_MACINFO_define, name: "VALUE_DEFINE", value: "1")
63-
; CHECK-NEXT: !33 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !34, size: 192, dwarfAddressSpace: 0)
64-
; CHECK-NEXT: !34 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyStruct", scope: !4, file: !1, size: 192, elements: !35, runtimeLang: DW_LANG_C89, identifier: "MyStruct")
65-
; CHECK-NEXT: !35 = !{!6, !6, !6}
66-
; CHECK-NEXT: !36 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 42, type: !37, scopeLine: 42, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !42)
67-
; CHECK-NEXT: !37 = !DISubroutineType(types: !38)
68-
; CHECK-NEXT: !38 = !{!6, !6, !39}
69-
; CHECK-NEXT: !39 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 640, flags: DIFlagVector, elements: !40)
70-
; CHECK-NEXT: !40 = !{!41}
71-
; CHECK-NEXT: !41 = !DISubrange(count: 10, lowerBound: 0)
72-
; CHECK-NEXT: !42 = !{!43, !44, !45, !46, !48, !49}
73-
; CHECK-NEXT: !43 = !DILocalVariable(name: "a", arg: 1, scope: !36, file: !1, line: 42, type: !6)
74-
; CHECK-NEXT: !44 = !DILocalVariable(name: "b", arg: 2, scope: !36, file: !1, line: 42, type: !6)
75-
; CHECK-NEXT: !45 = !DILocalVariable(name: "c", arg: 3, scope: !36, file: !1, line: 42, type: !39)
76-
; CHECK-NEXT: !46 = !DILocalVariable(name: "d", scope: !47, file: !1, line: 43, type: !6)
77-
; CHECK-NEXT: !47 = distinct !DILexicalBlock(scope: !36, file: !1, line: 42)
78-
; CHECK-NEXT: !48 = !DILocalVariable(name: "e", scope: !47, file: !1, line: 44, type: !6)
79-
; CHECK-NEXT: !49 = !DILabel(scope: !36, name: "label3", file: !1, line: 42)
80-
; CHECK-NEXT: !50 = !DILocation(line: 42, scope: !36)
81-
; CHECK-NEXT: !51 = !DILabel(scope: !36, name: "label1", file: !1, line: 42)
82-
; CHECK-NEXT: !52 = !DILabel(scope: !36, name: "label2", file: !1, line: 42)
83-
; CHECK-NEXT: !53 = !DILocation(line: 43, scope: !36)
44+
; CHECK-NEXT: !11 = !{!12, !16}
45+
; CHECK-NEXT: !12 = !DIGlobalVariableExpression(var: !13, expr: !DIExpression(DW_OP_constu, 0, DW_OP_stack_value))
46+
; CHECK-NEXT: !13 = distinct !DIGlobalVariable(name: "globalClass", scope: !5, file: !1, line: 1, type: !14, isLocal: true, isDefinition: true)
47+
; CHECK-NEXT: !14 = !DICompositeType(tag: DW_TAG_structure_type, name: "TestClass", scope: !1, file: !1, line: 42, size: 64, flags: DIFlagObjcClassComplete, elements: !15)
48+
; CHECK-NEXT: !15 = !{}
49+
; CHECK-NEXT: !16 = !DIGlobalVariableExpression(var: !17, expr: !DIExpression(DW_OP_constu, 0, DW_OP_stack_value))
50+
; CHECK-NEXT: !17 = distinct !DIGlobalVariable(name: "global", scope: !5, file: !1, line: 1, type: !18, isLocal: true, isDefinition: true)
51+
; CHECK-NEXT: !18 = !DIDerivedType(tag: DW_TAG_typedef, name: "int64_t", scope: !1, file: !1, line: 42, baseType: !6)
52+
; CHECK-NEXT: !19 = !{!20, !22}
53+
; CHECK-NEXT: !20 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !5, entity: !21, file: !1, line: 42)
54+
; CHECK-NEXT: !21 = !DIModule(scope: null, name: "llvm-c-test-import", includePath: "/test/include/llvm-c-test-import.h")
55+
; CHECK-NEXT: !22 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !5, entity: !20, file: !1, line: 42)
56+
; CHECK-NEXT: !23 = !{!24}
57+
; CHECK-NEXT: !24 = !DIMacroFile(file: !1, nodes: !25)
58+
; CHECK-NEXT: !25 = !{!26, !27}
59+
; CHECK-NEXT: !26 = !DIMacro(type: DW_MACINFO_define, name: "SIMPLE_DEFINE")
60+
; CHECK-NEXT: !27 = !DIMacro(type: DW_MACINFO_define, name: "VALUE_DEFINE", value: "1")
61+
; CHECK-NEXT: !28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !29, size: 192, dwarfAddressSpace: 0)
62+
; CHECK-NEXT: !29 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyStruct", scope: !4, file: !1, size: 192, elements: !30, runtimeLang: DW_LANG_C89, identifier: "MyStruct")
63+
; CHECK-NEXT: !30 = !{!31}
64+
; CHECK-NEXT: !31 = !DICompositeType(tag: DW_TAG_structure_type, name: "ThisStruc", scope: !4, file: !1, size: 192, elements: !32, runtimeLang: DW_LANG_C89, identifier: "ThisStruc")
65+
; CHECK-NEXT: !32 = !{!6, !6, !6}
66+
; CHECK-NEXT: !33 = !DISubrangeType(name: "foo", scope: !1, file: !1, line: 42, size: 64, baseType: !6, lowerBound: i64 0, upperBound: i64 1)
67+
; CHECK-NEXT: !34 = !DIDerivedType(tag: DW_TAG_set_type, name: "enumset", scope: !1, file: !1, line: 42, baseType: !3, size: 64)
68+
; CHECK-NEXT: !35 = !DIDerivedType(tag: DW_TAG_set_type, name: "subrangeset", scope: !1, file: !1, line: 42, baseType: !33, size: 64)
69+
; CHECK-NEXT: !36 = !DICompositeType(tag: DW_TAG_array_type, name: "foo", scope: !1, file: !1, line: 42, baseType: !6, size: 640, elements: !37, dataLocation: !DIExpression())
70+
; CHECK-NEXT: !37 = !{!38}
71+
; CHECK-NEXT: !38 = !DISubrange(count: 10, lowerBound: 0)
72+
; CHECK-NEXT: !39 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 42, type: !40, scopeLine: 42, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !43)
73+
; CHECK-NEXT: !40 = !DISubroutineType(types: !41)
74+
; CHECK-NEXT: !41 = !{!6, !6, !42}
75+
; CHECK-NEXT: !42 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 640, flags: DIFlagVector, elements: !37)
76+
; CHECK-NEXT: !43 = !{!44, !45, !46, !47, !49, !50}
77+
; CHECK-NEXT: !44 = !DILocalVariable(name: "a", arg: 1, scope: !39, file: !1, line: 42, type: !6)
78+
; CHECK-NEXT: !45 = !DILocalVariable(name: "b", arg: 2, scope: !39, file: !1, line: 42, type: !6)
79+
; CHECK-NEXT: !46 = !DILocalVariable(name: "c", arg: 3, scope: !39, file: !1, line: 42, type: !42)
80+
; CHECK-NEXT: !47 = !DILocalVariable(name: "d", scope: !48, file: !1, line: 43, type: !6)
81+
; CHECK-NEXT: !48 = distinct !DILexicalBlock(scope: !39, file: !1, line: 42)
82+
; CHECK-NEXT: !49 = !DILocalVariable(name: "e", scope: !48, file: !1, line: 44, type: !6)
83+
; CHECK-NEXT: !50 = !DILabel(scope: !39, name: "label3", file: !1, line: 42)
84+
; CHECK-NEXT: !51 = !DILocation(line: 42, scope: !39)
85+
; CHECK-NEXT: !52 = !DILabel(scope: !39, name: "label1", file: !1, line: 42)
86+
; CHECK-NEXT: !53 = !DILabel(scope: !39, name: "label2", file: !1, line: 42)
87+
; CHECK-NEXT: !54 = !DILocation(line: 43, scope: !39)

llvm/tools/llvm-c-test/debuginfo.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,42 @@ int llvm_test_dibuilder(void) {
235235
M, "LargeEnumTest",
236236
LLVMMetadataAsValue(LLVMGetModuleContext(M), LargeEnumTest));
237237

238+
LLVMMetadataRef lo = LLVMValueAsMetadata(FooVal1);
239+
LLVMMetadataRef hi = LLVMValueAsMetadata(FooVal2);
240+
LLVMMetadataRef SubrangeMetadataTy = LLVMDIBuilderCreateSubrangeType(
241+
DIB, File, "foo", 3, 42, File, 64, 0, 0, Int64Ty, lo, hi, NULL, NULL);
242+
LLVMAddNamedMetadataOperand(
243+
M, "SubrangeType",
244+
LLVMMetadataAsValue(LLVMGetModuleContext(M), SubrangeMetadataTy));
245+
246+
LLVMMetadataRef SetMetadataTy1 = LLVMDIBuilderCreateSetType(
247+
DIB, File, "enumset", 7, File, 42, 64, 0, EnumTest);
248+
LLVMMetadataRef SetMetadataTy2 = LLVMDIBuilderCreateSetType(
249+
DIB, File, "subrangeset", 11, File, 42, 64, 0, SubrangeMetadataTy);
250+
LLVMAddNamedMetadataOperand(
251+
M, "SetType1",
252+
LLVMMetadataAsValue(LLVMGetModuleContext(M), SetMetadataTy1));
253+
LLVMAddNamedMetadataOperand(
254+
M, "SetType2",
255+
LLVMMetadataAsValue(LLVMGetModuleContext(M), SetMetadataTy2));
256+
257+
LLVMMetadataRef DynSubscripts[] = {
258+
LLVMDIBuilderGetOrCreateSubrange(DIB, 0, 10),
259+
};
260+
LLVMMetadataRef LocExpression = LLVMDIBuilderCreateExpression(DIB, NULL, 0);
261+
LLVMMetadataRef DynamicArrayMetadataTy = LLVMDIBuilderCreateDynamicArrayType(
262+
DIB, File, "foo", 3, 42, File, 64 * 10, 0, Int64Ty, DynSubscripts, 1,
263+
LocExpression, NULL, NULL, NULL, NULL);
264+
LLVMAddNamedMetadataOperand(
265+
M, "DynType",
266+
LLVMMetadataAsValue(LLVMGetModuleContext(M), DynamicArrayMetadataTy));
267+
268+
LLVMMetadataRef StructElts[] = {Int64Ty, Int64Ty, Int64Ty};
269+
LLVMMetadataRef StructDestTy = LLVMDIBuilderCreateStructType(
270+
DIB, NameSpace, "ThisStruct", 9, File, 0, 192, 0, 0, NULL, StructElts, 3,
271+
LLVMDWARFSourceLanguageC, NULL, "ThisStruct", 9);
272+
LLVMReplaceArrays(DIB, &StructDbgTy, &StructDestTy, 1);
273+
238274
// Using the new debug format, debug records get attached to instructions.
239275
// Insert a `br` and `ret` now to absorb the debug records which are
240276
// currently "trailing", meaning that they're associated with a block

0 commit comments

Comments
 (0)