<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 - Loop-idiom recognition rewrites a loop into memset instead of unrolling it when using LTO"
href="https://bugs.llvm.org/show_bug.cgi?id=34336">34336</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Loop-idiom recognition rewrites a loop into memset instead of unrolling it when using LTO
</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>enhancement
</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>phosek@chromium.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>This was observed when building our libc with LTO for aarch64 (we haven't seen
the same issue on x86_64), specifically in _dl_start function.
The source snippet is the following:
#define DYN_CNT 32
size_t i, dyn[DYN_CNT];
for (i = 0; i < DYN_CNT; i++)
dyn[i] = 0;
In the non-LTO build, this loop is unrolled as expected:
caa24: ad0003e0 stp q0, q0, [sp]
caa28: ad0103e0 stp q0, q0, [sp,#32]
caa2c: ad0203e0 stp q0, q0, [sp,#64]
caa30: ad0303e0 stp q0, q0, [sp,#96]
caa34: ad0403e0 stp q0, q0, [sp,#128]
caa38: ad0503e0 stp q0, q0, [sp,#160]
caa3c: ad0603e0 stp q0, q0, [sp,#192]
caa40: ad0703e0 stp q0, q0, [sp,#224]
In the LTO build, the loops is turned into a PLT call:
e1814: 940015a3 bl e6ea0 <memset@plt>
Since this code is at the beginning of _dl_start before any relocations have
been performed, this causes segfault.</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>