@@ -291,17 +291,17 @@ Compiled to LLVM, this function would be represented like this:
291
291
%X = alloca i32, align 4
292
292
%Y = alloca i32, align 4
293
293
%Z = alloca i32, align 4
294
- call void @llvm.dbg.declare(metadata i32* %X, metadata !11, metadata !DIExpression()) , !dbg !13
295
- store i32 21, i32* %X, align 4, !dbg !13
296
- call void @llvm.dbg.declare(metadata i32* %Y, metadata !14 , metadata !DIExpression()) , !dbg !15
297
- store i32 22, i32* %Y, align 4, !dbg !15
298
- call void @llvm.dbg.declare(metadata i32* %Z, metadata !16 , metadata !DIExpression()) , !dbg !18
299
- store i32 23, i32* %Z, align 4, !dbg !18
300
- %0 = load i32, i32* %X, align 4, !dbg !19
301
- store i32 %0, i32* %Z, align 4, !dbg !20
302
- %1 = load i32, i32* %Y, align 4, !dbg !21
303
- store i32 %1, i32* %X, align 4, !dbg !22
304
- ret void, !dbg !23
294
+ call void @llvm.dbg.declare(metadata i32* %X, metadata !11, metadata !13) , !dbg !14
295
+ store i32 21, i32* %X, align 4, !dbg !14
296
+ call void @llvm.dbg.declare(metadata i32* %Y, metadata !15 , metadata !13) , !dbg !16
297
+ store i32 22, i32* %Y, align 4, !dbg !16
298
+ call void @llvm.dbg.declare(metadata i32* %Z, metadata !17 , metadata !13) , !dbg !19
299
+ store i32 23, i32* %Z, align 4, !dbg !19
300
+ %0 = load i32, i32* %X, align 4, !dbg !20
301
+ store i32 %0, i32* %Z, align 4, !dbg !21
302
+ %1 = load i32, i32* %Y, align 4, !dbg !22
303
+ store i32 %1, i32* %X, align 4, !dbg !23
304
+ ret void, !dbg !24
305
305
}
306
306
307
307
; Function Attrs: nounwind readnone
@@ -327,17 +327,18 @@ Compiled to LLVM, this function would be represented like this:
327
327
!10 = !{!"clang version 3.7.0 (trunk 231150) (llvm/trunk 231154)"}
328
328
!11 = !DILocalVariable(name: "X", scope: !4, file: !1, line: 2, type: !12)
329
329
!12 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
330
- !13 = !DILocation(line: 2, column: 9, scope: !4)
331
- !14 = !DILocalVariable(name: "Y", scope: !4, file: !1, line: 3, type: !12)
332
- !15 = !DILocation(line: 3, column: 9, scope: !4)
333
- !16 = !DILocalVariable(name: "Z", scope: !17, file: !1, line: 5, type: !12)
334
- !17 = distinct !DILexicalBlock(scope: !4, file: !1, line: 4, column: 5)
335
- !18 = !DILocation(line: 5, column: 11, scope: !17)
336
- !19 = !DILocation(line: 6, column: 11, scope: !17)
337
- !20 = !DILocation(line: 6, column: 9, scope: !17)
338
- !21 = !DILocation(line: 8, column: 9, scope: !4)
339
- !22 = !DILocation(line: 8, column: 7, scope: !4)
340
- !23 = !DILocation(line: 9, column: 3, scope: !4)
330
+ !13 = !DIExpression()
331
+ !14 = !DILocation(line: 2, column: 9, scope: !4)
332
+ !15 = !DILocalVariable(name: "Y", scope: !4, file: !1, line: 3, type: !12)
333
+ !16 = !DILocation(line: 3, column: 9, scope: !4)
334
+ !17 = !DILocalVariable(name: "Z", scope: !18, file: !1, line: 5, type: !12)
335
+ !18 = distinct !DILexicalBlock(scope: !4, file: !1, line: 4, column: 5)
336
+ !19 = !DILocation(line: 5, column: 11, scope: !18)
337
+ !20 = !DILocation(line: 6, column: 11, scope: !18)
338
+ !21 = !DILocation(line: 6, column: 9, scope: !18)
339
+ !22 = !DILocation(line: 8, column: 9, scope: !4)
340
+ !23 = !DILocation(line: 8, column: 7, scope: !4)
341
+ !24 = !DILocation(line: 9, column: 3, scope: !4)
341
342
342
343
343
344
This example illustrates a few important details about LLVM debugging
@@ -348,21 +349,21 @@ variable definitions, and the code used to implement the function.
348
349
349
350
.. code-block :: llvm
350
351
351
- call void @llvm.dbg.declare(metadata i32* %X, metadata !11, metadata !DIExpression()) , !dbg !13
352
+ call void @llvm.dbg.declare(metadata i32* %X, metadata !11, metadata !13) , !dbg !14
352
353
; [debug line = 2:7] [debug variable = X]
353
354
354
355
The first intrinsic ``%llvm.dbg.declare `` encodes debugging information for the
355
- variable ``X ``. The metadata ``!dbg !13 `` attached to the intrinsic provides
356
+ variable ``X ``. The metadata ``!dbg !14 `` attached to the intrinsic provides
356
357
scope information for the variable ``X ``.
357
358
358
359
.. code-block :: text
359
360
360
- !13 = !DILocation(line: 2, column: 9, scope: !4)
361
+ !14 = !DILocation(line: 2, column: 9, scope: !4)
361
362
!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5,
362
363
isLocal: false, isDefinition: true, scopeLine: 1,
363
364
isOptimized: false, retainedNodes: !2)
364
365
365
- Here ``!13 `` is metadata providing `location information
366
+ Here ``!14 `` is metadata providing `location information
366
367
<LangRef.html#dilocation> `_. In this example, scope is encoded by ``!4 ``, a
367
368
`subprogram descriptor <LangRef.html#disubprogram >`_. This way the location
368
369
information attached to the intrinsics indicates that the variable ``X `` is
@@ -372,20 +373,20 @@ Now lets take another example.
372
373
373
374
.. code-block :: llvm
374
375
375
- call void @llvm.dbg.declare(metadata i32* %Z, metadata !16 , metadata !DIExpression()) , !dbg !18
376
+ call void @llvm.dbg.declare(metadata i32* %Z, metadata !17 , metadata !13) , !dbg !19
376
377
; [debug line = 5:9] [debug variable = Z]
377
378
378
379
The third intrinsic ``%llvm.dbg.declare `` encodes debugging information for
379
- variable ``Z ``. The metadata ``!dbg !18 `` attached to the intrinsic provides
380
+ variable ``Z ``. The metadata ``!dbg !19 `` attached to the intrinsic provides
380
381
scope information for the variable ``Z ``.
381
382
382
383
.. code-block :: text
383
384
384
- !17 = distinct !DILexicalBlock(scope: !4, file: !1, line: 4, column: 5)
385
- !18 = !DILocation(line: 5, column: 11, scope: !17 )
385
+ !18 = distinct !DILexicalBlock(scope: !4, file: !1, line: 4, column: 5)
386
+ !19 = !DILocation(line: 5, column: 11, scope: !18 )
386
387
387
- Here ``!18 `` indicates that ``Z `` is declared at line number 5 and column
388
- number 11 inside of lexical scope ``!17 ``. The lexical scope itself resides
388
+ Here ``!19 `` indicates that ``Z `` is declared at line number 5 and column
389
+ number 11 inside of lexical scope ``!18 ``. The lexical scope itself resides
389
390
inside of subprogram ``!4 `` described above.
390
391
391
392
The scope information attached with each instruction provides a straightforward
@@ -801,14 +802,14 @@ presents several difficulties:
801
802
br label %exit, !dbg !26
802
803
803
804
truebr:
804
- call void @llvm.dbg.value(metadata i32 %input, metadata !30, metadata !DIExpression()), !dbg !23
805
- call void @llvm.dbg.value(metadata i32 1, metadata !22 , metadata !DIExpression()), !dbg !23
805
+ call void @llvm.dbg.value(metadata i32 %input, metadata !30, metadata !DIExpression()), !dbg !24
806
+ call void @llvm.dbg.value(metadata i32 1, metadata !23 , metadata !DIExpression()), !dbg !24
806
807
%value1 = add i32 %input, 1
807
808
br label %bb1
808
809
809
810
falsebr:
810
- call void @llvm.dbg.value(metadata i32 %input, metadata !30, metadata !DIExpression()), !dbg !23
811
- call void @llvm.dbg.value(metadata i32 2, metadata !22 , metadata !DIExpression()), !dbg !23
811
+ call void @llvm.dbg.value(metadata i32 %input, metadata !30, metadata !DIExpression()), !dbg !24
812
+ call void @llvm.dbg.value(metadata i32 2, metadata !23 , metadata !DIExpression()), !dbg !24
812
813
%value = add i32 %input, 2
813
814
br label %bb1
814
815
@@ -819,7 +820,7 @@ presents several difficulties:
819
820
Here the difficulties are:
820
821
821
822
* The control flow is roughly the opposite of basic block order
822
- * The value of the ``!22 `` variable merges into ``%bb1 ``, but there is no PHI
823
+ * The value of the ``!23 `` variable merges into ``%bb1 ``, but there is no PHI
823
824
node
824
825
825
826
As mentioned above, the ``llvm.dbg.value `` intrinsics essentially form an
@@ -832,9 +833,9 @@ location, which would lead to a large number of debugging intrinsics being
832
833
generated.
833
834
834
835
Examining the example above, variable ``!30 `` is assigned ``%input `` on both
835
- conditional paths through the function, while ``!22 `` is assigned differing
836
+ conditional paths through the function, while ``!23 `` is assigned differing
836
837
constant values on either path. Where control flow merges in ``%bb1 `` we would
837
- want ``!30 `` to keep its location (``%input ``), but ``!22 `` to become undefined
838
+ want ``!30 `` to keep its location (``%input ``), but ``!23 `` to become undefined
838
839
as we cannot determine at runtime what value it should have in %bb1 without
839
840
inserting a PHI node. mem2reg does not insert the PHI node to avoid changing
840
841
codegen when debugging is enabled, and does not insert the other dbg.values
@@ -853,7 +854,7 @@ DbgEntityHistoryCalculator) to build a map of each instruction to every
853
854
valid variable location, without the need to consider control flow. From
854
855
the example above, it is otherwise difficult to determine that the location
855
856
of variable ``!30 `` should flow "up" into block ``%bb1 ``, but that the location
856
- of variable ``!22 `` should not flow "down" into the ``%exit `` block.
857
+ of variable ``!23 `` should not flow "down" into the ``%exit `` block.
857
858
858
859
.. _ccxx_frontend :
859
860
0 commit comments