Skip to content

Commit db394ed

Browse files
[RemoveDIs] Update DIBuilder C API with DbgRecord functions. (#95535)
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).
1 parent 3ca1744 commit db394ed

File tree

10 files changed

+95
-379
lines changed

10 files changed

+95
-379
lines changed

llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ value llvm_dibuild_create_parameter_variable_bytecode(value *argv, int arg) {
972972
value llvm_dibuild_insert_declare_before_native(value Builder, value Storage,
973973
value VarInfo, value Expr,
974974
value DebugLoc, value Instr) {
975-
LLVMDbgRecordRef Value = LLVMDIBuilderInsertDeclareBefore(
975+
LLVMDbgRecordRef Value = LLVMDIBuilderInsertDeclareRecordBefore(
976976
DIBuilder_val(Builder), Value_val(Storage), Metadata_val(VarInfo),
977977
Metadata_val(Expr), Metadata_val(DebugLoc), Value_val(Instr));
978978
return to_val(Value);
@@ -992,7 +992,7 @@ value llvm_dibuild_insert_declare_before_bytecode(value *argv, int arg) {
992992
value llvm_dibuild_insert_declare_at_end_native(value Builder, value Storage,
993993
value VarInfo, value Expr,
994994
value DebugLoc, value Block) {
995-
LLVMDbgRecordRef Value = LLVMDIBuilderInsertDeclareAtEnd(
995+
LLVMDbgRecordRef Value = LLVMDIBuilderInsertDeclareRecordAtEnd(
996996
DIBuilder_val(Builder), Value_val(Storage), Metadata_val(VarInfo),
997997
Metadata_val(Expr), Metadata_val(DebugLoc), BasicBlock_val(Block));
998998
return to_val(Value);

llvm/docs/ReleaseNotes.rst

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,40 @@ Changes to the C API
220220
* ``LLVMConstICmp``
221221
* ``LLVMConstFCmp``
222222

223-
* 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.
223+
**Note:** The following changes are due to the removal of the debug info
224+
intrinsics from LLVM and to the introduction of debug records into LLVM.
225+
They are described in detail in the `debug info migration guide <https://llvm.org/docs/RemoveDIsDebugInfo.html>`_.
226+
227+
* Added the following functions to insert before the indicated instruction but
228+
after any attached debug records.
229+
230+
* ``LLVMPositionBuilderBeforeDbgRecords``
231+
* ``LLVMPositionBuilderBeforeInstrAndDbgRecords``
232+
233+
Same as ``LLVMPositionBuilder`` and ``LLVMPositionBuilderBefore`` except the
234+
insertion position is set to before the debug records that precede the target
235+
instruction. ``LLVMPositionBuilder`` and ``LLVMPositionBuilderBefore`` are
236+
unchanged.
237+
238+
* Added the following functions to get/set the new non-instruction debug info format.
239+
They will be deprecated in the future and they are just a transition aid.
240+
241+
* ``LLVMIsNewDbgInfoFormat``
242+
* ``LLVMSetIsNewDbgInfoFormat``
243+
244+
* Added the following functions to insert a debug record (new debug info format).
245+
246+
* ``LLVMDIBuilderInsertDeclareRecordBefore``
247+
* ``LLVMDIBuilderInsertDeclareRecordAtEnd``
248+
* ``LLVMDIBuilderInsertDbgValueRecordBefore``
249+
* ``LLVMDIBuilderInsertDbgValueRecordAtEnd``
250+
251+
* Deleted the following functions that inserted a debug intrinsic (old debug info format).
252+
253+
* ``LLVMDIBuilderInsertDeclareBefore``
254+
* ``LLVMDIBuilderInsertDeclareAtEnd``
255+
* ``LLVMDIBuilderInsertDbgValueBefore``
256+
* ``LLVMDIBuilderInsertDbgValueAtEnd``
224257

225258
Changes to the CodeGen infrastructure
226259
-------------------------------------

llvm/docs/RemoveDIsDebugInfo.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,34 +140,31 @@ Any tests downstream of the main LLVM repo that test the IR output of LLVM may b
140140
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.
141141
142142
```
143-
New functions (all to be deprecated)
144-
------------------------------------
145-
LLVMIsNewDbgInfoFormat # Returns true if the module is in the new non-instruction mode.
146-
LLVMSetIsNewDbgInfoFormat # Convert to the requested debug info format.
147-
148-
LLVMDIBuilderInsertDeclareIntrinsicBefore # Insert a debug intrinsic (old debug info format).
149-
LLVMDIBuilderInsertDeclareIntrinsicAtEnd # Same as above.
150-
LLVMDIBuilderInsertDbgValueIntrinsicBefore # Same as above.
151-
LLVMDIBuilderInsertDbgValueIntrinsicAtEnd # Same as above.
152-
153-
LLVMDIBuilderInsertDeclareRecordBefore # Insert a debug record (new debug info format).
154-
LLVMDIBuilderInsertDeclareRecordAtEnd # Same as above.
155-
LLVMDIBuilderInsertDbgValueRecordBefore # Same as above.
156-
LLVMDIBuilderInsertDbgValueRecordAtEnd # Same as above.
157-
158-
Existing functions (behaviour change)
159-
-------------------------------------
143+
Deleted functions
144+
-----------------
160145
LLVMDIBuilderInsertDeclareBefore # Insert a debug record (new debug info format) instead of a debug intrinsic (old debug info format).
161146
LLVMDIBuilderInsertDeclareAtEnd # Same as above.
162147
LLVMDIBuilderInsertDbgValueBefore # Same as above.
163148
LLVMDIBuilderInsertDbgValueAtEnd # Same as above.
164149

150+
New functions (to be deprecated)
151+
--------------------------------
152+
LLVMIsNewDbgInfoFormat # Returns true if the module is in the new non-instruction mode.
153+
LLVMSetIsNewDbgInfoFormat # Convert to the requested debug info format.
154+
165155
New functions (no plans to deprecate)
166-
----------------------------------
156+
-------------------------------------
157+
LLVMDIBuilderInsertDeclareRecordBefore # Insert a debug record (new debug info format).
158+
LLVMDIBuilderInsertDeclareRecordAtEnd # Same as above. See info below.
159+
LLVMDIBuilderInsertDbgValueRecordBefore # Same as above. See info below.
160+
LLVMDIBuilderInsertDbgValueRecordAtEnd # Same as above. See info below.
161+
167162
LLVMPositionBuilderBeforeDbgRecords # See info below.
168163
LLVMPositionBuilderBeforeInstrAndDbgRecords # See info below.
169164
```
170165
166+
`LLVMDIBuilderInsertDeclareRecordBefore`, `LLVMDIBuilderInsertDeclareRecordAtEnd`, `LLVMDIBuilderInsertDbgValueRecordBefore` and `LLVMDIBuilderInsertDbgValueRecordAtEnd` are replacing the deleted `LLVMDIBuilderInsertDeclareBefore-style` functions.
167+
171168
`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).
172169
173170
If you don't know which function to call then follow this rule:

llvm/include/llvm-c/DebugInfo.h

Lines changed: 18 additions & 152 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,44 +1261,12 @@ LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl(
12611261
unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit,
12621262
LLVMMetadataRef Decl, uint32_t AlignInBits);
12631263

1264-
/*
1265-
* Insert a new Declare DbgRecord before the given instruction.
1266-
*
1267-
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
1268-
* Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
1269-
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
1270-
*
1271-
* \param Builder The DIBuilder.
1272-
* \param Storage The storage of the variable to declare.
1273-
* \param VarInfo The variable's debug info descriptor.
1274-
* \param Expr A complex location expression for the variable.
1275-
* \param DebugLoc Debug info location.
1276-
* \param Instr Instruction acting as a location for the new intrinsic.
1277-
*/
1278-
LLVMDbgRecordRef
1279-
LLVMDIBuilderInsertDeclareBefore(LLVMDIBuilderRef Builder, LLVMValueRef Storage,
1280-
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
1281-
LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
12821264
/**
1283-
* Soon to be deprecated.
1284-
* Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
1265+
* Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
12851266
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
12861267
*
1287-
* Insert a new llvm.dbg.declare intrinsic call before the given instruction.
1288-
* \param Builder The DIBuilder.
1289-
* \param Storage The storage of the variable to declare.
1290-
* \param VarInfo The variable's debug info descriptor.
1291-
* \param Expr A complex location expression for the variable.
1292-
* \param DebugLoc Debug info location.
1293-
* \param Instr Instruction acting as a location for the new intrinsic.
1294-
*/
1295-
LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicBefore(
1296-
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
1297-
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
1298-
/**
1299-
* Soon to be deprecated.
1300-
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
1301-
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
1268+
* The debug format can be switched later after inserting the records using
1269+
* LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
13021270
*
13031271
* Insert a Declare DbgRecord before the given instruction.
13041272
* \param Builder The DIBuilder.
@@ -1313,46 +1281,11 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
13131281
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
13141282

13151283
/**
1316-
* Insert a new Declare DbgRecord at the end of the given basic block. If the
1317-
* basic block has a terminator instruction, the intrinsic is inserted before
1318-
* that terminator instruction.
1319-
*
1320-
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
1321-
* Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
1322-
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
1323-
*
1324-
* \param Builder The DIBuilder.
1325-
* \param Storage The storage of the variable to declare.
1326-
* \param VarInfo The variable's debug info descriptor.
1327-
* \param Expr A complex location expression for the variable.
1328-
* \param DebugLoc Debug info location.
1329-
* \param Block Basic block acting as a location for the new intrinsic.
1330-
*/
1331-
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareAtEnd(
1332-
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
1333-
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
1334-
/**
1335-
* Soon to be deprecated.
1336-
* Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
1284+
* Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
13371285
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
13381286
*
1339-
* Insert a new llvm.dbg.declare intrinsic call at the end of the given basic
1340-
* block. If the basic block has a terminator instruction, the intrinsic is
1341-
* inserted before that terminator instruction.
1342-
* \param Builder The DIBuilder.
1343-
* \param Storage The storage of the variable to declare.
1344-
* \param VarInfo The variable's debug info descriptor.
1345-
* \param Expr A complex location expression for the variable.
1346-
* \param DebugLoc Debug info location.
1347-
* \param Block Basic block acting as a location for the new intrinsic.
1348-
*/
1349-
LLVMValueRef LLVMDIBuilderInsertDeclareIntrinsicAtEnd(
1350-
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
1351-
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
1352-
/**
1353-
* Soon to be deprecated.
1354-
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
1355-
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
1287+
* The debug format can be switched later after inserting the records using
1288+
* LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
13561289
*
13571290
* Insert a Declare DbgRecord at the end of the given basic block. If the basic
13581291
* block has a terminator instruction, the record is inserted before that
@@ -1369,107 +1302,40 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
13691302
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
13701303

13711304
/**
1372-
* Insert a new Value DbgRecord before the given instruction.
1373-
*
1374-
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
1375-
* Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
1376-
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
1377-
*
1378-
* \param Builder The DIBuilder.
1379-
* \param Val The value of the variable.
1380-
* \param VarInfo The variable's debug info descriptor.
1381-
* \param Expr A complex location expression for the variable.
1382-
* \param DebugLoc Debug info location.
1383-
* \param Instr Instruction acting as a location for the new intrinsic.
1384-
*/
1385-
LLVMDbgRecordRef
1386-
LLVMDIBuilderInsertDbgValueBefore(LLVMDIBuilderRef Builder, LLVMValueRef Val,
1387-
LLVMMetadataRef VarInfo, LLVMMetadataRef Expr,
1388-
LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
1389-
/**
1390-
* Soon to be deprecated.
1391-
* Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
1305+
* Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
13921306
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
13931307
*
1394-
* Insert a new llvm.dbg.value intrinsic call before the given instruction.
1395-
* \param Builder The DIBuilder.
1396-
* \param Val The value of the variable.
1397-
* \param VarInfo The variable's debug info descriptor.
1398-
* \param Expr A complex location expression for the variable.
1399-
* \param DebugLoc Debug info location.
1400-
* \param Instr Instruction acting as a location for the new intrinsic.
1401-
*/
1402-
LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicBefore(
1403-
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
1404-
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
1405-
/**
1406-
* Soon to be deprecated.
1407-
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
1408-
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
1308+
* The debug format can be switched later after inserting the records using
1309+
* LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
14091310
*
1410-
* Insert a new llvm.dbg.value intrinsic call before the given instruction.
1311+
* Insert a new debug record before the given instruction.
14111312
* \param Builder The DIBuilder.
14121313
* \param Val The value of the variable.
14131314
* \param VarInfo The variable's debug info descriptor.
14141315
* \param Expr A complex location expression for the variable.
14151316
* \param DebugLoc Debug info location.
1416-
* \param Instr Instruction acting as a location for the new intrinsic.
1317+
* \param Instr Instruction acting as a location for the new record.
14171318
*/
14181319
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
14191320
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
14201321
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
14211322

14221323
/**
1423-
* Insert a new Value DbgRecord at the end of the given basic block. If the
1424-
* basic block has a terminator instruction, the intrinsic is inserted before
1425-
* that terminator instruction.
1426-
*
1427-
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
1428-
* Use LLVMSetIsNewDbgInfoFormat(LLVMBool) to convert between formats.
1429-
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
1430-
*
1431-
* \param Builder The DIBuilder.
1432-
* \param Val The value of the variable.
1433-
* \param VarInfo The variable's debug info descriptor.
1434-
* \param Expr A complex location expression for the variable.
1435-
* \param DebugLoc Debug info location.
1436-
* \param Block Basic block acting as a location for the new intrinsic.
1437-
*/
1438-
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueAtEnd(
1439-
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
1440-
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
1441-
/**
1442-
* Soon to be deprecated.
1443-
* Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
1324+
* Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
14441325
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
14451326
*
1446-
* Insert a new llvm.dbg.value intrinsic call at the end of the given basic
1447-
* block. If the basic block has a terminator instruction, the intrinsic is
1448-
* inserted before that terminator instruction.
1449-
* \param Builder The DIBuilder.
1450-
* \param Val The value of the variable.
1451-
* \param VarInfo The variable's debug info descriptor.
1452-
* \param Expr A complex location expression for the variable.
1453-
* \param DebugLoc Debug info location.
1454-
* \param Block Basic block acting as a location for the new intrinsic.
1455-
*/
1456-
LLVMValueRef LLVMDIBuilderInsertDbgValueIntrinsicAtEnd(
1457-
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
1458-
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
1459-
/**
1460-
* Soon to be deprecated.
1461-
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
1462-
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
1327+
* The debug format can be switched later after inserting the records using
1328+
* LLVMSetIsNewDbgInfoFormat, if needed for legacy or transitionary reasons.
14631329
*
1464-
* Insert a new llvm.dbg.value intrinsic call at the end of the given basic
1465-
* block. If the basic block has a terminator instruction, the intrinsic is
1466-
* inserted before that terminator instruction.
1330+
* Insert a new debug record at the end of the given basic block. If the
1331+
* basic block has a terminator instruction, the record is inserted before
1332+
* that terminator instruction.
14671333
* \param Builder The DIBuilder.
14681334
* \param Val The value of the variable.
14691335
* \param VarInfo The variable's debug info descriptor.
14701336
* \param Expr A complex location expression for the variable.
14711337
* \param DebugLoc Debug info location.
1472-
* \param Block Basic block acting as a location for the new intrinsic.
1338+
* \param Block Basic block acting as a location for the new record.
14731339
*/
14741340
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd(
14751341
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,

0 commit comments

Comments
 (0)