Well, I had typed up this as a report but remembered being asked to write in forums before filing reports so here's what I was going to report.
---------------
assembler routines won't respect {$OPTIMIZATION STACKFRAME} and {$STACKFRAMES OFF} but respects nostackframe function modifier
---------------
In the following code with {$OPTIMIZATION STACKFRAME} and {$STACKFRAMES OFF}, if I leave commented out the "nostackframe;" function modifer the following code is generated:
push %ebp
mov %esp,%ebp
lea -0x4(%esp),%esp
add %edx,%eax
leave
ret
However, if I uncomment the "nostackframe;" function modifer the following code is generated:
add %edx,%eax
ret
From the documentation of {$STACKFRAMES OFF} it says it won't turn off stackframes for assembler routines. Alright then so that's why it doesn't work in this case. But the documentation of {$OPTIMIZATION STACKFRAME} does not mention what rules it follows.
In the end if {$OPTIMIZATION STACKFRAME} is completely identical to {$STACKFRAMES OFF} then it should be mentioned in the documentation, else if it's supposed to apply the "nostackframe;" to every function then it's not doing it to assembler routines.
--------------------------
program Project1;
{$APPTYPE GUI}
{$STACKFRAMES OFF}
{$INLINE ON}
{$MODE FPC}
{$ASMMODE INTEL}
{$MMX-}
{$FPUTYPE SSE2}
{$OPTIMIZATION LEVEL3}
{$OPTIMIZATION REGVAR}
{$OPTIMIZATION STACKFRAME}
{$OPTIMIZATION PEEPHOLE}
{$OPTIMIZATION ASMCSE}
{$OPTIMIZATION LOOPUNROLL}
{$OPTIMIZATION TAILREC}
{$OPTIMIZATION CSE}
{$OPTIMIZATION DFA}
{$OPTIMIZATION USEEBP}
{$OPTIMIZATION ORDERFIELDS}
{$OPTIMIZATION FASTMATH}
{$OPTIMIZATION REMOVEEMPTYPROCS}
{$OPTIMIZATION CONSTPROP}
function test_it(a,b:longint):longint;assembler;//nostackframe;
asm
add eax,edx
end;
procedure test;
begin
if test_it(10,20)<>30 then
halt(1);
end;
begin
test;
end.
----------------------------
So, the question is, should the "nostackframe" function modifier be required after specifying {$OPTIMIZATION STACKFRAME} and {$STACKFRAMES OFF}?