[llvm-bugs] [Bug 39787] New: [DebugInfo at O2] dbg.value with constant value "null" dropped in ISel
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Nov 26 06:11:52 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=39787
Bug ID: 39787
Summary: [DebugInfo at O2] dbg.value with constant value "null"
dropped in ISel
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: CONFIRMED
Keywords: wrong-debug
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: jeremy.morse.llvm at gmail.com
CC: chackz0x12 at gmail.com, greg.bedwell at sony.com,
international.phantom at gmail.com,
llvm-bugs at lists.llvm.org, paul.robinson at am.sony.com
Blocks: 38768
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--------
Referenced Bugs:
https://bugs.llvm.org/show_bug.cgi?id=38768
[Bug 38768] [meta][DebugInfo] Umbrella bug for poor debug experiences
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181126/09c4ab60/attachment.html>
More information about the llvm-bugs
mailing list