Register usage with -gt [Re: [fpc-devel] crash with -gt -O2 (regvar) in trunk]

Martin fpc at mfriebe.de
Mon Jun 7 19:04:10 CEST 2010


I found another thing, I don't understand (or I suspect to be not ok)
( see also the 0 initialization by -gt as indicated in the other mail / 
below)


First method in buttons.pp

.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

The code is identical between with/withou -gt => except for :
     movl    $0,%edx

which is inserted by -gt
But edx isn't used at all (the call returns it's result in eax)?

So why trashing it, and why with 0?

Martin

On 07/06/2010 17:44, Martin wrote:
> On 06/06/2010 20:44, Martin wrote:
>> On 05/06/2010 19:57, Jonas Maebe wrote:
>>>
>>> One thing that was added is the node level CSE optimiser. You can 
>>> disable it with the -Oonocse command line option (put it in the 
>>> command line after -O2). There are no changes to -gt that I remember.
>>>
>>
> Comparing the assembler of the same file with and without -gt I noted 
> soemthing else, I am not sure about
>
> local vars are:
>   GlyphValid, Handled: Boolean;
>   CustomGlyph: TGraphic;
>   BitmapHandle, MaskHandle: HBitmap;
>
> As expected the begin of the method is equal, I only copied it for 
> completeness
>
> .section .text.n_buttons_tcustombitbtn_$__realizekind
>     .balign 16,0x90
>     .balign 16,0x90
> .globl    BUTTONS_TCUSTOMBITBTN_$__REALIZEKIND
> BUTTONS_TCUSTOMBITBTN_$__REALIZEKIND:
> .Lc82:
> # Temps allocated between ebp-76 and ebp-12
> # path: .\include\
> # file: bitbtn.inc
> # indx: 2
> .Ll204:
> # [184] begin
>     pushl    %ebp
> .Lc84:
> .Lc85:
>     movl    %esp,%ebp
> .Lc86:
>     subl    $76,%esp
> # Var $self located in register eax
> # Var GlyphValid located in register al
> # Var CustomGlyph located in register esi
>     movl    %ebx,-76(%ebp)
>     movl    %esi,-72(%ebp)
>     movl    %edi,-68(%ebp)
> # Var Handled located at ebp-4
> # Var BitmapHandle located at ebp-8
> # Var MaskHandle located at ebp-12
>     movl    %eax,-60(%ebp)
> # ============================= here starts the difference
> # here is the trashing of locals
>
> .Ll205:
>     movb    $85,-64(%ebp)
>     movb    $85,-4(%ebp)
>     movl    $0,%esi  # <<<<<<<<<<<<<<<<<<<
>     movl    $1431655765,-8(%ebp)
>     movl    $1431655765,-12(%ebp)
>
>
> The line I marked trashes " CustomGlyph: TGraphic"
>
> Other objects are trashed with 1431655765 , but this one is trashed 
> with $0 ? (that isn't really trash?)
>
> Martin
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel




More information about the fpc-devel mailing list