Re: Compiler optimizing variables in inline assembly

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

 



On 02/21/2014 02:06 PM, Cody Rigney wrote:

> On Fri, Feb 21, 2014 at 4:53 AM, Andrew Haley <aph@xxxxxxxxxx> wrote:
>>
>> You can use a memory operand as an output, as in "=m"(*a) or simply
>> add "memory" to the clobber list.  And you must add all clobbered
>> registers to the clobber list.  Then it should work.
>>
> I added all the registers and "memory" to clobber and it worked!
> Since I think it's more efficient to specify which memory is changing,
> I'm going to give the "=m" (*a) a shot.  So even though you
> dereference the pointer, gcc will know the length of the memory(say 2
> bytes) that changes?  Or do you have to specify each index of the
> memory(e.g. char a[2]; ..... asm ... "=m" (*a), "=m" (*(a+1)))?

It's hard for me to give a 100% answer to that one, but GCC has an
idea what memory is reachable from every pointer.  So, this won't
clobber memory that's unreachable or has a different type from that
pointer.  It probably doesn't matter.

Andrew.


P.S.  Please don't top-post on GCC lists.  :-)




[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