llvm.org GIT mirror llvm / cd997a7
[LLVM-C] DIBuilderBindings for Subrange and Arrays Summary: Move Go bindings for subranges and DINode arrays. Reviewers: harlanhaskins, whitequark, deadalnix Reviewed By: whitequark Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45933 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330594 91177308-0d34-0410-b5e6-96231b3b80d8 Robert Widmann 1 year, 4 months ago
6 changed file(s) with 91 addition(s) and 54 deletion(s). Raw diff Collapse all Expand all
2828 Context ? unwrap(Context) : nullptr));
2929 }
3030
31 LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Dref,
32 int64_t Lo, int64_t Count) {
33 DIBuilder *D = unwrap(Dref);
34 return wrap(D->getOrCreateSubrange(Lo, Count));
35 }
36
37 LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Dref,
38 LLVMMetadataRef *Data,
39 size_t Length) {
40 DIBuilder *D = unwrap(Dref);
41 Metadata **DataValue = unwrap(Data);
42 ArrayRef Elements(DataValue, Length);
43 DINodeArray A = D->getOrCreateArray(Elements);
44 return wrap(A.get());
45 }
46
47 LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Dref,
48 LLVMMetadataRef *Data,
49 size_t Length) {
50 DIBuilder *D = unwrap(Dref);
51 Metadata **DataValue = unwrap(Data);
52 ArrayRef Elements(DataValue, Length);
53 DITypeRefArray A = D->getOrCreateTypeArray(Elements);
54 return wrap(A.get());
55 }
56
5731 LLVMValueRef LLVMDIBuilderInsertValueAtEnd(LLVMDIBuilderRef Dref,
5832 LLVMValueRef Val,
5933 LLVMMetadataRef VarInfo,
3232 LLVMMetadataRef File, unsigned Line,
3333 LLVMMetadataRef Context);
3434
35 LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef D, int64_t Lo,
36 int64_t Count);
37
38 LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef D,
39 LLVMMetadataRef *Data,
40 size_t Length);
41
42 LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef D,
43 LLVMMetadataRef *Data,
44 size_t Length);
45
4635 LLVMValueRef LLVMDIBuilderInsertValueAtEnd(LLVMDIBuilderRef D, LLVMValueRef Val,
4736 LLVMMetadataRef VarInfo,
4837 LLVMMetadataRef Expr,
318318 LLVMMetadataRef InlinedAt);
319319
320320 /**
321 * Create a type array.
322 * \param Builder The DIBuilder.
323 * \param Data The type elements.
324 * \param NumElements Number of type elements.
325 */
326 LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Builder,
327 LLVMMetadataRef *Data,
328 size_t NumElements);
329
330 /**
321331 * Create subroutine type.
322332 * \param Builder The DIBuilder.
323333 * \param File The file in which the subroutine resides.
676686 LLVMMetadataRef Type);
677687
678688 /**
689 * Create a descriptor for a value range.
690 * \param Builder The DIBuilder.
691 * \param LowerBound Lower bound of the subrange, e.g. 0 for C, 1 for Fortran.
692 * \param Count Count of elements in the subrange.
693 */
694 LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder,
695 int64_t LowerBound,
696 int64_t Count);
697
698 /**
699 * Create an array of DI Nodes.
700 * \param Builder The DIBuilder.
701 * \param Data The DI Node elements.
702 * \param NumElements Number of DI Node elements.
703 */
704 LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder,
705 LLVMMetadataRef *Data,
706 size_t NumElements);
707
708 /**
679709 * Create a new descriptor for the specified variable which has a complex
680710 * address expression for its address.
681711 * \param Builder The DIBuilder.
10161016 return wrap(unwrap(Builder)->createArtificialType(unwrapDI(Type)));
10171017 }
10181018
1019 LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Builder,
1020 LLVMMetadataRef *Types,
1021 size_t Length) {
1022 return wrap(
1023 unwrap(Builder)->getOrCreateTypeArray({unwrap(Types), Length}).get());
1024 }
1025
10191026 LLVMMetadataRef
10201027 LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Builder,
10211028 LLVMMetadataRef File,
10721079 map_from_llvmDIFlags(Flags)));
10731080 }
10741081
1082 LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder,
1083 int64_t Lo, int64_t Count) {
1084 return wrap(unwrap(Builder)->getOrCreateSubrange(Lo, Count));
1085 }
1086
1087 LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder,
1088 LLVMMetadataRef *Data,
1089 size_t Length) {
1090 Metadata **DataValue = unwrap(Data);
1091 return wrap(unwrap(Builder)->getOrCreateArray({DataValue, Length}).get());
1092 }
1093
10751094 LLVMMetadataRef LLVMGetSubprogram(LLVMValueRef Func) {
10761095 return wrap(unwrap(Func)->getSubprogram());
10771096 }
22 ; CHECK: ; ModuleID = 'debuginfo.c'
33 ; CHECK-NEXT: source_filename = "debuginfo.c"
44
5 ; CHECK: define i64 @foo(i64, i64) !dbg !9 {
5 ; CHECK: define i64 @foo(i64, i64, <10 x i64>) !dbg !9 {
66 ; CHECK-NEXT: entry:
7 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !13, metadata !DIExpression()), !dbg !15
8 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !14, metadata !DIExpression()), !dbg !15
7 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !16, metadata !DIExpression()), !dbg !19
8 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !17, metadata !DIExpression()), !dbg !19
9 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !18, metadata !DIExpression()), !dbg !19
910 ; CHECK-NEXT: }
1011
1112 ; CHECK: declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
1213
13 ; CHECK: declare !dbg !16 i64 @foo_inner_scope(i64, i64)
14 ; CHECK: declare !dbg !20 i64 @foo_inner_scope(i64, i64, <10 x i64>)
1415
1516 ; CHECK: !llvm.dbg.cu = !{!0}
16 ; CHECK-NEXT: !FooType = !{!3}
17 ; CHECK: !FooType = !{!3}
1718
1819 ; CHECK: !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "llvm-c-test", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false)
1920 ; CHECK-NEXT: !1 = !DIFile(filename: "debuginfo.c", directory: ".")
2425 ; CHECK-NEXT: !6 = !DIModule(scope: null, name: "llvm-c-test", includePath: "/test/include/llvm-c-test.h")
2526 ; CHECK-NEXT: !7 = !{!8, !8, !8}
2627 ; CHECK-NEXT: !8 = !DIBasicType(name: "Int64", size: 64)
27 ; CHECK-NEXT: !9 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 42, type: !10, isLocal: true, isDefinition: true, scopeLine: 42, isOptimized: false, unit: !0, variables: !12)
28 ; CHECK-NEXT: !9 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 42, type: !10, isLocal: true, isDefinition: true, scopeLine: 42, isOptimized: false, unit: !0, variables: !15)
2829 ; CHECK-NEXT: !10 = !DISubroutineType(types: !11)
29 ; CHECK-NEXT: !11 = !{!8, !8}
30 ; CHECK-NEXT: !12 = !{!13, !14}
31 ; CHECK-NEXT: !13 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 42, type: !8)
32 ; CHECK-NEXT: !14 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 42, type: !8)
33 ; CHECK-NEXT: !15 = !DILocation(line: 42, scope: !9)
34 ; CHECK-NEXT: !16 = distinct !DISubprogram(name: "foo_inner_scope", linkageName: "foo_inner_scope", scope: !17, file: !1, line: 42, type: !10, isLocal: true, isDefinition: true, scopeLine: 42, isOptimized: false, unit: !0, variables: !2)
35 ; CHECK-NEXT: !17 = distinct !DILexicalBlock(scope: !9, file: !1, line: 42)
30 ; CHECK-NEXT: !11 = !{!8, !8, !12}
31 ; CHECK-NEXT: !12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 640, flags: DIFlagVector, elements: !13)
32 ; CHECK-NEXT: !13 = !{!14}
33 ; CHECK-NEXT: !14 = !DISubrange(count: 10)
34 ; CHECK-NEXT: !15 = !{!16, !17, !18}
35 ; CHECK-NEXT: !16 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 42, type: !8)
36 ; CHECK-NEXT: !17 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 42, type: !8)
37 ; CHECK-NEXT: !18 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 42, type: !12)
38 ; CHECK-NEXT: !19 = !DILocation(line: 42, scope: !9)
39 ; CHECK-NEXT: !20 = distinct !DISubprogram(name: "foo_inner_scope", linkageName: "foo_inner_scope", scope: !21, file: !1, line: 42, type: !10, isLocal: true, isDefinition: true, scopeLine: 42, isOptimized: false, unit: !0, variables: !2)
40 ; CHECK-NEXT: !21 = distinct !DILexicalBlock(scope: !9, file: !1, line: 42)
5454 LLVMMetadataAsValue(LLVMGetModuleContext(M), StructDbgPtrTy));
5555
5656
57 LLVMTypeRef FooParamTys[] = { LLVMInt64Type(), LLVMInt64Type() };
58 LLVMTypeRef FooFuncTy = LLVMFunctionType(LLVMInt64Type(), FooParamTys, 2, 0);
57 LLVMTypeRef FooParamTys[] = {
58 LLVMInt64Type(),
59 LLVMInt64Type(),
60 LLVMVectorType(LLVMInt64Type(), 10),
61 };
62 LLVMTypeRef FooFuncTy = LLVMFunctionType(LLVMInt64Type(), FooParamTys, 3, 0);
5963 LLVMValueRef FooFunction = LLVMAddFunction(M, "foo", FooFuncTy);
6064 LLVMBasicBlockRef FooEntryBlock = LLVMAppendBasicBlock(FooFunction, "entry");
6165
62 LLVMMetadataRef ParamTypes[] = {Int64Ty, Int64Ty};
66 LLVMMetadataRef Subscripts[] = {
67 LLVMDIBuilderGetOrCreateSubrange(DIB, 0, 10),
68 };
69 LLVMMetadataRef VectorTy =
70 LLVMDIBuilderCreateVectorType(DIB, 64 * 10, 0,
71 Int64Ty, Subscripts, 1);
72
73
74 LLVMMetadataRef ParamTypes[] = {Int64Ty, Int64Ty, VectorTy};
6375 LLVMMetadataRef FunctionTy =
64 LLVMDIBuilderCreateSubroutineType(DIB, File, ParamTypes, 2, 0);
76 LLVMDIBuilderCreateSubroutineType(DIB, File, ParamTypes, 3, 0);
6577 LLVMMetadataRef FunctionMetadata =
6678 LLVMDIBuilderCreateFunction(DIB, File, "foo", 3, "foo", 3,
6779 File, 42, FunctionTy, true, true,
6880 42, 0, false);
81
6982 LLVMMetadataRef FooParamLocation =
7083 LLVMDIBuilderCreateDebugLocation(LLVMGetGlobalContext(), 42, 0,
7184 FunctionMetadata, NULL);
8396 LLVMDIBuilderInsertDeclareAtEnd(DIB, LLVMConstInt(LLVMInt64Type(), 0, false),
8497 FooParamVar2, FooParamExpression,
8598 FooParamLocation, FooEntryBlock);
99 LLVMMetadataRef FooParamVar3 =
100 LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "c", 1, 3, File,
101 42, VectorTy, true, 0);
102 LLVMDIBuilderInsertDeclareAtEnd(DIB, LLVMConstInt(LLVMInt64Type(), 0, false),
103 FooParamVar3, FooParamExpression,
104 FooParamLocation, FooEntryBlock);
105
86106 LLVMSetSubprogram(FooFunction, FunctionMetadata);
87107
88108 LLVMMetadataRef FooLexicalBlock =