-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[RemoveDIs] Update DIBuilder C API with DbgRecord functions [1/2] #84915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-debuginfo @llvm/pr-subscribers-llvm-ir Author: Orlando Cazalet-Hyams (OCHyams) ChangesFollow on from #84739, which updates the DIBuilder class. All the functions that have been added are temporary and will be deprecated in the future. The intention is that they'll help downstream projects adapt during the transition period. All the functions that have been added are temporary and will be deprecated in the future. The intention is that they'll help downstream projects adapt during the transition period.
The existing In the next patch, I'll swap them to call the debug records versions (new debug info format). Downstream users of this API can query and change the current format using the first two functions above, or can instead opt to temporarily use intrinsics or records explicitly. Patch is 27.49 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/84915.diff 11 Files Affected:
diff --git a/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c b/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
index a793e893524fe2..45b345a5e4f082 100644
--- a/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
+++ b/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
@@ -972,7 +972,7 @@ value llvm_dibuild_create_parameter_variable_bytecode(value *argv, int arg) {
value llvm_dibuild_insert_declare_before_native(value Builder, value Storage,
value VarInfo, value Expr,
value DebugLoc, value Instr) {
- LLVMValueRef Value = LLVMDIBuilderInsertDeclareBefore(
+ LLVMValueRef Value = LLVMDIBuilderInsertDeclareRecordBefore(
DIBuilder_val(Builder), Value_val(Storage), Metadata_val(VarInfo),
Metadata_val(Expr), Metadata_val(DebugLoc), Value_val(Instr));
return to_val(Value);
@@ -992,7 +992,7 @@ value llvm_dibuild_insert_declare_before_bytecode(value *argv, int arg) {
value llvm_dibuild_insert_declare_at_end_native(value Builder, value Storage,
value VarInfo, value Expr,
value DebugLoc, value Block) {
- LLVMValueRef Value = LLVMDIBuilderInsertDeclareAtEnd(
+ LLVMValueRef Value = LLVMDIBuilderInsertDeclareRecordAtEnd(
DIBuilder_val(Builder), Value_val(Storage), Metadata_val(VarInfo),
Metadata_val(Expr), Metadata_val(DebugLoc), BasicBlock_val(Block));
return to_val(Value);
diff --git a/llvm/docs/RemoveDIsDebugInfo.md b/llvm/docs/RemoveDIsDebugInfo.md
index a0577678e20fcd..577c5fa5023a02 100644
--- a/llvm/docs/RemoveDIsDebugInfo.md
+++ b/llvm/docs/RemoveDIsDebugInfo.md
@@ -30,6 +30,27 @@ There are two significant changes to be aware of. Firstly, we're adding a single
The second matter is that if you transfer sequences of instructions from one place to another manually, i.e. repeatedly using `moveBefore` where you might have used `splice`, then you should instead use the method `moveBeforePreserving`. `moveBeforePreserving` will transfer debug info records with the instruction they're attached to. This is something that happens automatically today -- if you use `moveBefore` on every element of an instruction sequence, then debug intrinsics will be moved in the normal course of your code, but we lose this behaviour with non-instruction debug info.
+# C-API changes
+
+All the functions that have been added are temporary and will be deprecated in the future. The intention is that they'll help downstream projects adapt during the transition period.
+
+```
+New functions (all to be deprecated)
+------------------------------------
+LLVMIsNewDbgInfoFormat # Returns true if the module is in the new non-instruction mode.
+LLVMSetIsNewDbgInfoFormat # Convert to the requested debug info format.
+
+LLVMDIBuilderInsertDeclareIntrinsicBefore # Insert a debug intrinsic (old debug info format).
+LLVMDIBuilderInsertDeclareIntrinsicAtEnd # Same as above.
+LLVMDIBuilderInsertDbgValueIntrinsicBefore # Same as above.
+LLVMDIBuilderInsertDbgValueIntrinsicAtEnd # Same as above.
+
+LLVMDIBuilderInsertDeclareRecordBefore # Insert a debug record (new debug info format).
+LLVMDIBuilderInsertDeclareRecordAtEnd # Same as above.
+LLVMDIBuilderInsertDbgValueRecordBefore # Same as above.
+LLVMDIBuilderInsertDbgValueRecordAtEnd # Same as above.
+```
+
# Anything else?
Not really, but here's an "old vs new" comparison of how to do certain things and quickstart for how this "new" debug info is structured.
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index 7cfe4dc4f775fd..a8fa7b8fd038aa 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -744,6 +744,24 @@ LLVMModuleRef LLVMCloneModule(LLVMModuleRef M);
*/
void LLVMDisposeModule(LLVMModuleRef M);
+/**
+ * Soon to be deprecated.
+ * See See https://llvm.org/docs/RemoveDIsDebugInfo.html.
+ *
+ * Returns true if the module is in the new debug info mode which uses
+ * non-instruction debug records instead of debug intrinsics for variable
+ * location tracking.
+ */
+LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M);
+
+/**
+ * Soon to be deprecated.
+ * See See https://llvm.org/docs/RemoveDIsDebugInfo.html.
+ *
+ * Convert module into desired debug info format.
+ */
+void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M, LLVMBool UseNewFormat);
+
/**
* Obtain the identifier of a module.
*
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 5924294708cc35..d316d137011401 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -1248,7 +1248,24 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
LLVMMetadataRef Decl, uint32_t AlignInBits);
+/*
+ * Insert a new llvm.dbg.declare intrinsic call before the given instruction.
+ * \param Builder The DIBuilder.
+ * \param Storage The storage of the variable to declare.
+ * \param VarInfo The variable's debug info descriptor.
+ * \param Expr A complex location expression for the variable.
+ * \param DebugLoc Debug info location.
+ * \param Instr Instruction acting as a location for the new intrinsic.
+ */
+LLVMValueRef
+LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
+ LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
+ LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
+ * Soon to be deprecated.
+ * Only use in "old debug mode" (LLVMIsNewDbgFormat() is false).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html
+ *
* Insert a new llvm.dbg.declare intrinsic call before the given instruction.
* \param Builder The DIBuilder.
* \param Storage The storage of the variable to declare.
@@ -1257,9 +1274,25 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
* \param DebugLoc Debug info location.
* \param Instr Instruction acting as a location for the new intrinsic.
*/
-LLVMValueRef LLVMDIBuilderInsertDeclareBefore(
- LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
- LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
+LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore(
+ LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
+/**
+ * Soon to be deprecated.
+ * Only use in "new debug mode" (LLVMIsNewDbgFormat() is true).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html
+ *
+ * Insert a Declare DbgRecord before the given instruction.
+ * \param Builder The DIBuilder.
+ * \param Storage The storage of the variable to declare.
+ * \param VarInfo The variable's debug info descriptor.
+ * \param Expr A complex location expression for the variable.
+ * \param DebugLoc Debug info location.
+ * \param Instr Instruction acting as a location for the new record.
+ */
+LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
+ LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
* Insert a new llvm.dbg.declare intrinsic call at the end of the given basic
@@ -1275,6 +1308,42 @@ LLVMValueRef LLVMDIBuilderInsertDeclareBefore(
LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
+/**
+ * Soon to be deprecated.
+ * Only use in "old debug mode" (LLVMIsNewDbgFormat() is false).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html
+ *
+ * Insert a new llvm.dbg.declare intrinsic call at the end of the given basic
+ * block. If the basic block has a terminator instruction, the intrinsic is
+ * inserted before that terminator instruction.
+ * \param Builder The DIBuilder.
+ * \param Storage The storage of the variable to declare.
+ * \param VarInfo The variable's debug info descriptor.
+ * \param Expr A complex location expression for the variable.
+ * \param DebugLoc Debug info location.
+ * \param Block Basic block acting as a location for the new intrinsic.
+ */
+LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
+ LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
+/**
+ * Soon to be deprecated.
+ * Only use in "new debug mode" (LLVMIsNewDbgFormat() is true).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html
+ *
+ * Insert a Declare DbgRecord at the end of the given basic block. If the basic
+ * block has a terminator instruction, the record is inserted before that
+ * terminator instruction.
+ * \param Builder The DIBuilder.
+ * \param Storage The storage of the variable to declare.
+ * \param VarInfo The variable's debug info descriptor.
+ * \param Expr A complex location expression for the variable.
+ * \param DebugLoc Debug info location.
+ * \param Block Basic block acting as a location for the new record.
+ */
+LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
+ LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
* Insert a new llvm.dbg.value intrinsic call before the given instruction.
@@ -1285,14 +1354,65 @@ LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
* \param DebugLoc Debug info location.
* \param Instr Instruction acting as a location for the new intrinsic.
*/
-LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder,
- LLVMValueRef Val,
- LLVMMetadataRef VarInfo,
- LLVMMetadataRef Expr,
- LLVMMetadataRef DebugLoc,
- LLVMValueRef Instr);
-
+LLVMValueRef
+LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val,
+ LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
+ LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
+/**
+ * Soon to be deprecated.
+ * Only use in "old debug mode" (Module::IsNewDbgInfoFormat is false).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html
+ *
+ * Insert a new llvm.dbg.value intrinsic call before the given instruction.
+ * \param Builder The DIBuilder.
+ * \param Val The value of the variable.
+ * \param VarInfo The variable's debug info descriptor.
+ * \param Expr A complex location expression for the variable.
+ * \param DebugLoc Debug info location.
+ * \param Instr Instruction acting as a location for the new intrinsic.
+ */
+LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore(
+ LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
+/**
+ * Soon to be deprecated.
+ * Only use in "new debug mode" (Module::IsNewDbgInfoFormat is true).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html
+ *
+ * Insert a new llvm.dbg.value intrinsic call before the given instruction.
+ * \param Builder The DIBuilder.
+ * \param Val The value of the variable.
+ * \param VarInfo The variable's debug info descriptor.
+ * \param Expr A complex location expression for the variable.
+ * \param DebugLoc Debug info location.
+ * \param Instr Instruction acting as a location for the new intrinsic.
+ */
+LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
+ LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
+/**
+ * Soon to be deprecated.
+ * Only use in "old debug mode" (Module::IsNewDbgInfoFormat is false).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html
+ *
+ * Insert a new llvm.dbg.value intrinsic call at the end of the given basic
+ * block. If the basic block has a terminator instruction, the intrinsic is
+ * inserted before that terminator instruction.
+ * \param Builder The DIBuilder.
+ * \param Val The value of the variable.
+ * \param VarInfo The variable's debug info descriptor.
+ * \param Expr A complex location expression for the variable.
+ * \param DebugLoc Debug info location.
+ * \param Block Basic block acting as a location for the new intrinsic.
+ */
+LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(
+ LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
+ * Soon to be deprecated.
+ * Only use in "old debug mode" (Module::IsNewDbgInfoFormat is false).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html
+ *
* Insert a new llvm.dbg.value intrinsic call at the end of the given basic
* block. If the basic block has a terminator instruction, the intrinsic is
* inserted before that terminator instruction.
@@ -1303,12 +1423,27 @@ LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder,
* \param DebugLoc Debug info location.
* \param Block Basic block acting as a location for the new intrinsic.
*/
-LLVMValueRef LLVMDIBuilderInsertDbgValueAtEnd(LLVMDIBuilderRef Builder,
- LLVMValueRef Val,
- LLVMMetadataRef VarInfo,
- LLVMMetadataRef Expr,
- LLVMMetadataRef DebugLoc,
- LLVMBasicBlockRef Block);
+LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
+ LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
+/**
+ * Soon to be deprecated.
+ * Only use in "new debug mode" (Module::IsNewDbgInfoFormat is true).
+ * See https://llvm.org/docs/RemoveDIsDebugInfo.html
+ *
+ * Insert a new llvm.dbg.value intrinsic call at the end of the given basic
+ * block. If the basic block has a terminator instruction, the intrinsic is
+ * inserted before that terminator instruction.
+ * \param Builder The DIBuilder.
+ * \param Val The value of the variable.
+ * \param VarInfo The variable's debug info descriptor.
+ * \param Expr A complex location expression for the variable.
+ * \param DebugLoc Debug info location.
+ * \param Block Basic block acting as a location for the new intrinsic.
+ */
+LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(
+ LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
* Create a new descriptor for a local auto variable.
diff --git a/llvm/include/llvm-c/Types.h b/llvm/include/llvm-c/Types.h
index d5474d986309fa..4681500ef9da3d 100644
--- a/llvm/include/llvm-c/Types.h
+++ b/llvm/include/llvm-c/Types.h
@@ -169,6 +169,11 @@ typedef struct LLVMOpaqueJITEventListener *LLVMJITEventListenerRef;
*/
typedef struct LLVMOpaqueBinary *LLVMBinaryRef;
+/**
+ * @see llvm::DbgRecord
+ */
+typedef struct LLVMOpaqueDbgRecord *LLVMDbgRecordRef;
+
/**
* @}
*/
diff --git a/llvm/include/llvm/IR/DebugProgramInstruction.h b/llvm/include/llvm/IR/DebugProgramInstruction.h
index a8faf415a3ea87..960489dc52b12a 100644
--- a/llvm/include/llvm/IR/DebugProgramInstruction.h
+++ b/llvm/include/llvm/IR/DebugProgramInstruction.h
@@ -643,6 +643,8 @@ getDbgValueRange(DPMarker *DbgMarker) {
return DbgMarker->getDbgValueRange();
}
+DEFINE_ISA_CONVERSION_FUNCTIONS(DbgRecord, LLVMDbgRecordRef);
+
} // namespace llvm
#endif // LLVM_IR_DEBUGPROGRAMINSTRUCTION_H
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 4b804a41a1676f..aacb163a0d4f09 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -404,6 +404,14 @@ void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior,
{Key, KeyLen}, unwrap(Val));
}
+LLVMBool LLVMIsNewDbgInfoFormat(LLVMModuleRef M) {
+ return unwrap(M)->IsNewDbgInfoFormat;
+}
+
+void LLVMSetIsNewDbgInfoFormat(LLVMModuleRef M, LLVMBool UseNewFormat) {
+ unwrap(M)->setIsNewDbgInfoFormat(UseNewFormat);
+}
+
/*--.. Printing modules ....................................................--*/
void LLVMDumpModule(LLVMModuleRef M) {
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 68fd244e256974..6559d62d570f53 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1663,6 +1663,12 @@ LLVMValueRef
LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
LLVMMetadataRef DL, LLVMValueRef Instr) {
+ return LLVMDIBuilderInsertDeclareIntrinsicBefore(Builder, Storage, VarInfo,
+ Expr, DL, Instr);
+}
+LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore(
+ LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMValueRef Instr) {
DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
@@ -1671,11 +1677,27 @@ LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
"Inserted a DbgRecord into function using old debug info mode");
return wrap(cast<Instruction *>(DbgInst));
}
+LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
+ LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMValueRef Instr) {
+ return wrap(
+ unwrap(Builder)
+ ->insertDeclare(unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
+ unwrap<DIExpression>(Expr), unwrap<DILocation>(DL),
+ unwrap<Instruction>(Instr))
+ .get<DbgRecord *>());
+}
LLVMValueRef
LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
+ return LLVMDIBuilderInsertDeclareIntrinsicAtEnd(Builder, Storage, VarInfo,
+ Expr, DL, Block);
+}
+LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
+ LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
DbgInstPtr DbgInst = unwrap(Builder)->insertDeclare(
unwrap(Storage), unwrap<DILocalVariable>(VarInfo),
unwrap<DIExpression>(Expr), unwrap<DILocation>(DL), unwrap(Block));
@@ -1683,10 +1705,26 @@ LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
"Inserted a DbgRecord into function using old debug info mode");
return wrap(cast<Instruction *>(DbgInst));
}
+LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
+ LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
+ LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
+ return wrap(unwrap(Builder)
+ ->insertDeclare(unwrap(Storage),
+ unwrap<DILocalVariable>(VarInfo),
+ unwrap<DIExpression>(Expr),
+ unwrap<DILocation>(DL), unwrap(Block))
+ .get<DbgRecord *>());
+}
LLVMValueRef LLVMDIBuilderInsertDbgValueBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) {
+ return LLVMDIBuilderInsertDbgValueIntrinsicBefore(Builder, Val, VarInfo, Expr,
+ DebugLoc, Instr);
+}
+LLVMValue...
[truncated]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code largely looks fine to me, just a couple inline comments - and of course it'd be good to have approval from people who consume this API!
llvm/include/llvm-c/Core.h
Outdated
@@ -744,6 +744,24 @@ LLVMModuleRef LLVMCloneModule(LLVMModuleRef M); | |||
*/ | |||
void LLVMDisposeModule(LLVMModuleRef M); | |||
|
|||
/** | |||
* Soon to be deprecated. | |||
* See See https://llvm.org/docs/RemoveDIsDebugInfo.html. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* See See https://llvm.org/docs/RemoveDIsDebugInfo.html. | |
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes |
Possible change here and below?
@@ -972,7 +972,7 @@ value llvm_dibuild_create_parameter_variable_bytecode(value *argv, int arg) { | |||
value llvm_dibuild_insert_declare_before_native(value Builder, value Storage, | |||
value VarInfo, value Expr, | |||
value DebugLoc, value Instr) { | |||
LLVMValueRef Value = LLVMDIBuilderInsertDeclareBefore( | |||
LLVMValueRef Value = LLVMDIBuilderInsertDeclareRecordBefore( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this stay as the base version, so that it transitions to inserting Records at the same time as the C-API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, mistakenly update here. Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't seem like any comments from consumers are likely, so LGTM.
Follow on from llvm#84915 which adds the DbgRecord function variants. Update the LLVMDIBuilderInsert... functions to insert DbgRecords instead of debug intrinsics. LLVMDIBuilderInsertDeclareBefore LLVMDIBuilderInsertDeclareAtEnd LLVMDIBuilderInsertDbgValueBefore LLVMDIBuilderInsertDbgValueAtEnd
…5657) Follow on from #84915 which adds the DbgRecord function variants. Update the LLVMDIBuilderInsert... functions to insert DbgRecords instead of debug intrinsics. LLVMDIBuilderInsertDeclareBefore LLVMDIBuilderInsertDeclareAtEnd LLVMDIBuilderInsertDbgValueBefore LLVMDIBuilderInsertDbgValueAtEnd Calling these functions will now cause an assertion if the module is in the wrong debug info format. They should only be used when the module is in "new debug format". Use LLVMIsNewDbgInfoFormat to query and LLVMSetIsNewDbgInfoFormat to change the debug info format of a module. Please see https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-change (RemoveDIsDebugInfo.md) for more info.
…vm#85657) Follow on from llvm#84915 which adds the DbgRecord function variants. Update the LLVMDIBuilderInsert... functions to insert DbgRecords instead of debug intrinsics. LLVMDIBuilderInsertDeclareBefore LLVMDIBuilderInsertDeclareAtEnd LLVMDIBuilderInsertDbgValueBefore LLVMDIBuilderInsertDbgValueAtEnd Calling these functions will now cause an assertion if the module is in the wrong debug info format. They should only be used when the module is in "new debug format". Use LLVMIsNewDbgInfoFormat to query and LLVMSetIsNewDbgInfoFormat to change the debug info format of a module. Please see https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-change (RemoveDIsDebugInfo.md) for more info.
…vm#85657) Follow on from llvm#84915 which adds the DbgRecord function variants. Update the LLVMDIBuilderInsert... functions to insert DbgRecords instead of debug intrinsics. LLVMDIBuilderInsertDeclareBefore LLVMDIBuilderInsertDeclareAtEnd LLVMDIBuilderInsertDbgValueBefore LLVMDIBuilderInsertDbgValueAtEnd Calling these functions will now cause an assertion if the module is in the wrong debug info format. They should only be used when the module is in "new debug format". Use LLVMIsNewDbgInfoFormat to query and LLVMSetIsNewDbgInfoFormat to change the debug info format of a module. Please see https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-change (RemoveDIsDebugInfo.md) for more info.
Follow on from #84915 which adds the DbgRecord function variants. The C API changes were reviewed in #85657. # C API Update the LLVMDIBuilderInsert... functions to insert DbgRecords instead of debug intrinsics. LLVMDIBuilderInsertDeclareBefore LLVMDIBuilderInsertDeclareAtEnd LLVMDIBuilderInsertDbgValueBefore LLVMDIBuilderInsertDbgValueAtEnd Calling these functions will now cause an assertion if the module is in the wrong debug info format. They should only be used when the module is in "new debug format". Use LLVMIsNewDbgInfoFormat to query and LLVMSetIsNewDbgInfoFormat to change the debug info format of a module. Please see https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-change (RemoveDIsDebugInfo.md) for more info. # OCaml bindings Add set_is_new_dbg_info_format and is_new_dbg_info_format to the OCaml bindings. These can be used to set and query the current debug info mode. These will eventually be removed, but are useful while we're transitioning between old and new debug info formats. Add string_of_lldbgrecord, like string_of_llvalue but prints DbgRecords. In test dbginfo.ml, unconditionally set the module debug info to the new mode and update CHECK lines to check for DbgRecords. Without this change the test crashes because it attempts to insert DbgRecords (new default behaviour of llvm_dibuild_insert_declare_...) into a module that is in the old debug info mode.
llvm#84915 llvm#85657 llvm#92417 (comment) As discussed by @nikic and @OCHyams: llvm#92417 (comment) > For the intrinsic-inserting functions, do you think we should: > > a) mark as deprecated but otherwise leave them alone for now. > b) mark as deprecated and change their behaviour so that they > do nothing and return nullptr. > c) outright delete them (it sounds like you're voting this one, > but just wanted to double check). This patch implements option (c).
The DIBuilder C API was changed to deal with DbgRecord functions: #84915 #85657 #92417 (comment) As discussed by @nikic and @OCHyams: #92417 (comment) > For the intrinsic-inserting functions, do you think we should: > > a) mark as deprecated but otherwise leave them alone for now. > b) mark as deprecated and change their behaviour so that they > do nothing and return nullptr. > c) outright delete them (it sounds like you're voting this one, > but just wanted to double check). This patch implements option (c).
Follow on from #84739, which updates the DIBuilder class.
All the functions that have been added are temporary and will be deprecated in the future. The intention is that they'll help downstream projects adapt during the transition period.
The existing
LLVMDIBuilderInsert...
functions call through to the intrinsic (old debug info format) currently.In the next patch, I'll swap them to call the debug records versions (new debug info format). Downstream users of this API can query and change the current format using the first two functions above, or can instead opt to temporarily use intrinsics or records explicitly.