<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 - Under -O0, function with preserve_most calling convention fails to spill before calling functions with normal calling convention"
href="https://bugs.llvm.org/show_bug.cgi?id=43449">43449</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Under -O0, function with preserve_most calling convention fails to spill before calling functions with normal calling convention
</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>Linux
</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>Backend: AArch64
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>scw@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>arnaud.degrandmaison@arm.com, llvm-bugs@lists.llvm.org, peter.smith@linaro.org, Ties.Stuij@arm.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22572" name="attach_22572" title="Reproducer">attachment 22572</a> <a href="attachment.cgi?id=22572&action=edit" title="Reproducer">[details]</a></span>
Reproducer
Though not formally documented, according to CSR_AArch64_RT_MostRegs in
AArch64CallingConvention.td, functions with preserve_most calling convention
preserves X9 through X15 in addition to the normal callee saved registers.
When a preserve_most function calls a function with normal calling convetion,
X9 through X15 thus have to be spilled. When optimization is disabled (-O0),
this is not done resulting in register values for the caller of preserve_most
functions getting overridden.
Reproducer (also attached):
====BEGIN REPRODUCER====
#include <assert.h>
void C() {
asm volatile("mov x9, %0" : : "N"(0xdead) :"x9");
asm volatile("mov x10, %0" : : "N"(0xdead) :"x10");
asm volatile("mov x11, %0" : : "N"(0xdead) :"x11");
asm volatile("mov x12, %0" : : "N"(0xdead) :"x12");
asm volatile("mov x13, %0" : : "N"(0xdead) :"x13");
asm volatile("mov x14, %0" : : "N"(0xdead) :"x14");
asm volatile("mov x15, %0" : : "N"(0xdead) :"x15");
}
__attribute__((preserve_most))
void B() {
C();
}
int main() {
asm volatile("mov x9, %0" : : "N"(0xbeef) :"x9");
asm volatile("mov x10, %0" : : "N"(0xbeef) :"x10");
asm volatile("mov x11, %0" : : "N"(0xbeef) :"x11");
asm volatile("mov x12, %0" : : "N"(0xbeef) :"x12");
asm volatile("mov x13, %0" : : "N"(0xbeef) :"x13");
asm volatile("mov x14, %0" : : "N"(0xbeef) :"x14");
asm volatile("mov x15, %0" : : "N"(0xbeef) :"x15");
B();
int v;
asm volatile("mov %w0, w9" : "=r"(v) : "r"(v) );
assert(v == 0xbeef);
return 0;
}
=====END REPRODUCER=====
Spilling is correctly generated with any level of optimization; function body
of C() is not needed for spilling to happen.</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>