Index: llvm/trunk/bindings/go/llvm/DIBuilderBindings.h =================================================================== --- llvm/trunk/bindings/go/llvm/DIBuilderBindings.h +++ llvm/trunk/bindings/go/llvm/DIBuilderBindings.h @@ -33,17 +33,6 @@ LLVMMetadataRef File, unsigned Line, LLVMMetadataRef Context); -LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef D, int64_t Lo, - int64_t Count); - -LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef D, - LLVMMetadataRef *Data, - size_t Length); - -LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef D, - LLVMMetadataRef *Data, - size_t Length); - LLVMValueRef LLVMDIBuilderInsertValueAtEnd(LLVMDIBuilderRef D, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, Index: llvm/trunk/bindings/go/llvm/DIBuilderBindings.cpp =================================================================== --- llvm/trunk/bindings/go/llvm/DIBuilderBindings.cpp +++ llvm/trunk/bindings/go/llvm/DIBuilderBindings.cpp @@ -29,32 +29,6 @@ Context ? unwrap(Context) : nullptr)); } -LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Dref, - int64_t Lo, int64_t Count) { - DIBuilder *D = unwrap(Dref); - return wrap(D->getOrCreateSubrange(Lo, Count)); -} - -LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Dref, - LLVMMetadataRef *Data, - size_t Length) { - DIBuilder *D = unwrap(Dref); - Metadata **DataValue = unwrap(Data); - ArrayRef Elements(DataValue, Length); - DINodeArray A = D->getOrCreateArray(Elements); - return wrap(A.get()); -} - -LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Dref, - LLVMMetadataRef *Data, - size_t Length) { - DIBuilder *D = unwrap(Dref); - Metadata **DataValue = unwrap(Data); - ArrayRef Elements(DataValue, Length); - DITypeRefArray A = D->getOrCreateTypeArray(Elements); - return wrap(A.get()); -} - LLVMValueRef LLVMDIBuilderInsertValueAtEnd(LLVMDIBuilderRef Dref, LLVMValueRef Val, LLVMMetadataRef VarInfo, Index: llvm/trunk/include/llvm-c/DebugInfo.h =================================================================== --- llvm/trunk/include/llvm-c/DebugInfo.h +++ llvm/trunk/include/llvm-c/DebugInfo.h @@ -319,6 +319,16 @@ LLVMMetadataRef InlinedAt); /** + * Create a type array. + * \param Builder The DIBuilder. + * \param Data The type elements. + * \param NumElements Number of type elements. + */ +LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Builder, + LLVMMetadataRef *Data, + size_t NumElements); + +/** * Create subroutine type. * \param Builder The DIBuilder. * \param File The file in which the subroutine resides. @@ -677,6 +687,26 @@ LLVMMetadataRef Type); /** + * Create a descriptor for a value range. + * \param Builder The DIBuilder. + * \param LowerBound Lower bound of the subrange, e.g. 0 for C, 1 for Fortran. + * \param Count Count of elements in the subrange. + */ +LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder, + int64_t LowerBound, + int64_t Count); + +/** + * Create an array of DI Nodes. + * \param Builder The DIBuilder. + * \param Data The DI Node elements. + * \param NumElements Number of DI Node elements. + */ +LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder, + LLVMMetadataRef *Data, + size_t NumElements); + +/** * Create a new descriptor for the specified variable which has a complex * address expression for its address. * \param Builder The DIBuilder. Index: llvm/trunk/lib/IR/DebugInfo.cpp =================================================================== --- llvm/trunk/lib/IR/DebugInfo.cpp +++ llvm/trunk/lib/IR/DebugInfo.cpp @@ -1017,6 +1017,13 @@ return wrap(unwrap(Builder)->createArtificialType(unwrapDI(Type))); } +LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray(LLVMDIBuilderRef Builder, + LLVMMetadataRef *Types, + size_t Length) { + return wrap( + unwrap(Builder)->getOrCreateTypeArray({unwrap(Types), Length}).get()); +} + LLVMMetadataRef LLVMDIBuilderCreateSubroutineType(LLVMDIBuilderRef Builder, LLVMMetadataRef File, @@ -1073,6 +1080,18 @@ map_from_llvmDIFlags(Flags))); } +LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange(LLVMDIBuilderRef Builder, + int64_t Lo, int64_t Count) { + return wrap(unwrap(Builder)->getOrCreateSubrange(Lo, Count)); +} + +LLVMMetadataRef LLVMDIBuilderGetOrCreateArray(LLVMDIBuilderRef Builder, + LLVMMetadataRef *Data, + size_t Length) { + Metadata **DataValue = unwrap(Data); + return wrap(unwrap(Builder)->getOrCreateArray({DataValue, Length}).get()); +} + LLVMMetadataRef LLVMGetSubprogram(LLVMValueRef Func) { return wrap(unwrap(Func)->getSubprogram()); } Index: llvm/trunk/test/Bindings/llvm-c/debug_info.ll =================================================================== --- llvm/trunk/test/Bindings/llvm-c/debug_info.ll +++ llvm/trunk/test/Bindings/llvm-c/debug_info.ll @@ -3,18 +3,19 @@ ; CHECK: ; ModuleID = 'debuginfo.c' ; CHECK-NEXT: source_filename = "debuginfo.c" -; CHECK: define i64 @foo(i64, i64) !dbg !9 { +; CHECK: define i64 @foo(i64, i64, <10 x i64>) !dbg !9 { ; CHECK-NEXT: entry: -; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !13, metadata !DIExpression()), !dbg !15 -; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !14, metadata !DIExpression()), !dbg !15 +; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !16, metadata !DIExpression()), !dbg !19 +; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !17, metadata !DIExpression()), !dbg !19 +; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !18, metadata !DIExpression()), !dbg !19 ; CHECK-NEXT: } ; CHECK: declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 -; CHECK: declare !dbg !16 i64 @foo_inner_scope(i64, i64) +; CHECK: declare !dbg !20 i64 @foo_inner_scope(i64, i64, <10 x i64>) ; CHECK: !llvm.dbg.cu = !{!0} -; CHECK-NEXT: !FooType = !{!3} +; CHECK: !FooType = !{!3} ; CHECK: !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "llvm-c-test", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false) ; CHECK-NEXT: !1 = !DIFile(filename: "debuginfo.c", directory: ".") @@ -25,12 +26,16 @@ ; CHECK-NEXT: !6 = !DIModule(scope: null, name: "llvm-c-test", includePath: "/test/include/llvm-c-test.h") ; CHECK-NEXT: !7 = !{!8, !8, !8} ; CHECK-NEXT: !8 = !DIBasicType(name: "Int64", size: 64) -; 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) +; 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) ; CHECK-NEXT: !10 = !DISubroutineType(types: !11) -; CHECK-NEXT: !11 = !{!8, !8} -; CHECK-NEXT: !12 = !{!13, !14} -; CHECK-NEXT: !13 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 42, type: !8) -; CHECK-NEXT: !14 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 42, type: !8) -; CHECK-NEXT: !15 = !DILocation(line: 42, scope: !9) -; 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) -; CHECK-NEXT: !17 = distinct !DILexicalBlock(scope: !9, file: !1, line: 42) +; CHECK-NEXT: !11 = !{!8, !8, !12} +; CHECK-NEXT: !12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 640, flags: DIFlagVector, elements: !13) +; CHECK-NEXT: !13 = !{!14} +; CHECK-NEXT: !14 = !DISubrange(count: 10) +; CHECK-NEXT: !15 = !{!16, !17, !18} +; CHECK-NEXT: !16 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 42, type: !8) +; CHECK-NEXT: !17 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 42, type: !8) +; CHECK-NEXT: !18 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 42, type: !12) +; CHECK-NEXT: !19 = !DILocation(line: 42, scope: !9) +; 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) +; CHECK-NEXT: !21 = distinct !DILexicalBlock(scope: !9, file: !1, line: 42) Index: llvm/trunk/tools/llvm-c-test/debuginfo.c =================================================================== --- llvm/trunk/tools/llvm-c-test/debuginfo.c +++ llvm/trunk/tools/llvm-c-test/debuginfo.c @@ -55,18 +55,31 @@ LLVMMetadataAsValue(LLVMGetModuleContext(M), StructDbgPtrTy)); - LLVMTypeRef FooParamTys[] = { LLVMInt64Type(), LLVMInt64Type() }; - LLVMTypeRef FooFuncTy = LLVMFunctionType(LLVMInt64Type(), FooParamTys, 2, 0); + LLVMTypeRef FooParamTys[] = { + LLVMInt64Type(), + LLVMInt64Type(), + LLVMVectorType(LLVMInt64Type(), 10), + }; + LLVMTypeRef FooFuncTy = LLVMFunctionType(LLVMInt64Type(), FooParamTys, 3, 0); LLVMValueRef FooFunction = LLVMAddFunction(M, "foo", FooFuncTy); LLVMBasicBlockRef FooEntryBlock = LLVMAppendBasicBlock(FooFunction, "entry"); - LLVMMetadataRef ParamTypes[] = {Int64Ty, Int64Ty}; + LLVMMetadataRef Subscripts[] = { + LLVMDIBuilderGetOrCreateSubrange(DIB, 0, 10), + }; + LLVMMetadataRef VectorTy = + LLVMDIBuilderCreateVectorType(DIB, 64 * 10, 0, + Int64Ty, Subscripts, 1); + + + LLVMMetadataRef ParamTypes[] = {Int64Ty, Int64Ty, VectorTy}; LLVMMetadataRef FunctionTy = - LLVMDIBuilderCreateSubroutineType(DIB, File, ParamTypes, 2, 0); + LLVMDIBuilderCreateSubroutineType(DIB, File, ParamTypes, 3, 0); LLVMMetadataRef FunctionMetadata = LLVMDIBuilderCreateFunction(DIB, File, "foo", 3, "foo", 3, File, 42, FunctionTy, true, true, 42, 0, false); + LLVMMetadataRef FooParamLocation = LLVMDIBuilderCreateDebugLocation(LLVMGetGlobalContext(), 42, 0, FunctionMetadata, NULL); @@ -84,6 +97,13 @@ LLVMDIBuilderInsertDeclareAtEnd(DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar2, FooParamExpression, FooParamLocation, FooEntryBlock); + LLVMMetadataRef FooParamVar3 = + LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "c", 1, 3, File, + 42, VectorTy, true, 0); + LLVMDIBuilderInsertDeclareAtEnd(DIB, LLVMConstInt(LLVMInt64Type(), 0, false), + FooParamVar3, FooParamExpression, + FooParamLocation, FooEntryBlock); + LLVMSetSubprogram(FooFunction, FunctionMetadata); LLVMMetadataRef FooLexicalBlock =