@@ -167,6 +167,17 @@ conventions used by the C and C++ front-ends.
167
167
Debug information descriptors are `specialized metadata nodes
168
168
<LangRef.html#specialized-metadata> `_, first-class subclasses of ``Metadata ``.
169
169
170
+ There are two models for defining the values of source variables at different
171
+ states of the program and tracking these values through optimization and code
172
+ generation: :ref: `intrinsic function calls <format_common_intrinsics >`, the
173
+ current default, and :ref: `debug records <debug_records >`, which are a new
174
+ non-instruction-based model
175
+ (for an explanation of how this works and why it is desirable, see the
176
+ `RemoveDIs <RemoveDIsDebugInfo.html >`_ document). Each module must use one or
177
+ the other; they may never be mixed within an IR module. To enable writing debug
178
+ records instead of intrinsic calls, use the flag
179
+ ``--write-experimental-debuginfo ``.
180
+
170
181
.. _format_common_intrinsics :
171
182
172
183
Debugger intrinsic functions
@@ -268,6 +279,61 @@ The formal LLVM-IR signature is:
268
279
269
280
See :doc: `AssignmentTracking ` for more info.
270
281
282
+ .. _debug_records :
283
+
284
+ Debug Records
285
+ ----------------------------
286
+
287
+ LLVM also has an alternative to intrinsic functions, debug records, which
288
+ function similarly but are not instructions. The basic syntax for debug records
289
+ is:
290
+
291
+ .. code-block :: llvm
292
+
293
+ #dbg_<kind>([<arg>, ]* <DILocation>)
294
+ ; Using the intrinsic model, the above is equivalent to:
295
+ call void llvm.dbg.<kind>([metadata <arg>, ]*), !dbg <DILocation>
296
+
297
+ A debug intrinsic function can be converted to a debug record with the
298
+ following steps:
299
+
300
+ 1. Add an extra level of indentation.
301
+ 2. Replace everything prior to the intrinsic kind (declare/value/assign) with
302
+ ``#dbg_ ``.
303
+ 3. Remove the leading ``metadata `` from the intrinsic's arguments.
304
+ 4. Transfer the ``!dbg `` attachment to be an argument, dropping the leading
305
+ ``!dbg ``.
306
+
307
+ For each kind of intrinsic function, there is an equivalent debug record.
308
+
309
+ ``#dbg_declare ``
310
+ ^^^^^^^^^^^^^^^^
311
+
312
+ .. code-block :: llvm
313
+
314
+ #dbg_declare([Value|MDNode], DILocalVariable, DIExpression, DILocation)
315
+
316
+ Equivalent to the ``llvm.dbg.declare `` intrinsic.
317
+
318
+ ``#dbg_value ``
319
+ ^^^^^^^^^^^^^^
320
+
321
+ .. code-block :: llvm
322
+
323
+ #dbg_value([Value|DIArgList|MDNode], DILocalVariable, DIExpression, DILocation)
324
+
325
+ Equivalent to the ``llvm.dbg.value `` intrinsic.
326
+
327
+ ``#dbg_assign ``
328
+ ^^^^^^^^^^^^^^^
329
+
330
+ .. code-block :: llvm
331
+
332
+ #dbg_assign([Value|DIArgList|MDNode], DILocalVariable, DIExpression,
333
+ DIAssignID, [Value|MDNode], DIExpression, DILocation)
334
+
335
+ Equivalent to the ``llvm.dbg.assign `` intrinsic.
336
+
271
337
Object lifetimes and scoping
272
338
============================
273
339
0 commit comments