This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH][SH] atomicity.h bug fix
- From: Kaz Kojima <kkojima at rr dot iij4u dot or dot jp>
- To: ams at codesourcery dot com
- Cc: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Sat, 12 Sep 2009 08:59:58 +0900 (JST)
- Subject: Re: [PATCH][SH] atomicity.h bug fix
- References: <4AAA65E1.7040606@codesourcery.com>
[CC to libstdc++ list]
Andrew Stubbs <ams@codesourcery.com> wrote:
> This patch fixes a bug that can cause bad code at -O2 and above.
>
> The problem is that the inline assembler can be given the same
> register for an input and a (different) output. This is not a
> problem if the outputs are only made after all the inputs have been
> read, but one is not, so an 'early clobber' constraint is required.
>
> OK?
OK. Thanks for the patch!
Regards,
kaz
> 2009-09-11 Andrew Stubbs <ams@codesourcery.com>
>
> * config/cpu/sh/atomicity.h (__exchange_and_add): Set earlyclobber
> constraint.
>
> --- a/libstdc++-v3/config/cpu/sh/atomicity.h
> +++ b/libstdc++-v3/config/cpu/sh/atomicity.h
> @@ -44,7 +44,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
> "\tadd\t%3,r0\n"
> "\tmovco.l\tr0,@%2\n"
> "\tbf\t0b"
> - : "+m" (*__mem), "=r" (__result)
> + : "+m" (*__mem), "=&r" (__result)
> : "r" (__mem), "rI08" (__val)
> : "r0");