mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 20:09:19 +02:00
* Another attempt to fix x86_64 stack frame calculation, tested better this time.
git-svn-id: trunk@17709 -
This commit is contained in:
parent
70240bf212
commit
d4b2998e07
@ -42,6 +42,7 @@ implementation
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
systems,
|
systems,
|
||||||
|
globtype,
|
||||||
globals,
|
globals,
|
||||||
cutils,
|
cutils,
|
||||||
symconst,
|
symconst,
|
||||||
@ -52,9 +53,15 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if target_info.system=system_x86_64_win64 then
|
if target_info.system=system_x86_64_win64 then
|
||||||
begin
|
begin
|
||||||
|
{ Fixes the case when there are calls done by low-level means
|
||||||
|
(cg.a_call_name) but no child callnode }
|
||||||
|
if (pi_do_call in flags) then
|
||||||
|
allocate_push_parasize(32);
|
||||||
|
|
||||||
if not(po_assembler in procdef.procoptions) and
|
if not(po_assembler in procdef.procoptions) and
|
||||||
(tg.direction > 0) then
|
(tg.direction > 0) then
|
||||||
tg.setfirsttemp(tg.direction*maxpushedparasize+4*8);
|
{ maxpushedparasize already contains 32 bytes of spilling area }
|
||||||
|
tg.setfirsttemp(tg.direction*maxpushedparasize);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
tg.setfirsttemp(tg.direction*maxpushedparasize);
|
tg.setfirsttemp(tg.direction*maxpushedparasize);
|
||||||
@ -72,10 +79,15 @@ implementation
|
|||||||
function tx86_64procinfo.calc_stackframe_size:longint;
|
function tx86_64procinfo.calc_stackframe_size:longint;
|
||||||
begin
|
begin
|
||||||
maxpushedparasize:=align(maxpushedparasize,max(current_settings.alignment.localalignmin,16));
|
maxpushedparasize:=align(maxpushedparasize,max(current_settings.alignment.localalignmin,16));
|
||||||
{ RSP should be aligned on 16 bytes }
|
{ Note 1: when tg.direction>0, tg.lasttemp is already offset by maxpushedparasize
|
||||||
result:=Align(tg.direction*tg.lasttemp+maxpushedparasize,16);
|
(because tg.setfirsttemp also sets lasttemp)
|
||||||
if target_info.system=system_x86_64_win64 then
|
Note 2: Align to 8 bytes here. The final 16-byte alignment is handled in
|
||||||
inc(result,4*8);
|
tcgx86.g_proc_entry, which considers saved rbp and the misalignment
|
||||||
|
caused by the call itself. }
|
||||||
|
if (tg.direction>0) then
|
||||||
|
result:=Align(tg.lasttemp,8)
|
||||||
|
else
|
||||||
|
result:=Align(tg.direction*tg.lasttemp+maxpushedparasize,8);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user