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


On Tue, 24 Jul 2007, Andi Kleen wrote:
>
> Linus Torvalds <torvalds@linux-foundation.org> writes:
> >
> > (Yes, the "asm volatile" may do so too, but it's very unclear what the
> > "volatile" on the asm actually does, so ..)
>
> Without the volatile they get completely optimized away :/
> [tried that, cost a lot of debugging time -- empty string functions
> cause a lot of strange side effects]

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".

Is that "not significantly moved" already equivalent to "not moved past
something that can change memory"? Probably not. Which is why it's a good
idea to have the "memory" clobber there too, because the semantics of the
"volatile" just aren't very well defined from a code movement standpoint
(while a general memory clobber is *very* clear: if gcc moves the inline
asm across another thing that uses/changes memory, that's a gcc bug, plain
and simple (*)).

Linus

(*) Other than pure internal gcc spills/reloads. Spilling/reloading local
registers that haven't had their address taken obviously cannot be seen as
memory accesses.
-
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 22:13    [W:0.140 / U:4.452 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site