Don't allocate stack space for varargs stack repair unless it's needed.

If there are no varargs calls (and nothing else that saves stack positions), then space doesn't need to be allocated for the saved stack position. This can also lead to more efficient prolog/epilog code for small functions.
This commit is contained in:
Stephen Heumann 2018-01-13 20:02:43 -06:00
parent f24f37aa9f
commit 4a7644e0b5
4 changed files with 5 additions and 1 deletions

View File

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

View File

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

View File

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

View File

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