|
From: <sv...@va...> - 2009-07-22 11:06:23
|
Author: sewardj
Date: 2009-07-22 12:06:17 +0100 (Wed, 22 Jul 2009)
New Revision: 1912
Log:
Tell the register allocator on x86 that xmm0..7 are trashed across
function calls. This forces it to handle them as caller-saved, which
is (to the extent that it's possible to tell) what the ELF ABI
requires. Lack of this has been observed to corrupt floating point
computations in tools that use the xmm registers in the helper
functions called from generated code. This change brings the x86
backend into line with the amd64 backend, the latter of which has
always treated the xmm regs as caller-saved.
The x87 registers are still incorrectly handled as callee-saved.
Modified:
trunk/priv/host_x86_defs.c
Modified: trunk/priv/host_x86_defs.c
===================================================================
--- trunk/priv/host_x86_defs.c 2009-07-22 09:29:13 UTC (rev 1911)
+++ trunk/priv/host_x86_defs.c 2009-07-22 11:06:17 UTC (rev 1912)
@@ -1230,10 +1230,19 @@
/* This is a bit subtle. */
/* First off, claim it trashes all the caller-saved regs
which fall within the register allocator's jurisdiction.
- These I believe to be %eax,%ecx,%edx. */
+ These I believe to be %eax %ecx %edx and all the xmm
+ registers. */
addHRegUse(u, HRmWrite, hregX86_EAX());
addHRegUse(u, HRmWrite, hregX86_ECX());
addHRegUse(u, HRmWrite, hregX86_EDX());
+ addHRegUse(u, HRmWrite, hregX86_XMM0());
+ addHRegUse(u, HRmWrite, hregX86_XMM1());
+ addHRegUse(u, HRmWrite, hregX86_XMM2());
+ addHRegUse(u, HRmWrite, hregX86_XMM3());
+ addHRegUse(u, HRmWrite, hregX86_XMM4());
+ addHRegUse(u, HRmWrite, hregX86_XMM5());
+ addHRegUse(u, HRmWrite, hregX86_XMM6());
+ addHRegUse(u, HRmWrite, hregX86_XMM7());
/* Now we have to state any parameter-carrying registers
which might be read. This depends on the regparmness. */
switch (i->Xin.Call.regparms) {
|
|
From: Nicholas N. <n.n...@gm...> - 2009-07-28 04:24:38
|
On Wed, Jul 22, 2009 at 9:06 PM, <sv...@va...> wrote: > Author: sewardj > Date: 2009-07-22 12:06:17 +0100 (Wed, 22 Jul 2009) > New Revision: 1912 > > Log: > Tell the register allocator on x86 that xmm0..7 are trashed across > function calls. This forces it to handle them as caller-saved, which > is (to the extent that it's possible to tell) what the ELF ABI > requires. Lack of this has been observed to corrupt floating point > computations in tools that use the xmm registers in the helper > functions called from generated code. This change brings the x86 > backend into line with the amd64 backend, the latter of which has > always treated the xmm regs as caller-saved. > > The x87 registers are still incorrectly handled as callee-saved. Did this fix any open bugs? Nick |