I understand that noreturn should be used for functions which are expected to doesn't return control to the caller, but I can't find difference in generated assembler codes. Does anyone know examples which will generate different codes?
Edit: The noreturn does not generate cleanup code after it.
returns_twicedisables some gcc optimizations.As an example, in an old gcc version I have laying around: tail call optimization, global common subexpression elimination, jump bypassing.
returns_twiceusescalls_setjmpmachinery (all around the source tree):tco (
gcc/tree-tailcall.c):gcse (
gcc/gcse.c):jump-bypassing (
gcc/gcse.c):The function can be neither pure nor const (
gcc/ipa-pure-const.c):The function cannot be inlined (
gcc/tree-inline.c):It also affects the register save area in the function's stack frame.
Example(tco):
func.c:
tco.c:
doesn't return twice:
returns twice: