kernel vm question

David Schultz das at FreeBSD.ORG
Sun Jan 30 19:53:13 PST 2005


On Fri, Jan 28, 2005, Dag-Erling Smrgrav wrote:
> des at des.no (Dag-Erling Smørgrav) writes:
> > David Schultz <das at FreeBSD.ORG> writes:
> > > When the line is there, the compiler is probably smart enough to
> > > realize that 'x=y; y=x' is (usually) a no-op, so it optimizes away
> > > both statements.
> > Wrong.  The compiler is free to optimize away the second statement
> > provided that neither x nor y is declared volatile, but it cannot
> > optimize away the first statement.
> 
> I should add: unless it can determine with absolute certainty that x
> is not referenced later.

Exactly.  Notice that this is indeed the case for Jaques' example.
I oversimplified a bit because, as I mentioned, this is a
digression from the main point about writing to the code segment.
There's no need to be curt.


More information about the freebsd-hackers mailing list