<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 - Invalid DWARF expression for long double on x64"
href="https://bugs.llvm.org/show_bug.cgi?id=43682">43682</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Invalid DWARF expression for long double on x64
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>C
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>brettw@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22675" name="attach_22675" title="Repro case">attachment 22675</a> <a href="attachment.cgi?id=22675&action=edit" title="Repro case">[details]</a></span>
Repro case
I was experimenting with long doubles on x64 (80 bits which force x87
instructions). Clang seems to generate corrupt DWARF expressions. For this:
long double ld = 2.38;
ld += argc;
(see attached source file), it produces this DWARF entry:
DW_TAG_variable
DW_AT_location (0x0000005a
[0x0000000000201714, 0x0000000000201722): DW_OP_constu
0x9851eb851eb85000, DW_OP_stack_value, DW_OP_piece 0x8, DW_OP_constu 0x4000,
DW_OP_stack_value, DW_OP_bit_piece 0x10 0x40, DW_OP_stack_value)
DW_AT_name ("ld")
DW_AT_decl_file ("float.cc")
DW_AT_decl_line (4)
DW_AT_type (0x00000090 "long double")
This expression makes no sense. It seems to be three different ones
concatenated together, as the three DW_OP_stack_value instructions should each
indicate the end of the expression.
Additionally this variable should have two distinct values while these symbols
only indicate one.
In that expression, I used "argc" to force it to not optimize the math.
Removing that generates a reasonable looking constant value:
DW_TAG_variable
DW_AT_const_value (<0x0a> 00 50 b8 1e 85 eb 51 98 00 40 )
DW_AT_name ("ld")
DW_AT_decl_file ("float.cc")
DW_AT_decl_line (4)
DW_AT_type (0x00000097 "long double")
If the type is changed to a "double", the DWARF is reasonable, showing a
constant value and then the result of the math operation in a register:
DW_TAG_variable
DW_AT_location (0x00000046
[0x0000000000201711, 0x000000000020171d): DW_OP_constu
0x40030a3d70a3d70a, DW_OP_stack_value
[0x000000000020171d, 0x0000000000201729): DW_OP_reg17 XMM0)
DW_AT_name ("ld")
DW_AT_decl_file ("float.cc")
DW_AT_decl_line (4)
DW_AT_type (0x0000002a "double")</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>