Re: [PATCH 3/8] i386: bitops: Rectify bogus "+m" constraints
From: Linus Torvalds
Date: Mon Jul 23 2007 - 13:46:53 EST
On Mon, 23 Jul 2007, Satyam Sharma wrote:
>
> [3/8] i386: bitops: Rectify bogus "+m" constraints
>
> From the gcc manual:
>
> Extended asm supports input-output or read-write operands. Use the
> constraint character `+' to indicate such an operand and list it with
> the output operands. You should only use read-write operands when the
> constraints for the operand (or the operand in which only some of the
> bits are to be changed) allow a register.
>
> So, using the "+" constraint modifier for memory, like "+m" is bogus.
> We must simply specify "=m" which handles the case correctly.
No. This is wrong.
"=m" means that the new value of the memory location is *set*.
Which means that gcc will potentially optimize away any previous stores to
that memory location.
And yes, it happens, and yes, we've seen it.
The gcc docs are secondary. They're not updated, they aren't correct, they
don't reflect reality, and they don't matter. The only correct thing to
use is "+m" for things like this, or alternatively to just use the
"memory" specifier at the end and make gcc generate really crappy code.
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/