A question about "memory" clobbers in asm

Paul Koning pkoning@equallogic.com
Mon Sep 20 13:57:00 GMT 2004


>>>>> "tm" == tm gccmail <tm_gccmail@kloo.net> writes:

 tm> On Fri, 17 Sep 2004, Nathan Sidwell wrote:
 >> Jamie Lokier wrote: > I'm having trouble understand when it's
 >> appropriate to use a "memory" > clobber, when to use volatile, and
 >> when to use both.  The manual is > unclear to me.  Although I see
 >> that someone has tried to clarify it > since I last read it, it's
 >> still not obvious how "memory" is different > from `volatile'.
 >> 
 >> my understanding is
 >> 
 >> * volatile asm says something to the effect 'this changes state
 >> that you (the compiler) don't know about' -- such as writing to an
 >> IO port.
 >> 
 >> * memory clobber says 'this asm will change memory, so don't cache
 >> anything across this asm'.

 tm> This definition of memory clobbers is incomplete.

 tm> A memory clobber is required when the inline assembly either
 tm> reads from or writes to arbitrary memory or both. Not just
 tm> "writes to".

This means that the term "clobber" should be removed from the
description because it is seriously misleading.

	    paul



More information about the Gcc mailing list