This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: i386 flags register clober in inline assembly
- From: Jan Hubicka <jh at suse dot cz>
- To: Momchil Velikov <velco at fadata dot bg>
- Cc: linux-kernel at vger dot kernel dot org, gcc at gcc dot gnu dot org
- Date: Sat, 17 Nov 2001 16:14:36 +0100
- Subject: Re: i386 flags register clober in inline assembly
- References: <87y9l58pb5.fsf@fadata.bg>
>
> There are several inline assembly routines in the i386 port, which
> clobber the flags register, nevertheless fail to declare that.
> E.g. atomic_inc
>
> __asm__ __volatile__(
> LOCK "incl %0"
> :"=m" (v->counter)
> :"m" (v->counter));
>
> should be
>
> __asm__ __volatile__(
> LOCK "incl %0"
> :"=m" (v->counter)
> :"m" (v->counter)
> : "cc");
>
> since "incl" clobbers flags.
>
> Any ideas if these functions should be corrected ?
They don't need to be. On i386, the flags are (partly for historical reasons) clobbered
by default.
>
> Although gcc documentation says "cc" has no effect on some machines,
> it seems this is not the case with i386, judging from the "(set (reg:CC 17) ..."
> and "(clobber (reg:CC 17))" in i386.md.
i386.md does add the clobber to each asm statement.
Honza
>
> Regards,
> -velco
>