<html>
<head>
<base href="http://bugzilla.gdcproject.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 - GDC emits unnecessary dead struct inits"
href="http://bugzilla.gdcproject.org/show_bug.cgi?id=147">147</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>GDC emits unnecessary dead struct inits
</td>
</tr>
<tr>
<th>Product</th>
<td>GDC
</td>
</tr>
<tr>
<th>Version</th>
<td>4.9.x
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>Normal
</td>
</tr>
<tr>
<th>Component</th>
<td>gdc
</td>
</tr>
<tr>
<th>Assignee</th>
<td>ibuclaw@gdcproject.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>art.08.09@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>--------------------------------------------------------
void f() { assert(0); }
struct S { ulong v; }
void main(string[] argv) {
S a; /* Adding `= void` here results in sane codegen, but shouldn't be
necessary. */
a.v = argv.length; /* Modifies the whole struct. */
if (a.v==42)
f();
}
---------------------------------------------------------
using current gcc4.9 based git head, gdc -m64 -O3:
0000000000402970 <void bugzdeadstore1.f()>:
402970: 48 83 ec 08 sub $0x8,%rsp
402974: ba 04 00 00 00 mov $0x4,%edx
402979: bf 10 00 00 00 mov $0x10,%edi
40297e: be 84 1f 44 00 mov $0x441f84,%esi
402983: e8 28 e6 00 00 callq 410fb0 <_d_assert>
0000000000402990 <_Dmain>:
402990: 48 83 ec 18 sub $0x18,%rsp
402994: 48 83 ff 2a cmp $0x2a,%rdi
402998: 48 c7 04 24 00 00 00 movq $0x0,(%rsp)
40299f: 00
4029a0: 74 07 je 4029a9 <_Dmain+0x19>
4029a2: 31 c0 xor %eax,%eax
4029a4: 48 83 c4 18 add $0x18,%rsp
4029a8: c3 retq
4029a9: e8 c2 ff ff ff callq 402970 <void bugzdeadstore1.f()>
That dead store @402998 is unnecessary. It disappears when `a` is initted to
`void`, but that is not a practical (nor safe) solution for real code (this is
obviously a very reduced example).
There are other issues with non-POD object related codegen (especially for
@noinline functions), but this one is bad because it affects PODs and makes
even simple type wrapping expensive.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are watching all bug changes.</li>
</ul>
</body>
</html>