https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103510

--- Comment #4 from ashimida <ashimida at linux dot alibaba.com> ---
(In reply to Andrew Pinski from comment #3)
> The only registers which are saved are the callee saved register IIRC. So
> you need to know the ABI.

Thanks Andrew,

I saw the following description in the IA-64 C++ ABI [1]:
"All registers specified as callee-saved by the base ABI are restored,
as well as scratch registers GR15, GR16, GR17 and GR18 (see below). 
Except for those exceptions, scratch (or caller-saved) registers are
not preserved, and their contents are undefined on transfer."

My understanding is that the ABI states that 4 scratch registers and
callee-saved need to be 'restored' before transferring conrtrol to
landing pad. But AFAIK, the ABI does not specify whether unwind should
'initialize' all registers to context->reg[] at the beginning (please
correct me if it's wrong).

One more thing is that _Unwind_Backtrace seems to be defined in the LSB
standard (I did't find its definition in the IA-64 C++ ABI).

PS:
The reason why I am struggling with this detail is because a similar case
happened when I try to support the unwind for SCS[2] on aarch64, I found
that uw_init_context_1 did not save all the registers, which would cause
a crash when a ".cfi_escape 0x16, 0x12, 0x02, 0x82, 0x78" directive
(means x18 -= 8) was executed, which would not happen in clang.

Initializing non-call-saved registers in uw_init_context_1 can solve
those issue, but i'm not sure enough if this breaks the ABI rules.

[1] https://itanium-cxx-abi.github.io/cxx-abi/abi-eh.html
[2] https://gcc.gnu.org/pipermail/gcc-patches/2021-November/585199.html

Reply via email to