Skip to content

[RemoveDIs] Update DIBuilder C API with DbgRecord functions. #95535

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

Merged
merged 4 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
35 changes: 34 additions & 1 deletion llvm/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------------------------------
Expand Down
33 changes: 15 additions & 18 deletions llvm/docs/RemoveDIsDebugInfo.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
170 changes: 18 additions & 152 deletions llvm/include/llvm-c/DebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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,
Expand Down
Loading
Loading