wingo pushed a commit to branch lightning
in repository guile.
commit dbb9fe1e81ca8c684ea902a59a4889c7345c45ee
Author: pcpa <[email protected]>
Date: Wed Feb 19 15:29:26 2014 -0300
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.
---
ChangeLog | 8 ++++++++
lib/jit_x86.c | 10 ++++++----
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 81d3919..f3ab5a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2014-19-02 Paulo Andrade <[email protected]>
+ * 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 <[email protected]>
+
* include/lightning/jit_aarch64.h, include/lightning/jit_arm.h,
include/lightning/jit_hppa.h, include/lightning/jit_ia64.h,
include/lightning/jit_mips.h, include/lightning/jit_ppc.h,
diff --git a/lib/jit_x86.c b/lib/jit_x86.c
index 69df289..027e6db 100644
--- a/lib/jit_x86.c
+++ b/lib/jit_x86.c
@@ -236,10 +236,11 @@ jit_get_cpu(void)
#endif
/* query %eax = 1 function */
- __asm__ volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1"
+ __asm__ volatile ("cpuid; movl %%ebx, %1"
: "=a" (eax), "=r" (ebx),
"=c" (ecx.cpuid), "=d" (edx.cpuid)
- : "0" (1));
+ : "0" (1)
+ : "ebx");
jit_cpu.fpu = edx.bits.fpu;
jit_cpu.cmpxchg8b = edx.bits.cmpxchg8b;
@@ -261,10 +262,11 @@ jit_get_cpu(void)
#if __WORDSIZE == 64
/* query %eax = 0x80000001 function */
- __asm__ volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1"
+ __asm__ volatile ("cpuid; movl %%ebx, %1"
: "=a" (eax), "=r" (ebx),
"=c" (ecx.cpuid), "=d" (edx.cpuid)
- : "0" (0x80000001));
+ : "0" (0x80000001)
+ : "ebx");
jit_cpu.lahf = ecx.cpuid & 1;
#endif
}