WTF lazarus
WTF lazarus
The code generation inlazarus fpc is just as broken as the Delphi one.
Case in point:
function Point(x,y: cardinal): TPoint; inline;
begin
//UInt64(Result):= UInt64(y * (1 shl 32)) + x;
Result.x:= x;
Result.y:= y;
end;
unit1.pas:44 pt:= Point(x,y);
89d8 mov eax,ebx
4863c0 movsxd rax,eax
48b9ffffffff00000000 mov rcx,0xffffffff
4821c8 and rax,rcx
48b900000000ffffffff mov rcx,0xffffffff00000000
4821c9 and rcx,rcx
4809c1 or rcx,rax
4863d2 movsxd rdx,edx
48c1e220 shl rdx,0x20
48b800000000ffffffff mov rax,0xffffffff00000000
4821c2 and rdx,rax
48b8ffffffff00000000 mov rax,0xffffffff
4821c1 and rcx,rax
4809d1 or rcx,rdx
48894df8 mov QWORD PTR [rbp-0x8],rcx
Is fpc writing war & peace here?
However with a little help it does do a reasonable job.
Uncomment the first line and disable line 2 and 3 above.
unit1.pas:44 pt:= Point(x,y);
000000010002C3E7 81e2ffffffff and edx,0xffffffff
000000010002C3ED 48c1e220 shl rdx,0x20
000000010002C3F1 89d8 mov eax,ebx
000000010002C3F3 488d0402 lea rax,[rdx+rax]
000000010002C3F7 488945f8 mov QWORD PTR [rbp-0x8],rax
There is still the useless and edx and the mov eax,ebx (really?)
And senseless stack smashing. But at least it is not totally hopeless.
The code generation in
Case in point:
function Point(x,y: cardinal): TPoint; inline;
begin
//UInt64(Result):= UInt64(y * (1 shl 32)) + x;
Result.x:= x;
Result.y:= y;
end;
unit1.pas:44 pt:= Point(x,y);
89d8 mov eax,ebx
4863c0 movsxd rax,eax
48b9ffffffff00000000 mov rcx,0xffffffff
4821c8 and rax,rcx
48b900000000ffffffff mov rcx,0xffffffff00000000
4821c9 and rcx,rcx
4809c1 or rcx,rax
4863d2 movsxd rdx,edx
48c1e220 shl rdx,0x20
48b800000000ffffffff mov rax,0xffffffff00000000
4821c2 and rdx,rax
48b8ffffffff00000000 mov rax,0xffffffff
4821c1 and rcx,rax
4809d1 or rcx,rdx
48894df8 mov QWORD PTR [rbp-0x8],rcx
Is fpc writing war & peace here?
However with a little help it does do a reasonable job.
Uncomment the first line and disable line 2 and 3 above.
unit1.pas:44 pt:= Point(x,y);
000000010002C3E7 81e2ffffffff and edx,0xffffffff
000000010002C3ED 48c1e220 shl rdx,0x20
000000010002C3F1 89d8 mov eax,ebx
000000010002C3F3 488d0402 lea rax,[rdx+rax]
000000010002C3F7 488945f8 mov QWORD PTR [rbp-0x8],rax
There is still the useless and edx and the mov eax,ebx (really?)
And senseless stack smashing. But at least it is not totally hopeless.
Maciej Izak Disagree, that's an interesting information. Thanks for sharing Johan Bontes
ReplyDeleteSébastien Paradis I do not claim that this is uninteresting, I saying that the absence of a report makes it useless.
ReplyDeleteMaciej Izak
ReplyDeleteDid you miss the part where this is marked as rant and not as bug?