Previously it was 74 from GCC sources: * `gcc/config/loongarch/loongarch.h`: `#define FIRST_PSEUDO_REGISTER 74` * `gcc/defaults.h`: `#define DWARF_FRAME_REGISTERS FIRST_PSEUDO_REGISTER`
According to `loongarch.h`, 74 = 32 GPRs + 32 FPRs + 8 FCCs + 2 fake registers (arg pointer & frame pointer; they are GCC internals and not distinct physical registers). This is larger than what the current LoongArch DWARF spec (v20230425, [1]) says in Table 1: > DWARF Register Number >= 64 -- Reserved for future standard extensions And neither GCC nor LLVM generates debuginfo that references any register number >= 64, conforming to the spec. Considering that the FCCs are all temporary thus not participating in CFI or unwinding, and that the remaining 2 registers are not even physical, dropping the frame_nregs definition to 64 is safe and more conformant to the specs. [1]: https://github.com/loongson/la-abi-specs/blob/v2.50/ladwarf.adoc ChangeLog: * backends/loongarch_init.c (loongarch_init): Reduce frame_nregs to 64. Signed-off-by: WANG Xuerui <[email protected]> --- backends/loongarch_init.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backends/loongarch_init.c b/backends/loongarch_init.c index 35b453b74f29..9485ca38a3a4 100644 --- a/backends/loongarch_init.c +++ b/backends/loongarch_init.c @@ -51,8 +51,11 @@ loongarch_init (Elf *elf __attribute__ ((unused)), HOOK (eh, register_info); HOOK (eh, core_note); HOOK (eh, abi_cfi); - /* gcc/config/ #define DWARF_FRAME_REGISTERS. */ - eh->frame_nregs = 74; + /* Only the 32 GPRs and 32 FPRs have DWARF register numbers allocated, and + participate in unwinding. + See "DWARF for the LoongArch(tm) Architecture", v20230425: + https://github.com/loongson/la-abi-specs/blob/v2.50/ladwarf.adoc */ + eh->frame_nregs = 64; HOOK (eh, check_special_symbol); HOOK (eh, set_initial_registers_tid); HOOK (eh, return_value_location); -- 2.56.0
