On Thu, Feb 29, 2024 at 02:31:05PM +0100, Jan Hubicka wrote: > I agree that debugability of user core dumps is important here. > > I guess an ideal solution would be to change codegen of noreturn functions > to callee save all registers. Performance of prologue of noreturn > function is not too important. THen we can stop caller saving registers > and still get reasonable backtraces.
I don't think that is possible. While both C and C++ require that if [[noreturn]] attribute is used on some function declaration, it must be used on the first declaration and also if some function is [[noreturn]] in one TU, it must be [[noreturn]] in all other TUs which declare the same function. But, we have no such requirement for __attribute__((noreturn)), there it is a pure optimization, it can be declared just on the caller side as an optimization hint the function will not return, or just on the callee side where the compiler will actually verify it doesn't return, or both. And, the attribute is not part of function type, so even in standard C/C++, one can use extern void bar (); [[noreturn]] void foo () { for (;;) bar (); } void (*fn) () = foo; void baz () { fn (); } As you can call the noreturn function directly or indirectly, changing calling conventions based on noreturn vs. no-noreturn is IMHO not possible. Jakub