https://bugs.llvm.org/show_bug.cgi?id=43449
Bug ID: 43449
Summary: Under -O0, function with preserve_most calling
convention fails to spill before calling functions
with normal calling convention
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: AArch64
Assignee: unassignedb...@nondot.org
Reporter: s...@google.com
CC: arnaud.degrandmai...@arm.com,
llvm-bugs@lists.llvm.org, peter.sm...@linaro.org,
ties.st...@arm.com
Created attachment 22572
--> https://bugs.llvm.org/attachment.cgi?id=22572&action=edit
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.
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs