1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-07 18:30:25 +02:00

x86_64: Correct wrong inline assembly in jit_get_cpu

* lib/jit_x86.c: Rewrite incorrect inline assembly that could
	truncate a variable in a callee save register. Now it simply
	tells gcc that the register is clobbered, instead of using a
	*32 bit* swap with a temporary variable. The problem only
	happens when compiling with optimization.
This commit is contained in:
pcpa 2014-02-19 15:29:26 -03:00
parent 6e75c0352d
commit dbb9fe1e81
2 changed files with 14 additions and 4 deletions

View file

@ -1,3 +1,11 @@
2014-19-02 Paulo Andrade <pcpa@gnu.org>
* lib/jit_x86.c: Rewrite incorrect inline assembly that could
truncate a variable in a callee save register. Now it simply
tells gcc that the register is clobbered, instead of using a
*32 bit* swap with a temporary variable. The problem only
happens when compiling with optimization.
2014-19-02 Paulo Andrade <pcpa@gnu.org> 2014-19-02 Paulo Andrade <pcpa@gnu.org>
* include/lightning/jit_aarch64.h, include/lightning/jit_arm.h, * include/lightning/jit_aarch64.h, include/lightning/jit_arm.h,

View file

@ -236,10 +236,11 @@ jit_get_cpu(void)
#endif #endif
/* query %eax = 1 function */ /* query %eax = 1 function */
__asm__ volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1" __asm__ volatile ("cpuid; movl %%ebx, %1"
: "=a" (eax), "=r" (ebx), : "=a" (eax), "=r" (ebx),
"=c" (ecx.cpuid), "=d" (edx.cpuid) "=c" (ecx.cpuid), "=d" (edx.cpuid)
: "0" (1)); : "0" (1)
: "ebx");
jit_cpu.fpu = edx.bits.fpu; jit_cpu.fpu = edx.bits.fpu;
jit_cpu.cmpxchg8b = edx.bits.cmpxchg8b; jit_cpu.cmpxchg8b = edx.bits.cmpxchg8b;
@ -261,10 +262,11 @@ jit_get_cpu(void)
#if __WORDSIZE == 64 #if __WORDSIZE == 64
/* query %eax = 0x80000001 function */ /* query %eax = 0x80000001 function */
__asm__ volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1" __asm__ volatile ("cpuid; movl %%ebx, %1"
: "=a" (eax), "=r" (ebx), : "=a" (eax), "=r" (ebx),
"=c" (ecx.cpuid), "=d" (edx.cpuid) "=c" (ecx.cpuid), "=d" (edx.cpuid)
: "0" (0x80000001)); : "0" (0x80000001)
: "ebx");
jit_cpu.lahf = ecx.cpuid & 1; jit_cpu.lahf = ecx.cpuid & 1;
#endif #endif
} }