]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Tell the register allocator on x86 that xmm0..7 are trashed across
authorJulian Seward <jseward@acm.org>
Wed, 22 Jul 2009 11:06:17 +0000 (11:06 +0000)
committerJulian Seward <jseward@acm.org>
Wed, 22 Jul 2009 11:06:17 +0000 (11:06 +0000)
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

VEX/priv/host_x86_defs.c

index d5f5539a1c3fe5c36ba40fd31235aa0fd3f08c5c..6fa41255c55c6ea2028ec28690b32b3ca64fc6cd 100644 (file)
@@ -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) {