[fpc-devel] about bug 0016668 (-gt -O2)

Martin fpc at mfriebe.de
Tue Jun 8 17:03:34 CEST 2010


On 08/06/2010 15:46, Jonas Maebe wrote:
>
> On 08 Jun 2010, at 16:35, Martin wrote:
>
>> There is also the fact that -gt (at least if used with -O2) in some 
>> cases initializes (or zero-trashes) edx, even if edx is not used at 
>> all in the procedure
>>    movl    $0,%edx
>> There may be a reason for this, which I don't know?
>
> It can be due to an unused local variable.
>
Here is the example again (from lcl buttons.pp)

According to the comments on top, there is nothing in edx (and the " 
movl    $0,%edx " is only present if compiled with -gt).

That is, of course the local var, that would have gone into edx, may 
have been optimized away:
- The part of the compiler writing the comments, may have been aware of that
- -gt may not have been aware of that

I don't know, if edx needs to be saved on the stack, if it is used by 
the method? I have seen that other registers are usually saved on the 
stack, before they get used?
In the case below edx does not get saved.

.section .text.n_buttons_getlcldefaultbtnglyph$tbitbtnkind$$tgraphic
     .balign 16,0x90
     .balign 16,0x90
.globl    BUTTONS_GETLCLDEFAULTBTNGLYPH$TBITBTNKIND$$TGRAPHIC
BUTTONS_GETLCLDEFAULTBTNGLYPH$TBITBTNKIND$$TGRAPHIC:
.Lc1:
# Temps allocated between esp+0 and esp+0
# Var Kind located in register eax
# Var $result located in register eax
# [buttons.pp]
# [452] begin
.Ll1:
     movl    $0,%edx
.Ll2:
# [453] Result := GetDefaultButtonIcon(BitBtnImages[Kind]);
     movl    TC_BUTTONS_BITBTNIMAGES(,%eax,4),%eax
     call    BUTTONS_GETDEFAULTBUTTONICON$LONGINT$$TCUSTOMBITMAP
.Ll3:
# [454] end;
     ret



More information about the fpc-devel mailing list