RE: Interactions between function inlining and inline assembly

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

 



On Tue, 14 Jan 2020, RECOULES Frederic wrote:

> Thank you for the answer.
> 
> Yet, I agree this example has no real meaning, but my question is,
> as v is already an address (global variable), why GCC prefers to
> copy the value pointed by v into the stack and give the new pointer
> rather than just give v directly?
> Is it to ensure the correctness of the code or just because nobody
> have met this strange configuration and so no optimisation was
> developed? 

I didn't dig deeply, but I think this is because high-level optimizations
don't distinguish "address taken, but not significant" vs. "address taken
and is significant" for inline asm. In your example, passing variable 'x'
to inline asm means its address is computed and given to the asm statement,
but the compiler conservatively considers the address can be used for any
purpose, including for comparison against addresses of other variables
(imagine &x != &v, which must evaluate to false). Hence the need to pass
an address of a copy, rather than the address of variable 'v'.

HTH
Alexander



[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