[Gc] Re: llvm bug in boehmgc inline asm

Ivan Maidanski ivmai at mail.ru
Sun Jun 26 23:51:25 PDT 2011


Hi Jeremy,

Thank you for finding the right solution!
Fixed in CVS.

Regards.

24 jun 2011, 21:12 Jeremy Huddleston <jeremyhu at apple.com>:
> Hi,
> 
> I was about to send you a fix for some buggy inline asm in the boehmgc
> project.  It looks like you "fixed" it the wrong way (by assuming it was a bug
> in the assembler when it was really a bug in the code):
> 
> # ifdef AO_XCHGB_RET_WORD
> /* Workaround for a bug in LLVM v2.7 GAS.   */
> unsigned oldval;
> # else
> unsigned char oldval;
> # endif
> 
> The correct fix is to cast 0xff to an unsigned char.  This patch is against
> 7.1, but you should be able to see what to do for current svn.
> 
> --Jeremy
> 
> diff -Naurp gc-7.1.orig/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86.h
> gc-7.1/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86.h
> --- gc-7.1.orig/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86.h	2008-02-01
> 11:57:17.000000000 -0800
> +++ gc-7.1/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86.h	2011-06-24
> 10:01:50.000000000 -0700
> @@ -113,7 +113,7 @@ AO_test_and_set_full(volatile AO_TS_t *a
> /* Note: the "xchg" instruction does not need a "lock" prefix */
> __asm__ __volatile__("xchgb %0, %1"
> : "=q"(oldval), "=m"(*addr)
> -		: "0"(0xff), "m"(*addr) : "memory");
> +		: "0"((unsigned char)0xff), "m"(*addr) : "memory");
> return (AO_TS_VAL_t)oldval;
> }
> 
> diff -Naurp gc-7.1.orig/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86_64.h
> gc-7.1/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86_64.h
> --- gc-7.1.orig/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86_64.h
> 2008-01-05 19:34:51.000000000 -0800
> +++ gc-7.1/libatomic_ops-1.2/src/atomic_ops/sysdeps/gcc/x86_64.h	2011-06-24
> 10:01:59.000000000 -0700
> @@ -126,7 +126,7 @@ AO_test_and_set_full(volatile AO_TS_t *a
> /* Note: the "xchg" instruction does not need a "lock" prefix */
> __asm__ __volatile__("xchgb %0, %1"
> : "=q"(oldval), "=m"(*addr)
> -		: "0"(0xff), "m"(*addr) : "memory");
> +		: "0"((unsigned char)0xff), "m"(*addr) : "memory");
> return (AO_TS_VAL_t)oldval;
> }



More information about the Gc mailing list