<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - insertDebugValuesForPHIs() re-orders how assignments appear"
href="https://bugs.llvm.org/show_bug.cgi?id=48206">48206</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>insertDebugValuesForPHIs() re-orders how assignments appear
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>Nabeel.Omer@sony.com
</td>
</tr>
<tr>
<th>CC</th>
<td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Version: LLVM 12.0 built from master at
bb8d1437a6fb3816c21363506ccb109adda58fb3
The LCSSA pass makes use of a function `insertDebugValuesForPHIs()` to
propogate `dbg.value()` intrinsics to newly inserted PHI instructions.
This bug occurs when the associated parent PHI of a newly inserted PHI is not
the most recent assignment to a source variable.
## Example:
```
; input.ll:
%S2 = ...
br label %loop.interior
loop.interior:
br i1 %S2, label %if.true, label %if.false
if.true:
%X1 = ...
@llvm.dbg.value(var = %X1)
br label %post.if
if.false:
%X2 = ...
@llvm.dbg.value(var = %X2)
br label %post.if
post.if:
%X3 = phi(X1, X2)
@llvm.dbg.value(var = %X3)
%Y1 = ...
@llvm.dbg.value(var = %Y1)
br i1 %S2, label %loop.exit, label %loop.interior
loop.exit:
... = X3 + 4
; output.ll:
%S2 = ...
br label %loop.interior
loop.interior:
br i1 %S2, label %if.true, label %if.false
if.true:
%X1 = ...
@llvm.dbg.value(var = %X1)
br label %post.if
if.false:
%X2 = ...
@llvm.dbg.value(var = %X2)
br label %post.if
post.if:
%X3 = phi(X1, X2)
@llvm.dbg.value(var = %X3)
%Y1 = ...
@llvm.dbg.value(var = %Y1)
br i1 %S2, label %loop.exit, label %loop.interior
loop.exit:
%X3.lcssa = phi(X3)
@llvm.dbg.value(var = %X3.lcssa) <---- Incorrect!
%X4 = %X3.lcssa + 3
```
As can be seen in the pseudo-IR above, insertDebugValuesForPHIs() propogates
the incorrect `dbg.value()` intrinsic. The intrinsic that should be propogated
is the one associated with `%Y1` because that is the most recent assignment to
`var`, but it is simply ignored. This results in incorrect debugging
information.
In terms of the code listings below, the problem is that in the `post.if` block
in `input.ll`, after the assignment to `%X3` and the associated `dbg.value()`
intrinsic making an assignment to the source variable `var`, there's another
assignment to `%Y1` and an associated `dbg.value()` intrinsic that makes `%Y1`
the most recent assignment to the source variable `var`(`!6`).
`insertDebugValuesForPHIs()` the function responsible for propogating the
intrinsic to the newly inserted PHI in `loop.exit` ignores the assignment to
`%Y1` and simply propogates the intrinsic associated with `%X3` as can be seen
in `output.ll`. This results in incorrect debugging information.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>