This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] fix expand_builtin_init_dwarf_reg_sizes wrt register spans


Hello,

Exception propagation has been failing for a while for the SPE/e500 family of
powerpc targets. The issue boils down to an assert failure through:

    uw_init_context_1 ()
    ...
    _Unwind_SetSpColumn (context, outer_cfa, &sp_slot);

then

    _Unwind_SetSpColumn ()
    ...
    int size = dwarf_reg_size_table[__builtin_dwarf_sp_column ()];

    if (size == sizeof(_Unwind_Ptr))
       tmp_sp->ptr = (_Unwind_Ptr) cfa;
    else
      {
        gcc_assert (size == sizeof(_Unwind_Word));

Indeed, dwarf_reg_size_table[sp] is 8 while sizeof(_Unwind_Word) and
sizeof(_Unwind_Ptr) are both 4. dwarf_reg_size[sp] 8 is an outcome of:

  commit 275035b56823b26d5fb7e90fad945b998648edf2
  Date:   Thu Sep 5 14:09:07 2013 +0000

       PR target/58139
       * reginfo.c (choose_hard_reg_mode): Scan through all mode classes
       looking for widest mode.

choose_hard_reg_mode returning 8 for register r1 is not incorrect per se,
I think.

The problem, IMO, is expand_builtin_init_dwarf_reg_sizes ignoring the
targetm.dwarf_register_span hook, unlike other functions in dwarf2outcfi.c.

This patch is a proposal to fix this.

The general idea is isolate the dwarf_reg_size computation for a single
register in a separate function, called either for the "current" register
if it doesn't span, or for each items of the span otherwise.

Working on this, I noticed that expand_builtin_init_dwarf_reg_sizes was
also not honoring DWARF_REG_TO_UNWIND_COLUMN. ISTM that it should so the
patch adjusts on this front as well.

We have been using a slight variant of this in production for a few months
on a gcc-4.9 base. Our 4.9 patch required adjustment to account for the
introduction of the dwarf_frame_reg_mode hook on mainline in the interim.

Tested by verifying that the proper size is stored for GPRs on
powerpc-eabispe, then with bootstrap and regtest for languages=all,ada on
x86_64-linux.

OK to commit ?

Thanks in advance for your feedback,

With Kind Regards,

Olivier

2014-09-30  Olivier Hainque  <hainque@adacore.com>

        libgcc/
        * unwind-dw2.c (DWARF_REG_TO_UNWIND_COLUMN): Move default def to ...

        gcc/
        * defaults.h: ... here.
        * dwarf2cfi.c (init_one_dwarf_reg_size): New helper, processing
        one particular reg for expand_builtin_init_dwarf_reg_sizes. Apply
        DWARF_REG_TO_UNWIND_COLUMN.
        (expand_builtin_init_dwarf_reg_sizes): Rework to use helper and
        account for dwarf register spans.

Attachment: cfispan.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]