<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 - Missed opportunity to remove a dead store"
href="https://bugs.llvm.org/show_bug.cgi?id=40527">40527</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Missed opportunity to remove a dead store
</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>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>glider@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
</td>
</tr></table>
<p>
<div>
<pre>When compiling the following code:
============================
void alloc_sock(int *err);
int try_send();
int send(int len) {
int err;
if (len) {
err = -1;
alloc_sock(&err);
err = try_send();
}
return -1;
}
============================
with
$ clang -O2 -g -ftrivial-auto-var-init=pattern
-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang -c t.c
Clang produces an extra store of $0xaaaaaaaa to |err|, which is introduced by
the -ftrivial-auto-var-init and not removed by other optimizations in the
pipeline:
$ objdump -d t.o
0000000000000000 <send>:
0: 50 push %rax
1: c7 44 24 04 aa aa aa movl $0xaaaaaaaa,0x4(%rsp)
8: aa
9: 85 ff test %edi,%edi
b: 74 1d je 2a <send+0x2a>
d: c7 44 24 04 ff ff ff movl $0xffffffff,0x4(%rsp)
14: ff
15: 48 8d 7c 24 04 lea 0x4(%rsp),%rdi
1a: e8 00 00 00 00 callq 1f <send+0x1f>
1f: 31 c0 xor %eax,%eax
21: e8 00 00 00 00 callq 26 <send+0x26>
26: 89 44 24 04 mov %eax,0x4(%rsp)
2a: b8 ff ff ff ff mov $0xffffffff,%eax
2f: 59 pop %rcx
30: c3 retq
As noted by JF Bastien here: <a href="https://reviews.llvm.org/D54604">https://reviews.llvm.org/D54604</a>, "Seems like the
optimizer should sink the store enough that it appears only once on each path."</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>