-O2/-O3 Optimization bug?

Johannes Pfau nospam at example.com
Thu Jan 23 08:55:47 PST 2014


Am Thu, 23 Jan 2014 11:30:41 +0000
schrieb "Mike" <none at none.com>:

> 
> The __asm__ __volatile__ seems to indicate Iain is right.  Notice 
> the message = *.LC1 in the unoptimized version, but not the 
> optimized version.  This is the first time I've seen this kind of 
> output, so can you decipher what's going on?

We can see a few things in that output:
 * The function really got inlined
 * The ASM is still there and marked as volatile
 * In the optimized version, the ubyte[3] message 
   variable is still there, but it's not initialized
   (message =*.LC1 is pseudo code for 'initialize message on the
   stack with the data stored at .LC1') 

> And here's the optimized assembly.  I'm not sure how to do this, 
> so I used -fverbose-asm -Wa,-adhln
> **********
> http://pastebin.com/NY2PNWzS
> **********

Nice, I always used -S but this output is better of course ;-)


I think what could be happening here is that GCC doesn't know what
memory you're accessing via the message pointer in SendCommand.

See http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
and search for "If your assembler instructions access memory in an
unpredictable fashion"

Maybe typing "message" as uint* or uint[3]* instead of void* is already
good enough. Otherwise try using a memory input as described on that
page.


More information about the D.gnu mailing list