<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_CONFIRMED "
title="CONFIRMED - [DebugInfo@O2] dbg.value with constant value "null" dropped in ISel"
href="https://bugs.llvm.org/show_bug.cgi?id=39787">39787</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[DebugInfo@O2] dbg.value with constant value "null" dropped in ISel
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>CONFIRMED
</td>
</tr>
<tr>
<th>Keywords</th>
<td>wrong-debug
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>jeremy.morse.llvm@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>chackz0x12@gmail.com, greg.bedwell@sony.com, international.phantom@gmail.com, llvm-bugs@lists.llvm.org, paul.robinson@am.sony.com
</td>
</tr>
<tr>
<th>Blocks</th>
<td>38768
</td>
</tr></table>
<p>
<div>
<pre>In the trivial piece of code below, using clang++-6.0 (also replicates with the
more recent r346686), the assignment of "xyzzy = nullptr" goes missing and does
not make it to the output debug info. The result is that the (now dead) first
pointer returned by "alloc" is presented as the value of "xyzzy" across the
assignments to "bar". I can't contrive a circumstance where this immediately
misleads a developer; instead IMHO it's possible that code the developer
doesn't immediately understand (say, a template meta-function) computes a
nullptr at compile time, the debug-info for which is dropped, and the developer
sees a stale pointer in a variable instead. Quite niche, but debug-info of
constants seems like something LLVM should be able to easily do.
Note that the constant-value of 'somethingorother' make it to the output, so
this is pointer specific, apparently.
Compiling "clang++-6.0 nonull.cpp -o a.out -O2 -g -fno-inline", dwarfdump
(llvm-dwarfdump-6.0 --name=xyzzy) says:
--------8<--------
a.out: file format ELF64-x86-64
0x000000cb: DW_TAG_variable
DW_AT_location (0x00000025
0x0000000000400556 - 0x000000000040056e: DW_OP_reg0 RAX)
DW_AT_name ("xyzzy")
DW_AT_decl_file ("/home/jmorse/nonull.cpp")
DW_AT_decl_line (14)
DW_AT_type (cu + 0x00ea "trains*")
-------->8--------
Observe that there's no constant value in there. Running -debug says:
--------8<--------
Dropping debug location info for:
call void @llvm.dbg.value(metadata %class.trains* null, metadata !40,
metadata !DIExpression()), !dbg !44
Last seen at:
%class.trains* null
-------->8--------
And finally the original code:
--------8<--------
class trains {
public:
volatile int foo;
trains() {
foo = 0;
}
};
trains *alloc() {
return new trains();
}
int main() {
trains *xyzzy = alloc();
int somethingorother = 0;
xyzzy->foo = 1;
xyzzy = nullptr;
volatile int bar = 0;
bar++;
if ((xyzzy = alloc())) {
return bar;
}
return 0;
}
-------->8--------</pre>
</div>
</p>
<div id="referenced">
<hr style="border: 1px dashed #969696">
<b>Referenced Bugs:</b>
<ul>
<li>
[<a class="bz_bug_link
bz_status_NEW "
title="NEW - [meta][DebugInfo] Umbrella bug for poor debug experiences"
href="https://bugs.llvm.org/show_bug.cgi?id=38768">Bug 38768</a>] [meta][DebugInfo] Umbrella bug for poor debug experiences
</li>
</ul>
</div>
<br>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>