Go bindings: add DIBuilder.InsertValueAtEnd

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222790 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Collingbourne
2014-11-25 21:05:04 +00:00
parent c9d99b504d
commit 5a4bf227a9
3 changed files with 27 additions and 2 deletions

View File

@@ -19,8 +19,7 @@
using namespace llvm; using namespace llvm;
namespace { namespace {
template <typename T> template <typename T> T unwrapDI(LLVMValueRef v) {
T unwrapDI(LLVMValueRef v) {
return v ? T(unwrap<MDNode>(v)) : T(); return v ? T(unwrap<MDNode>(v)) : T();
} }
} }
@@ -220,3 +219,15 @@ LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Dref,
unwrapDI<DIExpression>(Expr), unwrap(Block)); unwrapDI<DIExpression>(Expr), unwrap(Block));
return wrap(Instr); 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);
}

View File

@@ -116,6 +116,13 @@ LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef D,
LLVMValueRef Expr, LLVMValueRef Expr,
LLVMBasicBlockRef Block); LLVMBasicBlockRef Block);
LLVMValueRef LLVMDIBuilderInsertValueAtEnd(LLVMDIBuilderRef D,
LLVMValueRef Val,
uint64_t Offset,
LLVMValueRef VarInfo,
LLVMValueRef Expr,
LLVMBasicBlockRef Block);
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" } // extern "C"
#endif #endif

View File

@@ -484,6 +484,13 @@ func (d *DIBuilder) InsertDeclareAtEnd(v, diVarInfo, expr Value, bb BasicBlock)
return Value{C: result} 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 { func boolToCInt(v bool) C.int {
if v { if v {
return 1 return 1