Go bindings: add DIBuilder.InsertValueAtEnd
authorPeter Collingbourne <peter@pcc.me.uk>
Tue, 25 Nov 2014 21:05:04 +0000 (21:05 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Tue, 25 Nov 2014 21:05:04 +0000 (21:05 +0000)
Expose llvm::DIBuilder::insertDbgValueIntrinsic as
DIBuilder.InsertValueAtEnd in the Go bindings, to support attaching
debug metadata to register values.

Patch by Andrew Wilkins!

Differential Revision: http://reviews.llvm.org/D6374

llvm-svn: 222790

llvm/bindings/go/llvm/DIBuilderBindings.cpp
llvm/bindings/go/llvm/DIBuilderBindings.h
llvm/bindings/go/llvm/dibuilder.go

index 94fa96f..cb7ac8d 100644 (file)
@@ -19,8 +19,7 @@
 using namespace llvm;
 
 namespace {
-template <typename T>
-T unwrapDI(LLVMValueRef v) {
+template <typename T> T unwrapDI(LLVMValueRef v) {
   return v ? T(unwrap<MDNode>(v)) : T();
 }
 }
@@ -220,3 +219,15 @@ LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Dref,
                        unwrapDI<DIExpression>(Expr), unwrap(Block));
   return wrap(Instr);
 }
+
+LLVMValueRef LLVMDIBuilderInsertValueAtEnd(LLVMDIBuilderRef Dref,
+                                           LLVMValueRef Val, uint64_t Offset,
+                                           LLVMValueRef VarInfo,
+                                           LLVMValueRef Expr,
+                                           LLVMBasicBlockRef Block) {
+  DIBuilder *D = unwrap(Dref);
+  Instruction *Instr = D->insertDbgValueIntrinsic(
+      unwrap(Val), Offset, unwrapDI<DIVariable>(VarInfo),
+      unwrapDI<DIExpression>(Expr), unwrap(Block));
+  return wrap(Instr);
+}
index e6fe02a..4df7910 100644 (file)
@@ -116,6 +116,13 @@ LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef D,
                                              LLVMValueRef Expr,
                                              LLVMBasicBlockRef Block);
 
+LLVMValueRef LLVMDIBuilderInsertValueAtEnd(LLVMDIBuilderRef D,
+                                           LLVMValueRef Val,
+                                           uint64_t Offset,
+                                           LLVMValueRef VarInfo,
+                                           LLVMValueRef Expr,
+                                           LLVMBasicBlockRef Block);
+
 #ifdef __cplusplus
 }  // extern "C"
 #endif
index 1d07e98..bcbea93 100644 (file)
@@ -484,6 +484,13 @@ func (d *DIBuilder) InsertDeclareAtEnd(v, diVarInfo, expr Value, bb BasicBlock)
        return Value{C: result}
 }
 
+// InsertValueAtEnd inserts a call to llvm.dbg.value at the end of the
+// specified basic block for the given value and associated debug metadata.
+func (d *DIBuilder) InsertValueAtEnd(v, diVarInfo, expr Value, offset uint64, bb BasicBlock) Value {
+       result := C.LLVMDIBuilderInsertValueAtEnd(d.ref, v.C, C.uint64_t(offset), diVarInfo.C, expr.C, bb.C)
+       return Value{C: result}
+}
+
 func boolToCInt(v bool) C.int {
        if v {
                return 1