Linus Torvalds wrote:
> Sure, that's *one* thing that "volatile" guarantees (it guarantees that
> gcc won't optimize away things where the end result isn't actually visibly
> used).
>
> But gcc docs also talk about the other things volatile means, including
> "not significantly moved".
>
Actually, it doesn't. In fact it goes out of its way to say that "asm
volatile" statements can be moved quite a bit, with respect to other
asms, other code, jumps, basic blocks, etc. The only reliable way to
control the placement of an asm is have the right dependencies.
The `volatile' keyword indicates that the instruction has important
side-effects. GCC will not delete a volatile `asm' if it is reachable.
(The instruction can still be deleted if GCC can prove that
control-flow will never reach the location of the instruction.) Note
that even a volatile `asm' instruction can be moved relative to other
code, including across jump instructions.
also:
An `asm' instruction without any output operands will be treated
identically to a volatile `asm' instruction.
So there isn't anything very special about "asm volatile". It's purely
to stop apparently useless code from being removed.
J
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]