[fpc-devel] A bug with temp allocation?

Peter Vreman peter at freepascal.org
Sun Nov 18 23:11:36 CET 2007


> Hello,
>
> I have noticed a strange thing with FPC-generated assembler code.
> The Pascal code is very simple:
>
> program test;
> {$mode objfpc}{$h+}
> type
>    TObj = class(TObject)
>    public
>      destructor Destroy; override;
>    end;
>
> destructor TObj.Destroy;
> begin
>    writeln('TObj.Destroy');
> end;
>
> begin
> end.
>
> I compiled with 'fpc test.pp -a -AMASM -al -s -O1'.
>
> The generated assembler code follows below. Look at the prologs/epilogs.
> When compiled with -O1, there are 16 bytes allocated at the stack, but
> location [ebp-12] is never used.
> When compiled with -O2, however, allocation increases to 32 bytes, but
> still only three DWORDs (12 bytes) are used, remaining 20 bytes look
> just wasted.
>
> Is this subject for a bug report?

Fixed in r9293. There was a duplicate temp allocation.

That 16 bytes instead of 12 bytes are allocated comes from alignment.


Peter





More information about the fpc-devel mailing list