Re: Optimization and inline assembly in GCC 4.0/MIPS

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

 



At 16 Oct 2006 11:52:49 -0700,
Ian Lance Taylor wrote:
> 
> You've told gcc that the inline assembler code cares about the value
> of 'm', but you haven't told it that it cares about the value of
> 'm[0]', 'm[1]', etc.
> 
> This exact case is covered in the documentation:
> 
>     Note that in the following example the memory input is necessary,
>     otherwise GCC might optimize the store to x away:
> 
>      int foo ()
>      {
>        int x = 42;
>        int *y = &x;
>        int result;
>        asm ("magic stuff accessing an 'int' pointed to by '%1'"
>              "=&d" (r) : "a" (y), "m" (*y));

OK, but in my case _syscall2 is generically defined so I cannot give
individual input restrictions. If I parse the documentation correctly,

   If your assembler instructions access memory in an unpredictable
   fashion, add `memory' to the list of clobbered registers.  This
   will cause GCC to not keep memory values cached in registers across
   the assembler instruction and not optimize stores or loads to that
   memory.

clobbering "memory" should then force GCC to avoid optimizing accesses
away ("not optimize stores or loads to that memory"). I think I
understand this now, thanks.

// Simon

[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