Re: asm volatile("":::"memory) uncertainty.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jeff and Andrew,


On 5/10/2016 12:07 PM, Jeff Law wrote:
On 05/10/2016 10:05 AM, Andrew Haley wrote:
On 05/10/2016 04:58 PM, Tom Udale wrote:
To my mind, the only reason that these would not be considered "memory
references" is because the compiler has already decided to put the
memory into registers (true these are mostly automatic variables so they
can easily be put into registers).  But from an abstract machine
standpoint a=b is a memory read and a memory write is it not (or is that
a totally incorrect statement)?  It seems odd therefore that a register
allocation choice can fundamentally alter program behavior.

An auto variable is only considered to be "memory" if its address
is taken with & .  "memory" means that this object is reachable from
some pointer somewhere.
And note that there's a variety of analysis and transformations that
will try to eliminate the address-of so that the object is no longer
addressable.

Of course there is. I was about to posit that simply making a bunch of pointers to autos might have the desired effect but indeed my previous experience with gcc indicates it would not fall for this kind of trick.


Not really.  If a variable is not addressable by any means then it
can't be affected by a memory access.  Whether the compiler spills
that variable to a stack frame makes no difference.
Right.

Well, this is good. It at least means that things will not change willy-nilly based on optimization and that things are in fact set at the C level.


Thanks and
all the best,

Tom




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux