Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions llvm/include/llvm-c/DebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,52 @@ LLVMMetadataRef LLVMInstructionGetDebugLoc(LLVMValueRef Inst);
*/
void LLVMInstructionSetDebugLoc(LLVMValueRef Inst, LLVMMetadataRef Loc);

/**
* Create a new descriptor for a label
*
* \param Builder The DIBuilder.
* \param Scope The scope to create the label in.
* \param Name Variable name.
* \param NameLen Length of variable name.
* \param File The file to create the label in.
* \param LineNo Line Number.
* \param AlwaysPreserve Preserve the label even if the optimizer wants to remove it.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed after the fact that this line is longer than 80 characters and that the rest of the lines in this file are 80 characters. I would make a change like this but I also don't want to run a pipeline right now for a simple comment change. Waiting for review then, if this is desired, I can add it in.

Suggested change
* \param AlwaysPreserve Preserve the label even if the optimizer wants to remove it.
* \param AlwaysPreserve Preserve the label regardless of optimization.

*
* @see llvm::DIBuilder::createLabel()
*/
LLVMMetadataRef LLVMDIBuilderCreateLabel(
LLVMDIBuilderRef Builder,
LLVMMetadataRef Context, const char *Name, size_t NameLen,
LLVMMetadataRef File, unsigned LineNo, LLVMBool AlwaysPreserve);

/**
* Insert a new llvm.dbg.label intrinsic call
*
* \param Builder The DIBuilder.
* \param LabelInfo The Label's debug info descriptor
* \param Location The debug info location
* \param InsertBefore Location for the new intrinsic.
*
* @see llvm::DIBuilder::insertLabel()
*/
LLVMDbgRecordRef LLVMDIBuilderInsertLabelBefore(
LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo,
LLVMMetadataRef Location, LLVMValueRef InsertBefore);

/**
* Insert a new llvm.dbg.label intrinsic call
*
* \param Builder The DIBuilder.
* \param LabelInfo The Label's debug info descriptor
* \param Location The debug info location
* \param InsertAtEnd Location for the new intrinsic.
*
* @see llvm::DIBuilder::insertLabel()
*/
LLVMDbgRecordRef LLVMDIBuilderInsertLabelAtEnd(
LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo,
LLVMMetadataRef Location, LLVMBasicBlockRef InsertAtEnd);

/**
* Obtain the enumerated type of a Metadata instance.
*
Expand Down
41 changes: 41 additions & 0 deletions llvm/lib/IR/DebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
Loading