LLVM: fix currency parameters passed on the stack on x86-64

Resolves #40496
This commit is contained in:
Jonas Maebe 2023-11-05 10:13:33 +01:00
parent 47825610b8
commit 0ca260e08c
2 changed files with 39 additions and 1 deletions

View File

@ -1855,7 +1855,7 @@ unit cpupara;
end;
{$endif not LLVM}
paraloc^.size:=def_cgsize(paraloc^.def);
{ s64comp is pushed in an int register }
{ s64comp/s64currency is pushed in an int register }
if paraloc^.size=OS_C64 then
begin
paraloc^.size:=OS_64;
@ -1972,6 +1972,15 @@ unit cpupara;
paraloc:=hp.paraloc[side].add_location;
paraloc^.loc:=LOC_REFERENCE;
paraloc^.def:=loc[locidx].def;
{ s64comp/s64currency are passed as integer types
(important for LLVM here) }
if paracgsize=OS_C64 then
begin
paraloc^.size:=OS_64;
paraloc^.def:=u64inttype;
end;
{Hack alert!!! We should modify int_cgsize to handle OS_128,
however, since int_cgsize is called in many places in the
compiler where only a few can already handle OS_128, fixing it

29
tests/webtbs/tw40496.pp Normal file
View File

@ -0,0 +1,29 @@
program llvmccy5ParamTest;
type
TTestObjFail = object
constructor Init(
P1, P2, P3, P4: Currency; P5: Currency);
end;
constructor TTestObjFail.Init(
P1, P2, P3, P4: Currency; P5: Currency);
begin
if p1<>1 then
halt(1);
if p2<>2 then
halt(2);
if p3<>3 then
halt(3);
if p4<>4 then
halt(4);
if p5<>5 then
halt(5);
end;
var
TestObj : TTestObjFail;
begin
TestObj.Init(1, 2, 3, 4, 5);
end.