[Bug rtl-optimization/38534] gcc 4.2.1 and above: No need to save called-saved registers in 'noreturn' function
lukas.graetz@tu-darmstadt.de
gcc-bugzilla@gcc.gnu.org
Thu Feb 29 20:12:56 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=38534
--- Comment #45 from Lukas Grätz <lukas.graetz@tu-darmstadt.de> ---
(In reply to Jakub Jelinek from comment #28)
> (In reply to Lukas Grätz from comment #9)
> > Well it is not my testcase. But I added backtracing and observed that the
> > printed backtrace is unchanged with your patch. The new
> > no_return_to_caller():
>
> You haven't tried hard enough.
> Consider the testcase I've posted to the mailing list, built with -Og -g.
> It is artificial in that register pressure is increased artificially rather
> than coming from meaningful code, noipa attribute is used heavily instead of
> functions being too large or in different TUs, and optimize attribute used
> instead of the noreturn function sitting in a different library, built there
> with -O2, while user program say with -Og.
I found a
movq %rsp, %rbp
.cfi_def_cfa_register 6
in the assembler output of your example code in function qux(). After that, the
value of %rsp is only reconstructable with %rbp. Because there is some alloca
with unkown size at compile time in qux(), we could not reconstruct %rsp
otherwise. So I was ultimately wrong, and the value of %rbp would be needed to
construct the backtrace in some cases. So the only option to still get the
backtrace is to apply your patch to save %rbp (given that .cfi_def_cfa_register
always points to %rbp).
But I guess you know that already.
More information about the Gcc-bugs
mailing list