Index: DIBuilderBindings.h =================================================================== --- DIBuilderBindings.h +++ DIBuilderBindings.h @@ -116,6 +116,13 @@ 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: DIBuilderBindings.cpp =================================================================== --- DIBuilderBindings.cpp +++ DIBuilderBindings.cpp @@ -19,8 +19,7 @@ using namespace llvm; namespace { -template -T unwrapDI(LLVMValueRef v) { +template T unwrapDI(LLVMValueRef v) { return v ? T(unwrap(v)) : T(); } } @@ -220,3 +219,15 @@ unwrapDI(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(VarInfo), + unwrapDI(Expr), unwrap(Block)); + return wrap(Instr); +} Index: dibuilder.go =================================================================== --- dibuilder.go +++ dibuilder.go @@ -484,6 +484,13 @@ 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