From: Julian Seward Date: Wed, 22 Jul 2009 11:06:17 +0000 (+0000) Subject: Tell the register allocator on x86 that xmm0..7 are trashed across X-Git-Tag: svn/VALGRIND_3_5_0^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d937a500af331bc7b663206c76eaabbc5db3e79;p=thirdparty%2Fvalgrind.git 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. git-svn-id: svn://svn.valgrind.org/vex/trunk@1912 --- diff --git a/VEX/priv/host_x86_defs.c b/VEX/priv/host_x86_defs.c index d5f5539a1c..6fa41255c5 100644 --- a/VEX/priv/host_x86_defs.c +++ b/VEX/priv/host_x86_defs.c @@ -1230,10 +1230,19 @@ void getRegUsage_X86Instr (HRegUsage* u, X86Instr* i, Bool mode64) /* 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) {