<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 - clang -flto doesn't respect -fno-unroll-loops option"
href="https://bugs.llvm.org/show_bug.cgi?id=35139">35139</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clang -flto doesn't respect -fno-unroll-loops option
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</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>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Driver
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>st@quanttec.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>When I let clang link together object files that I produced with -flto -Os, the
link time optimization seems to respect the -Os option. When I let it link
files produced with -flto -O2 -fno-unroll-loops the -fno-unroll-loops flag
seems to be ignored.
Test case:
The following 3 commands produce an executable with an unrolled loop (using
clang 5.0 and the files pasted below; verified by disassembling the
executable):
<span class="quote">> clang -flto -O2 -fno-unroll-loops -c loop.c -o loop.o
> clang -O2 -fno-unroll-loops -c main.c -o main.o
> clang -flto -O2 -fno-unroll-loops loop.o main.o -o main</span >
I'd expect this to produce an executable without an unrolled loop, even when
the last command only reads `clang -flto loop.o main.o -o main`, as is the case
when using -Os instead of -O2 when compiling loop.c and main.c.
Adding `-Xlinker -mllvm -Xlinker -unroll-count=0` to the last command actually
does stop LLVM from unrolling the loop.
-- loop.c --
__attribute__((noinline))
int loop(float *array, int count) {
float i1 = 1;
for (int i = 0; i < count; ++i, i1 += 1) {
array[i] += i1;
}
return count;
}
-- loop.h --
int loop(float *array, int count);
-- main.c --
#include "loop.h"
int main() {
volatile int zero = 0;
return loop(0, zero);
}</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>