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? ________________________________________ From: Segher Boessenkool [segher@xxxxxxxxxxxxxxxxxxx] Sent: Tuesday, January 14, 2020 1:33 PM To: RECOULES Frederic Cc: gcc-help@xxxxxxxxxxx Subject: Re: Interactions between function inlining and inline assembly Hi! On Tue, Jan 14, 2020 at 11:54:00AM +0000, RECOULES Frederic wrote: > Let use the following (dumb) snippet as an example: > > static int foo (int x) > { > int r; > __asm__ ("movl %1, %0" : "=r" (r) : "m" (x)); > return r; > } > > int v; > > int main (int argc, char *argv[]) > { > return foo(v); > } > > Which when compiled with GCC 9.2 (as long as I know, version does not matter) > -m32 -O3 produce the following code: > > main: > subl $16, %esp > movl v, %eax > movl %eax, 12(%esp) > #APP > movl 12(%esp), %eax > #NO_APP > addl $16, %esp > ret > > > So, even if the function call is inlined, it continues to pass the argument v > by the stack while, in fact, I would have expected it to forward the > address like this: > > main: > #APP > movl v, %eax > #NO_APP > ret But you said that assembler argument has to be in memory! Try this: static int foo (int x) { int r; __asm__ ("movl %1, %0" : "=r" (r) : "rm" (x)); return r; } You could also use "rmi" (which can be written "g"), here. Segher