diff options
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index ea1d79d..cc36b71 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -1690,7 +1690,8 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore( DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare( unwrap(Storage), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr), unwrap<DILocation>(DL), - unwrap<Instruction>(Instr)); + Instr ? InsertPosition(unwrap<Instruction>(Instr)->getIterator()) + : nullptr); // This assert will fail if the module is in the old debug info format. // This function should only be called if the module is in the new // debug info format. @@ -1722,7 +1723,9 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore( LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) { DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic( unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr), - unwrap<DILocation>(DebugLoc), unwrap<Instruction>(Instr)); + unwrap<DILocation>(DebugLoc), + Instr ? InsertPosition(unwrap<Instruction>(Instr)->getIterator()) + : nullptr); // This assert will fail if the module is in the old debug info format. // This function should only be called if the module is in the new // debug info format. @@ -1738,7 +1741,8 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd( LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) { DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic( unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr), - unwrap<DILocation>(DebugLoc), unwrap(Block)); + unwrap<DILocation>(DebugLoc), + Block ? InsertPosition(unwrap(Block)->end()) : nullptr); // This assert will fail if the module is in the old debug info format. // This function should only be called if the module is in the new // debug info format. @@ -1804,21 +1808,25 @@ void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc) { unwrap<Instruction>(Inst)->setDebugLoc(DebugLoc()); } -LLVMMetadataRef LLVMDIBuilderCreateLabel( - LLVMDIBuilderRef Builder, - LLVMMetadataRef Context, const char *Name, size_t NameLen, - LLVMMetadataRef File, unsigned LineNo, LLVMBool AlwaysPreserve) { +LLVMMetadataRef LLVMDIBuilderCreateLabel(LLVMDIBuilderRef Builder, + LLVMMetadataRef Context, + const char *Name, size_t NameLen, + LLVMMetadataRef File, unsigned LineNo, + LLVMBool AlwaysPreserve) { return wrap(unwrap(Builder)->createLabel( - unwrapDI<DIScope>(Context), StringRef(Name, NameLen), - unwrapDI<DIFile>(File), LineNo, AlwaysPreserve)); + unwrapDI<DIScope>(Context), StringRef(Name, NameLen), + unwrapDI<DIFile>(File), LineNo, AlwaysPreserve)); } -LLVMDbgRecordRef LLVMDIBuilderInsertLabelBefore( - LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo, - LLVMMetadataRef Location, LLVMValueRef InsertBefore) { +LLVMDbgRecordRef LLVMDIBuilderInsertLabelBefore(LLVMDIBuilderRef Builder, + LLVMMetadataRef LabelInfo, + LLVMMetadataRef Location, + LLVMValueRef InsertBefore) { DbgInstPtr DbgInst = unwrap(Builder)->insertLabel( - unwrapDI<DILabel>(LabelInfo), unwrapDI<DILocation>(Location), - unwrap<Instruction>(InsertBefore)); + unwrapDI<DILabel>(LabelInfo), unwrapDI<DILocation>(Location), + InsertBefore + ? InsertPosition(unwrap<Instruction>(InsertBefore)->getIterator()) + : nullptr); // This assert will fail if the module is in the old debug info format. // This function should only be called if the module is in the new // debug info format. @@ -1829,12 +1837,13 @@ LLVMDbgRecordRef LLVMDIBuilderInsertLabelBefore( return wrap(cast<DbgRecord *>(DbgInst)); } -LLVMDbgRecordRef LLVMDIBuilderInsertLabelAtEnd( - LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo, - LLVMMetadataRef Location, LLVMBasicBlockRef InsertAtEnd) { +LLVMDbgRecordRef LLVMDIBuilderInsertLabelAtEnd(LLVMDIBuilderRef Builder, + LLVMMetadataRef LabelInfo, + LLVMMetadataRef Location, + LLVMBasicBlockRef InsertAtEnd) { DbgInstPtr DbgInst = unwrap(Builder)->insertLabel( - unwrapDI<DILabel>(LabelInfo), unwrapDI<DILocation>(Location), - unwrap(InsertAtEnd)); + unwrapDI<DILabel>(LabelInfo), unwrapDI<DILocation>(Location), + InsertAtEnd ? InsertPosition(unwrap(InsertAtEnd)->end()) : nullptr); // This assert will fail if the module is in the old debug info format. // This function should only be called if the module is in the new // debug info format. |