diff --git a/CGI.pas b/CGI.pas index 70ebee7..c6219f1 100644 --- a/CGI.pas +++ b/CGI.pas @@ -363,7 +363,6 @@ 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} {------------------------} diff --git a/Expression.pas b/Expression.pas index 045bd88..5ea6342 100644 --- a/Expression.pas +++ b/Expression.pas @@ -3463,8 +3463,6 @@ 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, diff --git a/Gen.pas b/Gen.pas index c3c3bdc..64dd28d 100644 --- a/Gen.pas +++ b/Gen.pas @@ -7623,7 +7623,7 @@ while bk <> nil do begin end; {while} bk := bk^.next; end; {while} -if saveStack or checkStack or (strictVararg and hasVarargsCall) then begin +if saveStack or checkStack then begin stackLoc := minSize; minSize := minSize + 2; localSize := localSize + 2; diff --git a/Native.pas b/Native.pas index f2ddb42..682b903 100644 --- a/Native.pas +++ b/Native.pas @@ -1963,7 +1963,7 @@ var begin {GenNative} { writeln('GenNative: ',p_opcode:4, ', mode=', ord(p_mode):1, ' operand=', p_operand:1); {debug} -if npeephole and not (strictVararg and hasVarargsCall) then begin +if npeephole then begin if (nnextspot = 1) and not (p_opcode in nleadOpcodes) then begin if p_opcode <> d_end then if registers then diff --git a/Parser.pas b/Parser.pas index 0501d0b..7025352 100644 --- a/Parser.pas +++ b/Parser.pas @@ -4035,7 +4035,6 @@ 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 diff --git a/Scanner.pas b/Scanner.pas index a4ba996..bc4ae4b 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -3542,8 +3542,6 @@ if ch in ['a','d','e','i','l','p','u','w'] then begin loopOptimizations := odd(val >> 5); strictVararg := not odd(val >> 6); fastMath := odd(val >> 7); - if saveStack then - npeepHole := false; if token.kind <> eolsy then Error(11); end {else if} diff --git a/cc.notes b/cc.notes index 586005f..80412a5 100644 --- a/cc.notes +++ b/cc.notes @@ -1460,7 +1460,9 @@ Contrary to all common sense, the ANSI standard says this statement is legal IF Beginning with ORCA/C 2.1, this statement will work. Note that in keeping with the ANSI standard, this call and others like it only work if the function is properly defined with a prototyped variable argument parameter list. -There are two undesirable side effects, though. First, all function calls to a variable argument function are surrounded by extra stack repair code, even if you set optimization bit 3. (This bit turns off stack repair code.) This increases code size and slows a program down. Sometimes these changes are noticeable, or even dramatic. Second, native code peephole optimization is always disabled when stack repair code is in use, so you loose another optimization if you do not use this one. +There is an undesirable side effect, though. All function calls to a variable argument function are surrounded by extra stack repair code, even if you set optimization bit 3. (This bit turns off stack repair code.) This increases code size and slows a program down. Sometimes these changes are noticeable, or even dramatic. + +Prior to ORCA/C 2.2.0 B7, native code peephole optimization was always disabled when stack repair code was in use, so you would also lose another optimization if you did not use this one. As of ORCA/C 2.2.0 B7, this is no longer the case: native code peephole optimization can be used without disabling stack repair code. Turning this optimization on means ORCA/C is no longer strictly in compliance with the ANSI standard. For strict compliance, you should leave stack repair code on for variable argument functions. You can add any or all of the other optimizations and remain ANSI compliant, so this pragma will work with all ANSI C programs: