aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authortf2spi <misomosispi@gmail.com>2024-10-28 13:59:53 -0400
committerGitHub <noreply@github.com>2024-10-28 10:59:53 -0700
commitf23bdbbaff5b89b1c102a155d062fc32f99d4a92 (patch)
tree57e3d82fd56009025aadd85c6c7dd2be9c3da732 /llvm/lib/IR/DebugInfo.cpp
parent4cf128512be5d7e41d8b8b5a12eec47a64af36ea (diff)
downloadllvm-f23bdbbaff5b89b1c102a155d062fc32f99d4a92.zip
llvm-f23bdbbaff5b89b1c102a155d062fc32f99d4a92.tar.gz
llvm-f23bdbbaff5b89b1c102a155d062fc32f99d4a92.tar.bz2
Add DILabel functions for LLVM-C (#112840)
Addresses #112799
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 50b29ae..e20a0f0 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1799,6 +1799,47 @@ 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) {
+ return wrap(unwrap(Builder)->createLabel(
+ unwrapDI<DIScope>(Context), StringRef(Name, NameLen),
+ unwrapDI<DIFile>(File), LineNo, AlwaysPreserve));
+}
+
+LLVMDbgRecordRef LLVMDIBuilderInsertLabelBefore(
+ LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo,
+ LLVMMetadataRef Location, LLVMValueRef InsertBefore) {
+ DbgInstPtr DbgInst = unwrap(Builder)->insertLabel(
+ unwrapDI<DILabel>(LabelInfo), unwrapDI<DILocation>(Location),
+ unwrap<Instruction>(InsertBefore));
+ // 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.
+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
+ // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
+ assert(isa<DbgRecord *>(DbgInst) &&
+ "Function unexpectedly in old debug info format");
+ return wrap(cast<DbgRecord *>(DbgInst));
+}
+
+LLVMDbgRecordRef LLVMDIBuilderInsertLabelAtEnd(
+ LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo,
+ LLVMMetadataRef Location, LLVMBasicBlockRef InsertAtEnd) {
+ DbgInstPtr DbgInst = unwrap(Builder)->insertLabel(
+ unwrapDI<DILabel>(LabelInfo), unwrapDI<DILocation>(Location),
+ unwrap(InsertAtEnd));
+ // 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.
+ // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
+ // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
+ assert(isa<DbgRecord *>(DbgInst) &&
+ "Function unexpectedly in old debug info format");
+ return wrap(cast<DbgRecord *>(DbgInst));
+}
+
LLVMMetadataKind LLVMGetMetadataKind(LLVMMetadataRef Metadata) {
switch(unwrap(Metadata)->getMetadataID()) {
#define HANDLE_METADATA_LEAF(CLASS) \