Fix varargs stack repair.

Varargs-only stack repair (i.e. using #pragma optimize bit 3 but not bit 6) was broken by commit 32975b720f. It removed some code that was needed to allocate the direct page location used to hold the stack pointer value in that case. This would lead to invalid code being produced, which could cause a crash when run. The fix is to revert the erroneous parts of commit 32975b720f (which do not affect its core purpose of enabling intermediate code peephole optimization to be used when stack repair code is active).
This commit is contained in:
Stephen Heumann 2023-01-08 15:15:32 -06:00
parent 74b9885572
commit 2958619726
4 changed files with 5 additions and 1 deletions

View File

@ -364,6 +364,7 @@ var
symLength: integer; {length of debug symbol table}
toolParms: boolean; {generate tool format parameters?}
volatile: boolean; {has a volatile qualifier been used?}
hasVarargsCall: boolean; {does current function call any varargs fns?}
{desk accessory variables}
{------------------------}

View File

@ -3508,6 +3508,8 @@ var
Gen1tName(pc_cup, ord(hasVarargs and strictVararg),
UsualUnaryConversions, fname);
end; {else}
if hasVarargs then
hasVarargsCall := true;
end {if}
else
GenTool(pc_tl1, ftype^.toolNum, long(ftype^.ftype^.size).lsw,

View File

@ -7679,7 +7679,7 @@ while bk <> nil do begin
end; {while}
bk := bk^.next;
end; {while}
if saveStack or checkStack then begin
if saveStack or checkStack or (strictVararg and hasVarargsCall) then begin
stackLoc := minSize;
minSize := minSize + 2;
localSize := localSize + 2;

View File

@ -4019,6 +4019,7 @@ if isFunction then begin
end; {if}
Gen2Name(dc_str, segType, 0, fName);
doingMain := variable^.name^ = 'main';
hasVarargsCall := false;
firstCompoundStatement := true;
Gen0 (dc_pin);
if not isAsm then