<html>
<head>
<base href="http://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 --- - miscompile at -O1 produces crashing program (postRA scheduler?)"
href="http://llvm.org/bugs/show_bug.cgi?id=20020">20020</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>miscompile at -O1 produces crashing program (postRA scheduler?)
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</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>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>spatel+llvm@rotateright.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>The following C test case is a reduced version of
test-suite/SingleSource/Benchmarks/BenchmarkGame/n-body.c.
This program is crashing on both Linux x86-64 and OS X using clang trunk (v3.5)
like so:
$ ./clang -fmath-errno -O1 nbody_reduced.c -march=atom -lm
$ ./a.out
Segmentation fault (core dumped)
I am suspicious of postRA scheduling because after I enabled postRA scheduling
for another target (btver2) and rebuilt clang, the program began crashing on
that target too. I don't see a way to toggle postRA scheduling via command-line
flags, but if that's possible, it would be much easier to test.
Any suggestions on how to isolate this fault?
$ cat nbody_reduced.c
#include <math.h>
struct planet {
double x, y;
double vx, vy;
double mass;
};
void advance(int nbodies, struct planet * bodies, double dt)
{
int i, j;
for (i = 0; i < nbodies; i++) {
struct planet * b = &(bodies[i]);
for (j = i + 1; j < nbodies; j++) {
struct planet * b2 = &(bodies[j]);
double dx = b->x - b2->x;
double dy = b->y - b2->y;
double distance = sqrt(dx * dx + dy * dy);
double mag = dt / (distance * distance * distance);
b->vx -= dx * b2->mass * mag;
b->vy -= dy * b2->mass * mag;
}
}
for (i = 0; i < nbodies; i++) {
struct planet * b = &(bodies[i]);
b->x += b->vx;
b->y += 0.01 * b->vy;
}
}
int main()
{
struct planet bodies;
advance(1, &bodies, 0.01);
return 0;
}</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>