<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 --- - [AARCH64] SIMD instructions are emitted without proper address alignment"
href="https://llvm.org/bugs/show_bug.cgi?id=31170">31170</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[AARCH64] SIMD instructions are emitted without proper address alignment
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</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>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>sergio.moreira@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=17656" name="attach_17656" title="Sample C code">attachment 17656</a> <a href="attachment.cgi?id=17656&action=edit" title="Sample C code">[details]</a></span>
Sample C code
Hi,
I'm compiling a very simple memset() implementation for AARCH64. See the
attached file.
clang is generating a couple of SIMD store instructions without checking if the
address is aligned. When run on a target (e.g. Hikey board) it crashes with an
alignment fault.
I tested both clang-3.8 that is available on Ubuntu 16.04 Server, as well as a
build of clang-4.0 from SVN.
$ /opt/llvm/bin/clang-4.0 --target=aarch64 -c -O2 LibC.c -o LibC.o -isystem
/usr/aarch64-linux-gnu/include/
$ aarch64-linux-gnu-objdump -d -x LibC.o
<snipped>
0000000000000088 <memset>:
88: b40002c2 cbz x2, e0 <memset+0x58>
8c: f100805f cmp x2, #0x20
90: 540001e3 b.cc cc <memset+0x44>
94: 927be84a and x10, x2, #0xffffffffffffffe0
98: b40001aa cbz x10, cc <memset+0x44>
9c: 8b0a0008 add x8, x0, x10
a0: cb0a0049 sub x9, x2, x10
a4: 4e010c20 dup v0.16b, w1
a8: 9100400b add x11, x0, #0x10
ac: aa0a03ec mov x12, x10
b0: ad3f8160 stp q0, q0, [x11,#-16] <- x11 can be unaligned.
<snipped>
Let me know if you need more information.
$ /opt/llvm/bin/clang-4.0 -v
clang version 4.0.0 (trunk 287757)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/llvm/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.0.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Selected multilib: .;@m64</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>