diff options
Diffstat (limited to 'bindings/go/llvm')
-rw-r--r-- | bindings/go/llvm/DIBuilderBindings.cpp | 12 | ||||
-rw-r--r-- | bindings/go/llvm/DIBuilderBindings.h | 5 | ||||
-rw-r--r-- | bindings/go/llvm/IRBindings.cpp | 5 | ||||
-rw-r--r-- | bindings/go/llvm/dibuilder.go | 32 | ||||
-rw-r--r-- | bindings/go/llvm/linker.go | 2 |
5 files changed, 52 insertions, 4 deletions
diff --git a/bindings/go/llvm/DIBuilderBindings.cpp b/bindings/go/llvm/DIBuilderBindings.cpp index a7d75a3..f39198d 100644 --- a/bindings/go/llvm/DIBuilderBindings.cpp +++ b/bindings/go/llvm/DIBuilderBindings.cpp @@ -146,6 +146,18 @@ LLVMMetadataRef LLVMDIBuilderCreateStructType( return wrap(CT); } +LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType( + LLVMDIBuilderRef Dref, unsigned Tag, const char *Name, + LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, + unsigned RuntimeLang, uint64_t SizeInBits, uint64_t AlignInBits, + unsigned Flags) { + DIBuilder *D = unwrap(Dref); + DICompositeType CT = D->createReplaceableCompositeType( + Tag, Name, unwrapDI<DIDescriptor>(Scope), unwrapDI<DIFile>(File), Line, + RuntimeLang, SizeInBits, AlignInBits, Flags); + return wrap(CT); +} + LLVMMetadataRef LLVMDIBuilderCreateMemberType(LLVMDIBuilderRef Dref, LLVMMetadataRef Scope, const char *Name, LLVMMetadataRef File, diff --git a/bindings/go/llvm/DIBuilderBindings.h b/bindings/go/llvm/DIBuilderBindings.h index e268b3c..a4fba27 100644 --- a/bindings/go/llvm/DIBuilderBindings.h +++ b/bindings/go/llvm/DIBuilderBindings.h @@ -84,6 +84,11 @@ LLVMMetadataRef LLVMDIBuilderCreateStructType( uint64_t AlignInBits, unsigned Flags, LLVMMetadataRef DerivedFrom, LLVMMetadataRef ElementTypes); +LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType( + LLVMDIBuilderRef D, unsigned Tag, const char *Name, LLVMMetadataRef Scope, + LLVMMetadataRef File, unsigned Line, unsigned RuntimeLang, + uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags); + LLVMMetadataRef LLVMDIBuilderCreateMemberType(LLVMDIBuilderRef D, LLVMMetadataRef Scope, const char *Name, LLVMMetadataRef File, diff --git a/bindings/go/llvm/IRBindings.cpp b/bindings/go/llvm/IRBindings.cpp index fb451ef..fd0cb80 100644 --- a/bindings/go/llvm/IRBindings.cpp +++ b/bindings/go/llvm/IRBindings.cpp @@ -86,9 +86,8 @@ void LLVMSetMetadata2(LLVMValueRef Inst, unsigned KindID, LLVMMetadataRef MD) { } void LLVMMetadataReplaceAllUsesWith(LLVMMetadataRef MD, LLVMMetadataRef New) { - auto *Node = unwrap<MDTuple>(MD); - assert(Node->isTemporary() && "Expected temporary node"); - Node->replaceAllUsesWith(unwrap<MDNode>(New)); + auto *Node = unwrap<MDNode>(MD); + Node->replaceAllUsesWith(unwrap<Metadata>(New)); MDNode::deleteTemporary(Node); } diff --git a/bindings/go/llvm/dibuilder.go b/bindings/go/llvm/dibuilder.go index 3b1a1a6..f03f740 100644 --- a/bindings/go/llvm/dibuilder.go +++ b/bindings/go/llvm/dibuilder.go @@ -343,6 +343,38 @@ func (d *DIBuilder) CreateStructType(scope Metadata, t DIStructType) Metadata { return Metadata{C: result} } +// DIReplaceableCompositeType holds the values for creating replaceable +// composite type debug metadata. +type DIReplaceableCompositeType struct { + Tag dwarf.Tag + Name string + File Metadata + Line int + RuntimeLang int + SizeInBits uint64 + AlignInBits uint64 + Flags int +} + +// CreateReplaceableCompositeType creates replaceable composite type debug metadata. +func (d *DIBuilder) CreateReplaceableCompositeType(scope Metadata, t DIReplaceableCompositeType) Metadata { + name := C.CString(t.Name) + defer C.free(unsafe.Pointer(name)) + result := C.LLVMDIBuilderCreateReplaceableCompositeType( + d.ref, + C.unsigned(t.Tag), + name, + scope.C, + t.File.C, + C.unsigned(t.Line), + C.unsigned(t.RuntimeLang), + C.uint64_t(t.SizeInBits), + C.uint64_t(t.AlignInBits), + C.unsigned(t.Flags), + ) + return Metadata{C: result} +} + // DIMemberType holds the values for creating member type debug metadata. type DIMemberType struct { Name string diff --git a/bindings/go/llvm/linker.go b/bindings/go/llvm/linker.go index 64d794e..f64f66c 100644 --- a/bindings/go/llvm/linker.go +++ b/bindings/go/llvm/linker.go @@ -22,7 +22,7 @@ import "errors" func LinkModules(Dest, Src Module) error { var cmsg *C.char - failed := C.LLVMLinkModules(Dest.C, Src.C, 0, &cmsg) + failed := C.LLVMLinkModules(Dest.C, Src.C, C.LLVMLinkerDestroySource, &cmsg) if failed != 0 { err := errors.New(C.GoString(cmsg)) C.LLVMDisposeMessage(cmsg) |