[llvm] db394ed - [RemoveDIs] Update DIBuilder C API with DbgRecord functions. (#95535)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 18 00:39:41 PDT 2024
Author: Carlos Alberto Enciso
Date: 2024-06-18T08:39:36+01:00
New Revision: db394edf95e7e47e2a11c570d65a8f5005af7849
URL: https://github.com/llvm/llvm-project/commit/db394edf95e7e47e2a11c570d65a8f5005af7849
DIFF: https://github.com/llvm/llvm-project/commit/db394edf95e7e47e2a11c570d65a8f5005af7849.diff
LOG: [RemoveDIs] Update DIBuilder C API with DbgRecord functions. (#95535)
The DIBuilder C API was changed to deal with DbgRecord functions:
https://github.com/llvm/llvm-project/pull/84915
https://github.com/llvm/llvm-project/pull/85657
https://github.com/llvm/llvm-project/pull/92417#issuecomment-2120078326
As discussed by @nikic and @OCHyams:
https://github.com/llvm/llvm-project/pull/92417#issuecomment-2144505440
> 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).
Added:
Modified:
llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
llvm/docs/ReleaseNotes.rst
llvm/docs/RemoveDIsDebugInfo.md
llvm/include/llvm-c/DebugInfo.h
llvm/lib/IR/DebugInfo.cpp
llvm/test/Bindings/llvm-c/debug_info_new_format.ll
llvm/tools/llvm-c-test/debuginfo.c
llvm/tools/llvm-c-test/llvm-c-test.h
llvm/tools/llvm-c-test/main.c
Removed:
llvm/test/Bindings/llvm-c/debug_info.ll
################################################################################
diff --git a/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c b/llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
index fbe45c0c1e0b0..ba4a9cbde37a4 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) {
- LLVMDbgRecordRef Value = LLVMDIBuilderInsertDeclareBefore(
+ LLVMDbgRecordRef 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) {
- LLVMDbgRecordRef Value = LLVMDIBuilderInsertDeclareAtEnd(
+ LLVMDbgRecordRef 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/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 97f445d498dd0..82db968872ee1 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -220,7 +220,40 @@ Changes to the C API
* ``LLVMConstICmp``
* ``LLVMConstFCmp``
-* Added ``LLVMPositionBuilderBeforeDbgRecords`` and ``LLVMPositionBuilderBeforeInstrAndDbgRecords``. Same as ``LLVMPositionBuilder`` and ``LLVMPositionBuilderBefore`` except the insertion position is set to before the debug records that precede the target instruction. See the `debug info migration guide <https://llvm.org/docs/RemoveDIsDebugInfo.html>`_ for more info. ``LLVMPositionBuilder`` and ``LLVMPositionBuilderBefore`` are unchanged; they insert before the indicated instruction but after any attached debug records.
+**Note:** The following changes are due to the removal of the debug info
+intrinsics from LLVM and to the introduction of debug records into LLVM.
+They are described in detail in the `debug info migration guide <https://llvm.org/docs/RemoveDIsDebugInfo.html>`_.
+
+* Added the following functions to insert before the indicated instruction but
+ after any attached debug records.
+
+ * ``LLVMPositionBuilderBeforeDbgRecords``
+ * ``LLVMPositionBuilderBeforeInstrAndDbgRecords``
+
+ Same as ``LLVMPositionBuilder`` and ``LLVMPositionBuilderBefore`` except the
+ insertion position is set to before the debug records that precede the target
+ instruction. ``LLVMPositionBuilder`` and ``LLVMPositionBuilderBefore`` are
+ unchanged.
+
+* Added the following functions to get/set the new non-instruction debug info format.
+ They will be deprecated in the future and they are just a transition aid.
+
+ * ``LLVMIsNewDbgInfoFormat``
+ * ``LLVMSetIsNewDbgInfoFormat``
+
+* Added the following functions to insert a debug record (new debug info format).
+
+ * ``LLVMDIBuilderInsertDeclareRecordBefore``
+ * ``LLVMDIBuilderInsertDeclareRecordAtEnd``
+ * ``LLVMDIBuilderInsertDbgValueRecordBefore``
+ * ``LLVMDIBuilderInsertDbgValueRecordAtEnd``
+
+* Deleted the following functions that inserted a debug intrinsic (old debug info format).
+
+ * ``LLVMDIBuilderInsertDeclareBefore``
+ * ``LLVMDIBuilderInsertDeclareAtEnd``
+ * ``LLVMDIBuilderInsertDbgValueBefore``
+ * ``LLVMDIBuilderInsertDbgValueAtEnd``
Changes to the CodeGen infrastructure
-------------------------------------
diff --git a/llvm/docs/RemoveDIsDebugInfo.md b/llvm/docs/RemoveDIsDebugInfo.md
index 56634f7ccc6bd..33c590e780079 100644
--- a/llvm/docs/RemoveDIsDebugInfo.md
+++ b/llvm/docs/RemoveDIsDebugInfo.md
@@ -140,34 +140,31 @@ Any tests downstream of the main LLVM repo that test the IR output of LLVM may b
Some new 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.
-
-Existing functions (behaviour change)
--------------------------------------
+Deleted functions
+-----------------
LLVMDIBuilderInsertDeclareBefore # Insert a debug record (new debug info format) instead of a debug intrinsic (old debug info format).
LLVMDIBuilderInsertDeclareAtEnd # Same as above.
LLVMDIBuilderInsertDbgValueBefore # Same as above.
LLVMDIBuilderInsertDbgValueAtEnd # Same as above.
+New functions (to be deprecated)
+--------------------------------
+LLVMIsNewDbgInfoFormat # Returns true if the module is in the new non-instruction mode.
+LLVMSetIsNewDbgInfoFormat # Convert to the requested debug info format.
+
New functions (no plans to deprecate)
-----------------------------------
+-------------------------------------
+LLVMDIBuilderInsertDeclareRecordBefore # Insert a debug record (new debug info format).
+LLVMDIBuilderInsertDeclareRecordAtEnd # Same as above. See info below.
+LLVMDIBuilderInsertDbgValueRecordBefore # Same as above. See info below.
+LLVMDIBuilderInsertDbgValueRecordAtEnd # Same as above. See info below.
+
LLVMPositionBuilderBeforeDbgRecords # See info below.
LLVMPositionBuilderBeforeInstrAndDbgRecords # See info below.
```
+`LLVMDIBuilderInsertDeclareRecordBefore`, `LLVMDIBuilderInsertDeclareRecordAtEnd`, `LLVMDIBuilderInsertDbgValueRecordBefore` and `LLVMDIBuilderInsertDbgValueRecordAtEnd` are replacing the deleted `LLVMDIBuilderInsertDeclareBefore-style` functions.
+
`LLVMPositionBuilderBeforeDbgRecords` and `LLVMPositionBuilderBeforeInstrAndDbgRecords` behave the same as `LLVMPositionBuilder` and `LLVMPositionBuilderBefore` except the insertion position is set before the debug records that precede the target instruction. Note that this doesn't mean that debug intrinsics before the chosen instruction are skipped, only debug records (which unlike debug records are not themselves instructions).
If you don't know which function to call then follow this rule:
diff --git a/llvm/include/llvm-c/DebugInfo.h b/llvm/include/llvm-c/DebugInfo.h
index 2c3c75e246c00..6d8891e705772 100644
--- a/llvm/include/llvm-c/DebugInfo.h
+++ b/llvm/include/llvm-c/DebugInfo.h
@@ -1261,44 +1261,12 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
LLVMMetadataRef Decl, uint32_t AlignInBits);
-/*
- * Insert a new Declare DbgRecord before the given instruction.
- *
- * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
- * Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
- * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
- *
- * \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.
- */
-LLVMDbgRecordRef
-LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
- LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
- LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
- * Soon to be deprecated.
- * Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
+ * Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
- * 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 LLVMDIBuilderInsertDeclareIntrinsicBefore(
- LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
- LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
-/**
- * Soon to be deprecated.
- * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
- * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ * The debug format can be switched later after inserting the records using
+ * LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
*
* Insert a Declare DbgRecord before the given instruction.
* \param Builder The DIBuilder.
@@ -1313,46 +1281,11 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
- * Insert a new Declare DbgRecord at the end of the given basic block. If the
- * basic block has a terminator instruction, the intrinsic is inserted before
- * that terminator instruction.
- *
- * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
- * Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
- * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
- *
- * \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.
- */
-LLVMDbgRecordRef LLVMDIBuilderInsertDeclareAtEnd(
- LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
- LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
-/**
- * Soon to be deprecated.
- * Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
+ * Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
- * 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" (LLVMIsNewDbgInfoFormat() is true).
- * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ * The debug format can be switched later after inserting the records using
+ * LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
*
* 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
@@ -1369,107 +1302,40 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
/**
- * Insert a new Value DbgRecord before the given instruction.
- *
- * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
- * Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
- * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
- *
- * \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
-LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val,
- LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
- LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
-/**
- * Soon to be deprecated.
- * Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
+ * Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
- * 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" (LLVMIsNewDbgInfoFormat() is true).
- * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ * The debug format can be switched later after inserting the records using
+ * LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
*
- * Insert a new llvm.dbg.value intrinsic call before the given instruction.
+ * Insert a new debug record 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.
+ * \param Instr Instruction acting as a location for the new record.
*/
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
/**
- * Insert a new Value DbgRecord at the end of the given basic block. If the
- * basic block has a terminator instruction, the intrinsic is inserted before
- * that terminator instruction.
- *
- * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
- * Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
- * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
- *
- * \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 LLVMDIBuilderInsertDbgValueAtEnd(
- LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
- LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
-/**
- * Soon to be deprecated.
- * Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
+ * Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
*
- * 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 LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
- LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
- LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
-/**
- * Soon to be deprecated.
- * Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
- * See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
+ * The debug format can be switched later after inserting the records using
+ * LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
*
- * 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.
+ * Insert a new debug record 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 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.
+ * \param Block Basic block acting as a location for the new record.
*/
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 228e17641ffc4..e57c3fe8c825d 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -1662,29 +1662,6 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
unwrapDI<MDNode>(Decl), nullptr, AlignInBits));
}
-LLVMDbgRecordRef
-LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
- LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
- LLVMMetadataRef DL, LLVMValueRef Instr) {
- return LLVMDIBuilderInsertDeclareRecordBefore(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),
- unwrap<Instruction>(Instr));
- // This assert will fail if the module is in the new debug info format.
- // This function should only be called if the module is in the old
- // debug info format.
- // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
- // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
- assert(isa<Instruction *>(DbgInst) &&
- "Function unexpectedly in new debug info format");
- return wrap(cast<Instruction *>(DbgInst));
-}
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMValueRef Instr) {
@@ -1702,28 +1679,6 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
return wrap(cast<DbgRecord *>(DbgInst));
}
-LLVMDbgRecordRef
-LLVMDIBuilderInsertDeclareAtEnd(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
- LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
- LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
- return LLVMDIBuilderInsertDeclareRecordAtEnd(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));
- // This assert will fail if the module is in the new debug info format.
- // This function should only be called if the module is in the old
- // debug info format.
- // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
- // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
- assert(isa<Instruction *>(DbgInst) &&
- "Function unexpectedly in new debug info format");
- return wrap(cast<Instruction *>(DbgInst));
-}
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block) {
@@ -1740,27 +1695,6 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
return wrap(cast<DbgRecord *>(DbgInst));
}
-LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueBefore(
- LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
- LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) {
- return LLVMDIBuilderInsertDbgValueRecordBefore(Builder, Val, VarInfo, Expr,
- DebugLoc, Instr);
-}
-LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore(
- LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
- 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));
- // This assert will fail if the module is in the new debug info format.
- // This function should only be called if the module is in the old
- // debug info format.
- // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
- // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
- assert(isa<Instruction *>(DbgInst) &&
- "Function unexpectedly in new debug info format");
- return wrap(cast<Instruction *>(DbgInst));
-}
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr) {
@@ -1777,27 +1711,6 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
return wrap(cast<DbgRecord *>(DbgInst));
}
-LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueAtEnd(
- LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
- LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
- return LLVMDIBuilderInsertDbgValueRecordAtEnd(Builder, Val, VarInfo, Expr,
- DebugLoc, Block);
-}
-LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
- LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
- LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
- DbgInstPtr DbgInst = unwrap(Builder)->insertDbgValueIntrinsic(
- unwrap(Val), unwrap<DILocalVariable>(VarInfo), unwrap<DIExpression>(Expr),
- unwrap<DILocation>(DebugLoc), unwrap(Block));
- // This assert will fail if the module is in the new debug info format.
- // This function should only be called if the module is in the old
- // debug info format.
- // See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes,
- // LLVMIsNewDbgInfoFormat, and LLVMSetIsNewDbgInfoFormat for more info.
- assert(isa<Instruction *>(DbgInst) &&
- "Function unexpectedly in new debug info format");
- return wrap(cast<Instruction *>(DbgInst));
-}
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block) {
diff --git a/llvm/test/Bindings/llvm-c/debug_info.ll b/llvm/test/Bindings/llvm-c/debug_info.ll
deleted file mode 100644
index 71986fbb2348f..0000000000000
--- a/llvm/test/Bindings/llvm-c/debug_info.ll
+++ /dev/null
@@ -1,76 +0,0 @@
-; RUN: llvm-c-test --test-dibuilder-old-debuginfo-format | FileCheck %s
-
-; CHECK: ; ModuleID = 'debuginfo.c'
-; CHECK-NEXT: source_filename = "debuginfo.c"
-
-; CHECK: define i64 @foo(i64 %0, i64 %1, <10 x i64> %2) !dbg !31 {
-; CHECK-NEXT: entry:
-; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !38, metadata !DIExpression()), !dbg !43
-; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !39, metadata !DIExpression()), !dbg !43
-; CHECK-NEXT: call void @llvm.dbg.declare(metadata i64 0, metadata !40, metadata !DIExpression()), !dbg !43
-; CHECK-NEXT: br label %vars
-; CHECK: vars:
-; CHECK-NEXT: %p1 = phi i64 [ 0, %entry ]
-; CHECK-NEXT: %p2 = phi i64 [ 0, %entry ]
-; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 0, metadata !41, metadata !DIExpression(DW_OP_constu, 0, DW_OP_stack_value)), !dbg !44
-; CHECK-NEXT: %a = add i64 %p1, %p2
-; CHECK-NEXT: ret i64 0
-; CHECK-NEXT: }
-
-; CHECK: ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
-; CHECK-NEXT: declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
-
-; CHECK: ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
-; CHECK-NEXT: declare void @llvm.dbg.value(metadata, metadata, metadata) #0
-
-; CHECK: attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
-
-; CHECK: !llvm.dbg.cu = !{!0}
-; CHECK-NEXT: !FooType = !{!28}
-; CHECK-NEXT: !EnumTest = !{!3}
-
-; CHECK: !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "llvm-c-test", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !11, imports: !19, macros: !23, splitDebugInlining: false, sysroot: "/")
-; CHECK-NEXT: !1 = !DIFile(filename: "debuginfo.c", directory: ".")
-; CHECK-NEXT: !2 = !{!3}
-; CHECK-NEXT: !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "EnumTest", scope: !4, file: !1, baseType: !6, size: 64, elements: !7)
-; CHECK-NEXT: !4 = !DINamespace(name: "NameSpace", scope: !5)
-; CHECK-NEXT: !5 = !DIModule(scope: null, name: "llvm-c-test", includePath: "/test/include/llvm-c-test.h")
-; CHECK-NEXT: !6 = !DIBasicType(name: "Int64", size: 64)
-; CHECK-NEXT: !7 = !{!8, !9, !10}
-; CHECK-NEXT: !8 = !DIEnumerator(name: "Test_A", value: 0, isUnsigned: true)
-; CHECK-NEXT: !9 = !DIEnumerator(name: "Test_B", value: 1, isUnsigned: true)
-; CHECK-NEXT: !10 = !DIEnumerator(name: "Test_B", value: 2, isUnsigned: true)
-; CHECK-NEXT: !11 = !{!12, !16}
-; CHECK-NEXT: !12 = !DIGlobalVariableExpression(var: !13, expr: !DIExpression(DW_OP_constu, 0, DW_OP_stack_value))
-; CHECK-NEXT: !13 = distinct !DIGlobalVariable(name: "globalClass", scope: !5, file: !1, line: 1, type: !14, isLocal: true, isDefinition: true)
-; CHECK-NEXT: !14 = !DICompositeType(tag: DW_TAG_structure_type, name: "TestClass", scope: !1, file: !1, line: 42, size: 64, flags: DIFlagObjcClassComplete, elements: !15)
-; CHECK-NEXT: !15 = !{}
-; CHECK-NEXT: !16 = !DIGlobalVariableExpression(var: !17, expr: !DIExpression(DW_OP_constu, 0, DW_OP_stack_value))
-; CHECK-NEXT: !17 = distinct !DIGlobalVariable(name: "global", scope: !5, file: !1, line: 1, type: !18, isLocal: true, isDefinition: true)
-; CHECK-NEXT: !18 = !DIDerivedType(tag: DW_TAG_typedef, name: "int64_t", scope: !1, file: !1, line: 42, baseType: !6)
-; CHECK-NEXT: !19 = !{!20, !22}
-; CHECK-NEXT: !20 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !5, entity: !21, file: !1, line: 42)
-; CHECK-NEXT: !21 = !DIModule(scope: null, name: "llvm-c-test-import", includePath: "/test/include/llvm-c-test-import.h")
-; CHECK-NEXT: !22 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !5, entity: !20, file: !1, line: 42)
-; CHECK-NEXT: !23 = !{!24}
-; CHECK-NEXT: !24 = !DIMacroFile(file: !1, nodes: !25)
-; CHECK-NEXT: !25 = !{!26, !27}
-; CHECK-NEXT: !26 = !DIMacro(type: DW_MACINFO_define, name: "SIMPLE_DEFINE")
-; CHECK-NEXT: !27 = !DIMacro(type: DW_MACINFO_define, name: "VALUE_DEFINE", value: "1")
-; CHECK-NEXT: !28 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !29, size: 192, dwarfAddressSpace: 0)
-; CHECK-NEXT: !29 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyStruct", scope: !4, file: !1, size: 192, elements: !30, runtimeLang: DW_LANG_C89, identifier: "MyStruct")
-; CHECK-NEXT: !30 = !{!6, !6, !6}
-; CHECK-NEXT: !31 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: !1, file: !1, line: 42, type: !32, scopeLine: 42, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !37)
-; CHECK-NEXT: !32 = !DISubroutineType(types: !33)
-; CHECK-NEXT: !33 = !{!6, !6, !34}
-; CHECK-NEXT: !34 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 640, flags: DIFlagVector, elements: !35)
-; CHECK-NEXT: !35 = !{!36}
-; CHECK-NEXT: !36 = !DISubrange(count: 10, lowerBound: 0)
-; CHECK-NEXT: !37 = !{!38, !39, !40, !41}
-; CHECK-NEXT: !38 = !DILocalVariable(name: "a", arg: 1, scope: !31, file: !1, line: 42, type: !6)
-; CHECK-NEXT: !39 = !DILocalVariable(name: "b", arg: 2, scope: !31, file: !1, line: 42, type: !6)
-; CHECK-NEXT: !40 = !DILocalVariable(name: "c", arg: 3, scope: !31, file: !1, line: 42, type: !34)
-; CHECK-NEXT: !41 = !DILocalVariable(name: "d", scope: !42, file: !1, line: 43, type: !6)
-; CHECK-NEXT: !42 = distinct !DILexicalBlock(scope: !31, file: !1, line: 42)
-; CHECK-NEXT: !43 = !DILocation(line: 42, scope: !31)
-; CHECK-NEXT: !44 = !DILocation(line: 43, scope: !31)
diff --git a/llvm/test/Bindings/llvm-c/debug_info_new_format.ll b/llvm/test/Bindings/llvm-c/debug_info_new_format.ll
index 1b6f2c4ea403a..a9ba9d7ad05a7 100644
--- a/llvm/test/Bindings/llvm-c/debug_info_new_format.ll
+++ b/llvm/test/Bindings/llvm-c/debug_info_new_format.ll
@@ -1,4 +1,4 @@
-; RUN: llvm-c-test --test-dibuilder-new-debuginfo-format | FileCheck %s
+; RUN: llvm-c-test --test-dibuilder-debuginfo-format | FileCheck %s
;; Duplicate of debug_info.ll using debug records instead of intrinsics.
; CHECK: ; ModuleID = 'debuginfo.c'
diff --git a/llvm/tools/llvm-c-test/debuginfo.c b/llvm/tools/llvm-c-test/debuginfo.c
index 032657203b5f2..5519cb076546d 100644
--- a/llvm/tools/llvm-c-test/debuginfo.c
+++ b/llvm/tools/llvm-c-test/debuginfo.c
@@ -29,10 +29,13 @@ declare_objc_class(LLVMDIBuilderRef DIB, LLVMMetadataRef File) {
return Decl;
}
-int llvm_test_dibuilder(bool NewDebugInfoFormat) {
+int llvm_test_dibuilder() {
const char *Filename = "debuginfo.c";
LLVMModuleRef M = LLVMModuleCreateWithName(Filename);
- LLVMSetIsNewDbgInfoFormat(M, NewDebugInfoFormat);
+
+ LLVMSetIsNewDbgInfoFormat(M, true);
+ assert(LLVMIsNewDbgInfoFormat(M));
+
LLVMDIBuilderRef DIB = LLVMCreateDIBuilder(M);
LLVMMetadataRef File = LLVMDIBuilderCreateFile(DIB, Filename,
@@ -137,38 +140,24 @@ int llvm_test_dibuilder(bool NewDebugInfoFormat) {
LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "a", 1, 1, File,
42, Int64Ty, true, 0);
- if (LLVMIsNewDbgInfoFormat(M))
- LLVMDIBuilderInsertDeclareAtEnd(
- DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar1,
- FooParamExpression, FooParamLocation, FooEntryBlock);
- else
- LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
- DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar1,
- FooParamExpression, FooParamLocation, FooEntryBlock);
+ LLVMDIBuilderInsertDeclareRecordAtEnd(
+ DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar1,
+ FooParamExpression, FooParamLocation, FooEntryBlock);
+
LLVMMetadataRef FooParamVar2 =
LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "b", 1, 2, File,
42, Int64Ty, true, 0);
- if (LLVMIsNewDbgInfoFormat(M))
- LLVMDIBuilderInsertDeclareAtEnd(
- DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar2,
- FooParamExpression, FooParamLocation, FooEntryBlock);
- else
- LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
- DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar2,
- FooParamExpression, FooParamLocation, FooEntryBlock);
-
- LLVMMetadataRef FooParamVar3 =
- LLVMDIBuilderCreateParameterVariable(DIB, FunctionMetadata, "c", 1, 3, File,
- 42, VectorTy, true, 0);
- if (LLVMIsNewDbgInfoFormat(M))
- LLVMDIBuilderInsertDeclareAtEnd(
- DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar3,
- FooParamExpression, FooParamLocation, FooEntryBlock);
- else
- LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
- DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar3,
- FooParamExpression, FooParamLocation, FooEntryBlock);
+ LLVMDIBuilderInsertDeclareRecordAtEnd(
+ DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar2,
+ FooParamExpression, FooParamLocation, FooEntryBlock);
+
+ LLVMMetadataRef FooParamVar3 = LLVMDIBuilderCreateParameterVariable(
+ DIB, FunctionMetadata, "c", 1, 3, File, 42, VectorTy, true, 0);
+
+ LLVMDIBuilderInsertDeclareRecordAtEnd(
+ DIB, LLVMConstInt(LLVMInt64Type(), 0, false), FooParamVar3,
+ FooParamExpression, FooParamLocation, FooEntryBlock);
LLVMSetSubprogram(FooFunction, FunctionMetadata);
@@ -185,12 +174,9 @@ int llvm_test_dibuilder(bool NewDebugInfoFormat) {
LLVMValueRef FooVal1 = LLVMConstInt(LLVMInt64Type(), 0, false);
LLVMMetadataRef FooVarValueExpr =
LLVMDIBuilderCreateConstantValueExpression(DIB, 0);
- if (LLVMIsNewDbgInfoFormat(M))
- LLVMDIBuilderInsertDbgValueRecordAtEnd(
- DIB, FooVal1, FooVar1, FooVarValueExpr, FooVarsLocation, FooVarBlock);
- else
- LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
- DIB, FooVal1, FooVar1, FooVarValueExpr, FooVarsLocation, FooVarBlock);
+
+ LLVMDIBuilderInsertDbgValueRecordAtEnd(DIB, FooVal1, FooVar1, FooVarValueExpr,
+ FooVarsLocation, FooVarBlock);
LLVMMetadataRef MacroFile =
LLVMDIBuilderCreateTempMacroFile(DIB, NULL, 0, File);
diff --git a/llvm/tools/llvm-c-test/llvm-c-test.h b/llvm/tools/llvm-c-test/llvm-c-test.h
index c50d3cce86748..f477f17e9c3b0 100644
--- a/llvm/tools/llvm-c-test/llvm-c-test.h
+++ b/llvm/tools/llvm-c-test/llvm-c-test.h
@@ -36,7 +36,7 @@ int llvm_calc(void);
int llvm_disassemble(void);
// debuginfo.c
-int llvm_test_dibuilder(bool NewDebugInfoFormat);
+int llvm_test_dibuilder();
int llvm_get_di_tag(void);
int llvm_di_type_get_name(void);
diff --git a/llvm/tools/llvm-c-test/main.c b/llvm/tools/llvm-c-test/main.c
index 9db6e05d6350d..8be9ea06fc68d 100644
--- a/llvm/tools/llvm-c-test/main.c
+++ b/llvm/tools/llvm-c-test/main.c
@@ -110,11 +110,8 @@ int main(int argc, char **argv) {
} else if (argc == 2 && !strcmp(argv[1], "--test-diagnostic-handler")) {
return llvm_test_diagnostic_handler();
} else if (argc == 2 &&
- !strcmp(argv[1], "--test-dibuilder-old-debuginfo-format")) {
- return llvm_test_dibuilder(false);
- } else if (argc == 2 &&
- !strcmp(argv[1], "--test-dibuilder-new-debuginfo-format")) {
- return llvm_test_dibuilder(true);
+ !strcmp(argv[1], "--test-dibuilder-debuginfo-format")) {
+ return llvm_test_dibuilder();
} else {
print_usage();
}
More information about the llvm-commits
mailing list