<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 - Emission of DW_TAG_formal_parameter location is inaccurate on Linux (with -O3)"
href="https://bugs.llvm.org/show_bug.cgi?id=39710">39710</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Emission of DW_TAG_formal_parameter location is inaccurate on Linux (with -O3)
</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>All
</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>DebugInfo
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>davide@freebsd.org
</td>
</tr>
<tr>
<th>CC</th>
<td>aprantl@apple.com, friss@apple.com, jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, rnk@google.com, vsk@apple.com
</td>
</tr></table>
<p>
<div>
<pre>There has been a lot of talking about about unrecoverable function arguments
for optimized builds, so I decided to give it a try to see if there's something
that could be done to improve.
Take the following test case:
__attribute__((noinline))
int fn1 (long int x, long int y, long int z) {
int l = x * 2;
int q = y * z;
return l + q;
}
__attribute__((noinline)) long int
fn2 (long int a, long int b, long int c)
{
long int q = 2 * a;
return fn1 (5, 6, 7);
}
int main(void) {
return fn2(14, 23, 34);
}
Build with -O3 -g. Set a breakpoint on fn1, and try to print the arguments
(e.g. through `frame var`).
You'll realize that you can recover them on a recent MacOS (Mojave), but you
can't on ubuntu 18.10.
I started looking a little bit into why this was the case, to immediately find
out the DWARF emission for the formal parameter differs on the two platforms.
Namely:
MacOS:
0x00000043: DW_TAG_formal_parameter
DW_AT_location (0x00000000
[0x0000000100000f70, 0x0000000100000f74): DW_OP_reg5 RDI
[0x0000000100000f74, 0x0000000100000f7c): DW_OP_reg5 RDI)
DW_AT_name ("x")
DW_AT_decl_file
("/Users/davide/llvm-monorepo/llvm-mono/build/bin/optout.c")
DW_AT_decl_line (2)
DW_AT_type (0x00000104 "long int")
Linux:
0x00000043: DW_TAG_formal_parameter
DW_AT_location (0x00000000)
DW_AT_name ("x")
DW_AT_decl_file ("/home/davide/optimized_code/./opt.c")
DW_AT_decl_line (2)
DW_AT_type (0x000000f1 "long int")
While the former contains a location list pointing at the register where the
debugger should retrieve the argument, the second one contains an empty
location list.</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>