Skip to content

Commit b40d1e8

Browse files
[RemoveDIs] Update DIBuilder C API with DbgRecord functions.
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).
1 parent e910f61 commit b40d1e8

File tree

12 files changed

+69
-450
lines changed

12 files changed

+69
-450
lines changed

llvm/bindings/ocaml/debuginfo/debuginfo_ocaml.c

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -969,45 +969,6 @@ value llvm_dibuild_create_parameter_variable_bytecode(value *argv, int arg) {
969969
);
970970
}
971971

972-
value llvm_dibuild_insert_declare_before_native(value Builder, value Storage,
973-
value VarInfo, value Expr,
974-
value DebugLoc, value Instr) {
975-
LLVMDbgRecordRef Value = LLVMDIBuilderInsertDeclareBefore(
976-
DIBuilder_val(Builder), Value_val(Storage), Metadata_val(VarInfo),
977-
Metadata_val(Expr), Metadata_val(DebugLoc), Value_val(Instr));
978-
return to_val(Value);
979-
}
980-
981-
value llvm_dibuild_insert_declare_before_bytecode(value *argv, int arg) {
982-
983-
return llvm_dibuild_insert_declare_before_native(argv[0], // Builder
984-
argv[1], // Storage
985-
argv[2], // VarInfo
986-
argv[3], // Expr
987-
argv[4], // DebugLoc
988-
argv[5] // Instr
989-
);
990-
}
991-
992-
value llvm_dibuild_insert_declare_at_end_native(value Builder, value Storage,
993-
value VarInfo, value Expr,
994-
value DebugLoc, value Block) {
995-
LLVMDbgRecordRef Value = LLVMDIBuilderInsertDeclareAtEnd(
996-
DIBuilder_val(Builder), Value_val(Storage), Metadata_val(VarInfo),
997-
Metadata_val(Expr), Metadata_val(DebugLoc), BasicBlock_val(Block));
998-
return to_val(Value);
999-
}
1000-
1001-
value llvm_dibuild_insert_declare_at_end_bytecode(value *argv, int arg) {
1002-
return llvm_dibuild_insert_declare_at_end_native(argv[0], // Builder
1003-
argv[1], // Storage
1004-
argv[2], // VarInfo
1005-
argv[3], // Expr
1006-
argv[4], // DebugLoc
1007-
argv[5] // Block
1008-
);
1009-
}
1010-
1011972
value llvm_dibuild_expression(value Builder, value Addr) {
1012973
return to_val(LLVMDIBuilderCreateExpression(
1013974
DIBuilder_val(Builder), (uint64_t *)Op_val(Addr), Wosize_val(Addr)));

llvm/bindings/ocaml/debuginfo/llvm_debuginfo.ml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -592,26 +592,6 @@ external dibuild_create_parameter_variable :
592592
Llvm.llmetadata
593593
= "llvm_dibuild_create_parameter_variable_bytecode" "llvm_dibuild_create_parameter_variable_native"
594594

595-
external dibuild_insert_declare_before :
596-
lldibuilder ->
597-
storage:Llvm.llvalue ->
598-
var_info:Llvm.llmetadata ->
599-
expr:Llvm.llmetadata ->
600-
location:Llvm.llmetadata ->
601-
instr:Llvm.llvalue ->
602-
Llvm.lldbgrecord
603-
= "llvm_dibuild_insert_declare_before_bytecode" "llvm_dibuild_insert_declare_before_native"
604-
605-
external dibuild_insert_declare_at_end :
606-
lldibuilder ->
607-
storage:Llvm.llvalue ->
608-
var_info:Llvm.llmetadata ->
609-
expr:Llvm.llmetadata ->
610-
location:Llvm.llmetadata ->
611-
block:Llvm.llbasicblock ->
612-
Llvm.lldbgrecord
613-
= "llvm_dibuild_insert_declare_at_end_bytecode" "llvm_dibuild_insert_declare_at_end_native"
614-
615595
external dibuild_expression :
616596
lldibuilder ->
617597
Int64.t array ->

llvm/bindings/ocaml/debuginfo/llvm_debuginfo.mli

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -652,30 +652,6 @@ val dibuild_create_parameter_variable :
652652
(** [dibuild_create_parameter_variable] Create a new descriptor for a
653653
function parameter variable. *)
654654

655-
val dibuild_insert_declare_before :
656-
lldibuilder ->
657-
storage:Llvm.llvalue ->
658-
var_info:Llvm.llmetadata ->
659-
expr:Llvm.llmetadata ->
660-
location:Llvm.llmetadata ->
661-
instr:Llvm.llvalue ->
662-
Llvm.lldbgrecord
663-
(** [dibuild_insert_declare_before] Insert a new llvm.dbg.declare
664-
intrinsic call before the given instruction [instr]. *)
665-
666-
val dibuild_insert_declare_at_end :
667-
lldibuilder ->
668-
storage:Llvm.llvalue ->
669-
var_info:Llvm.llmetadata ->
670-
expr:Llvm.llmetadata ->
671-
location:Llvm.llmetadata ->
672-
block:Llvm.llbasicblock ->
673-
Llvm.lldbgrecord
674-
(** [dibuild_insert_declare_at_end] Insert a new llvm.dbg.declare
675-
intrinsic call at the end of basic block [block]. If [block]
676-
has a terminator instruction, the intrinsic is inserted
677-
before that terminator instruction. *)
678-
679655
val dibuild_expression : lldibuilder -> Int64.t array -> Llvm.llmetadata
680656
(** [dibuild_expression] Create a new descriptor for the specified variable
681657
which has a complex address expression for its address.

llvm/docs/ReleaseNotes.rst

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,43 @@ 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+
* Added the following functions to insert before the indicated instruction but
224+
after any attached debug records.
225+
226+
* ``LLVMPositionBuilderBeforeDbgRecords``
227+
* ``LLVMPositionBuilderBeforeInstrAndDbgRecords``
228+
229+
Same as ``LLVMPositionBuilder`` and ``LLVMPositionBuilderBefore`` except the
230+
insertion position is set to before the debug records that precede the target
231+
instruction. ``LLVMPositionBuilder`` and ``LLVMPositionBuilderBefore`` are
232+
unchanged.
233+
234+
See the `debug info migration guide <https://llvm.org/docs/RemoveDIsDebugInfo.html>`_ for more info.
235+
236+
* Added the following functions to get/set the new non-instruction debug info format.
237+
238+
* ``LLVMIsNewDbgInfoFormat``
239+
* ``LLVMSetIsNewDbgInfoFormat``
240+
241+
* Added the following functions (no plans to deprecate) to insert a debug record
242+
(new debug info format).
243+
244+
* ``LLVMDIBuilderInsertDeclareRecordBefore``
245+
* ``LLVMDIBuilderInsertDeclareRecordAtEnd``
246+
* ``LLVMDIBuilderInsertDbgValueRecordBefore``
247+
* ``LLVMDIBuilderInsertDbgValueRecordAtEnd``
248+
249+
* Deleted the following functions that inserted a debug intrinsic (old debug info format)
250+
251+
* ``LLVMDIBuilderInsertDeclareBefore``
252+
* ``LLVMDIBuilderInsertDeclareAtEnd``
253+
* ``LLVMDIBuilderInsertDbgValueBefore``
254+
* ``LLVMDIBuilderInsertDbgValueAtEnd``
255+
256+
* ``LLVMDIBuilderInsertDeclareIntrinsicBefore``
257+
* ``LLVMDIBuilderInsertDeclareIntrinsicAtEnd``
258+
* ``LLVMDIBuilderInsertDbgValueIntrinsicBefore``
259+
* ``LLVMDIBuilderInsertDbgValueIntrinsicAtEnd``
224260

225261
Changes to the CodeGen infrastructure
226262
-------------------------------------

llvm/docs/RemoveDIsDebugInfo.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,34 +140,36 @@ 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.
143+
Deleted functions
144+
-----------------
145+
LLVMDIBuilderInsertDeclareBefore # Insert a debug record (new debug info format) instead of a debug intrinsic (old debug info format).
146+
LLVMDIBuilderInsertDeclareAtEnd # Same as above.
147+
LLVMDIBuilderInsertDbgValueBefore # Same as above.
148+
LLVMDIBuilderInsertDbgValueAtEnd # Same as above.
147149

148150
LLVMDIBuilderInsertDeclareIntrinsicBefore # Insert a debug intrinsic (old debug info format).
149151
LLVMDIBuilderInsertDeclareIntrinsicAtEnd # Same as above.
150152
LLVMDIBuilderInsertDbgValueIntrinsicBefore # Same as above.
151153
LLVMDIBuilderInsertDbgValueIntrinsicAtEnd # Same as above.
152154

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.
155+
New functions (to be deprecated)
156+
--------------------------------
157+
LLVMIsNewDbgInfoFormat # Returns true if the module is in the new non-instruction mode.
158+
LLVMSetIsNewDbgInfoFormat # Convert to the requested debug info format.
157159

158-
Existing functions (behaviour change)
160+
New functions (no plans to deprecate)
159161
-------------------------------------
160-
LLVMDIBuilderInsertDeclareBefore # Insert a debug record (new debug info format) instead of a debug intrinsic (old debug info format).
161-
LLVMDIBuilderInsertDeclareAtEnd # Same as above.
162-
LLVMDIBuilderInsertDbgValueBefore # Same as above.
163-
LLVMDIBuilderInsertDbgValueAtEnd # Same as above.
162+
LLVMDIBuilderInsertDeclareRecordBefore # Insert a debug record (new debug info format).
163+
LLVMDIBuilderInsertDeclareRecordAtEnd # Same as above. See info below.
164+
LLVMDIBuilderInsertDbgValueRecordBefore # Same as above. See info below.
165+
LLVMDIBuilderInsertDbgValueRecordAtEnd # Same as above. See info below.
164166

165-
New functions (no plans to deprecate)
166-
----------------------------------
167167
LLVMPositionBuilderBeforeDbgRecords # See info below.
168168
LLVMPositionBuilderBeforeInstrAndDbgRecords # See info below.
169169
```
170170
171+
`LLVMDIBuilderInsertDeclareRecordBefore`, `LLVMDIBuilderInsertDeclareRecordAtEnd`, `LLVMDIBuilderInsertDbgValueRecordBefore` and `LLVMDIBuilderInsertDbgValueRecordAtEnd` are replacing the deleted `LLVMDIBuilderInsertDeclareBefore-style` functions.
172+
171173
`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).
172174
173175
If you don't know which function to call then follow this rule:

llvm/include/llvm-c/DebugInfo.h

Lines changed: 0 additions & 142 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,40 +1261,6 @@ 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);
1282-
/**
1283-
* Soon to be deprecated.
1284-
* Only use in "old debug mode" (LLVMIsNewDbgInfoFormat() is false).
1285-
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
1286-
*
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);
12981264
/**
12991265
* Soon to be deprecated.
13001266
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
@@ -1312,43 +1278,6 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore(
13121278
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
13131279
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
13141280

1315-
/**
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).
1337-
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
1338-
*
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);
13521281
/**
13531282
* Soon to be deprecated.
13541283
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
@@ -1368,40 +1297,6 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd(
13681297
LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo,
13691298
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block);
13701299

1371-
/**
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).
1392-
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
1393-
*
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);
14051300
/**
14061301
* Soon to be deprecated.
14071302
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).
@@ -1419,43 +1314,6 @@ LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore(
14191314
LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo,
14201315
LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr);
14211316

1422-
/**
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).
1444-
* See https://llvm.org/docs/RemoveDIsDebugInfo.html#c-api-changes
1445-
*
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);
14591317
/**
14601318
* Soon to be deprecated.
14611319
* Only use in "new debug mode" (LLVMIsNewDbgInfoFormat() is true).

0 commit comments

Comments
 (0)