-O2/-O3 Optimization bug?
Mike
none at none.com
Thu Jan 23 03:30:41 PST 2014
On Wednesday, 22 January 2014 at 15:03:49 UTC, Johannes Pfau
wrote:
> I can only guess, but this looks like another 'volatile'
> problem. You'd
> have to post the ASM of the optimized version somewhere, and
> probably
> the output of -fdump-tree-optimized for the optimized version.
Here's the output with -fdump-tree-optimized
*******
;; Function start.OnReset (OnReset, funcdef_no=1, decl_uid=3544,
cgraph_uid=1) (executed once)
start.OnReset ()
{
uint message[3];
<bb 2>:
<bb 3>:
__asm__ __volatile__("mov r0, %[cmd];
mov r1, %[msg];
bkpt #0xAB" : : "cmd" "r" 5, "msg" "r" &message : "r0",
"r1", "r1");
<bb 4>:
goto <bb 3>;
}
;; Function start.SendCommand (_D5start11SendCommandFiPvZv,
funcdef_no=0, decl_uid=3545, cgraph_uid=0)
start.SendCommand (int command, void * message)
{
<bb 2>:
__asm__ __volatile__("mov r0, %[cmd];
mov r1, %[msg];
bkpt #0xAB" : : "cmd" "r" command_1(D), "msg" "r"
message_2(D) : "r0", "r1", "r1");
return;
}
*******
Here's the output of the unoptimized version
*******
;; Function start.SendCommand (_D5start11SendCommandFiPvZv,
funcdef_no=0, decl_uid=3545, cgraph_uid=0)
start.SendCommand (int command, void * message)
{
<bb 2>:
__asm__ __volatile__("mov r0, %[cmd];
mov r1, %[msg];
bkpt #0xAB" : : "cmd" "r" command_1(D), "msg" "r"
message_2(D) : "r0", "r1", "r1");
return;
}
;; Function start.OnReset (OnReset, funcdef_no=1, decl_uid=3544,
cgraph_uid=1)
start.OnReset ()
{
uint message[3];
<unnamed type> D.3562;
<unnamed type> _1;
<bb 2>:
message = *.LC1;
<bb 3>:
_1 = 0;
if (_1 != 0)
goto <bb 5>;
else
goto <bb 4>;
<bb 4>:
start.SendCommand (5, &message);
goto <bb 3>;
<bb 5>:
message ={v} {CLOBBER};
return;
}
********
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?
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
**********
And here's the unoptimized assembly for comparison
**********
http://pastebin.com/hbThtCsP
**********
Thanks for taking the time.
Mike
More information about the D.gnu
mailing list