<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - GVN-hoist miscompiles libgo/runtime/mgc0.c"
href="https://llvm.org/bugs/show_bug.cgi?id=29023">29023</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>GVN-hoist miscompiles libgo/runtime/mgc0.c
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>cdavis5x@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=16976" name="attach_16976" title="Unoptimized IR from mgc0.c">attachment 16976</a> <a href="attachment.cgi?id=16976&action=edit" title="Unoptimized IR from mgc0.c">[details]</a></span>
Unoptimized IR from mgc0.c
When the GVN-hoist pass is enabled, Clang miscompiles the file runtime/mgc0.c
from llgo's libgo. As a result, any program built with llgo will die on
startup.
Here's what I know so far:
* The miscompile only happens when Clang generates and optimizes the IR in one
run. I can reproduce it reliably by passing -O2 (or even -O1) to Clang. But if
I pass -O0 -S -emit-llvm, and try to run opt or even Clang on the IR with -O2,
I can't reproduce this. Yes, this does suck.
* The specific miscompilation I'm referring to is in the runtime_markspan()
function. A check that the variable runtime_checking is true is optimized away
as always true, and the condition for the loop on line 2676 is also optimized
away as always true. This results in a loop that only terminates with a call to
a noreturn function, with the rest of the function after that point being
optimized away as unreachable.
* Turning GVN-hoist off fixes the miscompilation.
I wish I had more information, but given bullet 1, reducing a test case is nigh
impossible. The lack of debug output in GVN-hoist does not help matters,
either. I will attach IR files that demonstrate the problem shortly.</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>