<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 - Miscompilation when targeting AArch64 from Windows"
href="https://bugs.llvm.org/show_bug.cgi?id=32917">32917</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Miscompilation when targeting AArch64 from Windows
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>3.9
</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>Interprocedural Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>martin@martin.st
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=18407" name="attach_18407" title="Reduced test case">attachment 18407</a> <a href="attachment.cgi?id=18407&action=edit" title="Reduced test case">[details]</a></span>
Reduced test case
When targeting AArch64, clang on Windows can miscompile code, while the exact
same clang version on Linux and OS X compiles it correctly.
The following reduced code snippet shows the issue:
a, b;
static fn1(*p1) { a = p1[-1]; }
fn2() { fn1(b); }
When built with -O3 for AArch64, it produces the following disassembly:
0000000000000000 <fn2>:
0: 90000008 adrp x8, 4 <fn2+0x4>
4: f9400108 ldr x8, [x8]
8: 90000009 adrp x9, 4 <fn2+0x4>
c: b9800108 ldrsw x8, [x8]
10: b85fc108 ldur w8, [x8,#-4]
14: f9400129 ldr x9, [x9]
18: b9000128 str w8, [x9]
1c: d65f03c0 ret
When built on Windows, it instead produces the following disassembly:
0000000000000000 <fn2>:
0: 90000008 adrp x8, 4 <fn2+0x4>
4: f9400108 ldr x8, [x8]
8: b27e7fe9 mov x9, #0x3fffffffc // #17179869180
c: b9800108 ldrsw x8, [x8]
10: b8696908 ldr w8, [x8,x9]
14: 90000009 adrp x9, 4 <fn2+0x4>
18: f9400129 ldr x9, [x9]
1c: b9000128 str w8, [x9]
20: d65f03c0 ret
To reproduce the issue, build with "clang -target aarch64-none-linux-android
-O3 -c aarch64-miscompilation.c -o test.o" and disassemble e.g. with
"aarch64-linux-gnu-objdump -d test.o".</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>