Good morning everyone!
Here's a simple testcase that illustrates what I'm observing in gcc-3.3.3 -----------------------------<snip>----------------------------- extern void abort (void) __attribute ((noreturn)); int foo (int a, int b) { if (a > 25) abort (); return (a + b); } int bar (int a, int b) { if (a > 25) a++; return (a + b); } -----------------------------<snip>----------------------------- Function bar() is clearly a leaf function, so at stackframe layout time I get called with current_function_is_leaf == 1, and since it uses no nonvolatile registers I get a function with no stackframe, no registers saved, no prologue and nothing but a ret insn in the epilog. Function foo() is not regarded as a leaf function, because it calls abort, and so my prologue generation code believes it has to create a stack frame just to save the link register. However, abort is clearly marked noreturn:- -----------------------------<snip>----------------------------- ;(call_insn 13 31 14 0x0 (parallel [ ; (call (mem:SI (symbol_ref:SI ("abort")) [0 S4 A32]) ; (const_int 0 [0x0])) ; (clobber (reg:SI 15 r15)) ; ]) 36 {call} (nil) ; (expr_list:REG_UNUSED (reg:SI 15 r15) ; (expr_list:REG_NORETURN (const_int 0 [0x0]) ; (expr_list:REG_EH_REGION (const_int 0 [0x0]) ; (nil)))) ; (nil)) -----------------------------<snip>----------------------------- and without this call it would clearly be a leaf function, and since this call is noreturn we could in fact still treat it as a leaf function. Is there some complication that I haven't realised why noreturn function calls can't be disregarded in deciding whether or not a function is leaf? Taking a look at leaf_function_p, I see that it specifically discounts sibcalls; why not noreturncalls as well? cheers, DaveK -- Can't think of a witty .sigline today....