lkml.org 
[lkml]   [2007]   [Jul]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 6/8] i386: bitops: Don't mark memory as clobbered unnecessarily
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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-07-24 23:35    [W:2.237 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site