Matthieu Longo <matthieu.lo...@arm.com> writes:
> Architecture-specific CFI directives are currently declared an processed 
> among others architecture-independent CFI directives in gcc/dwarf2* files. 
> This approach creates confusion, specifically in the case of DWARF 
> instructions in the vendor space and using the same instruction code.
> Such a clash currently happen between DW_CFA_GNU_window_save (used on SPARC) 
> and DW_CFA_AARCH64_negate_ra_state (used on AArch64), and both having the 
> same instruction code 0x2d. Then AArch64 compilers generates a SPARC CFI 
> directive (.cfi_window_save) instead of .cfi_negate_ra_state, contrarily to 
> what is expected in [1].

The series LGTM, thanks.  OK for trunk if there are no objections
before Monday.

Richard

> 1. Rename REG_CFA_TOGGLE_RA_MANGLE to REG_CFA_NEGATE_RA_STATE
>
> This patch renames:
> - dwarf2out_frame_debug_cfa_toggle_ra_mangle to 
> dwarf2out_frame_debug_cfa_negate_ra_state,
> - REG_CFA_TOGGLE_RA_MANGLE to REG_CFA_NEGATE_RA_STATE,
> as the naming was misleading.
> The word "toggle" suggested a binary state, whereas this register stores the 
> mangling state (that can be more than 2 states) for the return address on 
> AArch64.
>
> 2. dwarf2: add hooks for architecture-specific CFIs
>
> This refactoring does not solve completely the problem, but improve the 
> situation by moving some of the processing of those directives (more 
> specifically their output in the assembly) to the backend via 2 target hooks:
> - DW_CFI_OPRND1_DESC: parse the first operand of the directive (if any).
> - OUTPUT_CFI_DIRECTIVE: output the CFI directive as a string.
> Only AArch64's and SPARC's backend are impacted.
>
> 3. aarch64 testsuite: explain expectections for pr94515*
> PR94515's tests in AArch64 G++ testsuite were lacking documentation. They are 
> now thoroughly documented.
>
> 4. dwarf2: store the RA state in CFI row
>
> On AArch64, the RA state informs the unwinder whether the return address is 
> mangled and how, or not. This information is encoded in a boolean in the CFI 
> row. This binary approach prevents from expressing more complex 
> configuration, as it is the case with PAuth_LR introduced in Armv9.5-A.
> This patch addresses this limitation by replacing the boolean by an enum.
>
>
> References:
> [1] DWARF for the Arm 64-bit Architecture (AArch64) --> 
> https://github.com/ARM-software/abi-aa/blob/main/aadwarf64/aadwarf64.rst
>
> ### Diff between revisions 1 & 2
>
> patch 1: no change.
> patch 2:
>   - fix issue with default hook signature for new hooks.
>   - code style formatting.
>   - change targetm.dw_cfi_oprnd1_desc signature to match the one of 
> dw_cfi_oprnd2_desc.
> patch 3:
>   - add comments suggested by Richard Sandiford in test case 
> gcc/testsuite/g++.target
>     /aarch64/pr94515-2.C.
> patch 4:
>   - code style formatting.
>
> ## Testing
>
> Built for target aarch64-unknown-linux-gnu and ran GCC's & G++'s testsuites 
> for AArch64.
> Built GCC stage 1 for target sparc64-unknown-linux-gnu.
>
>
> Ok for master? I don't have commit access so I need someone to commit on my 
> behalf.
>
> Regards,
> Matthieu.
>
> Matthieu Longo (4):
>   Rename REG_CFA_TOGGLE_RA_MANGLE to REG_CFA_NEGATE_RA_STATE
>   dwarf2: add hooks for architecture-specific CFIs
>   aarch64 testsuite: explain expectections for pr94515* tests
>   dwarf2: store the RA state in CFI row
>
>  gcc/combine-stack-adj.cc                     |  2 +-
>  gcc/config/aarch64/aarch64.cc                | 37 +++++++++++-
>  gcc/config/sparc/sparc.cc                    | 35 ++++++++++++
>  gcc/coretypes.h                              |  6 ++
>  gcc/doc/tm.texi                              | 16 +++++-
>  gcc/doc/tm.texi.in                           |  5 +-
>  gcc/dwarf2cfi.cc                             | 59 ++++++++++----------
>  gcc/dwarf2out.cc                             | 13 +++--
>  gcc/dwarf2out.h                              | 11 ++--
>  gcc/hooks.cc                                 | 14 +++++
>  gcc/hooks.h                                  |  3 +
>  gcc/reg-notes.def                            |  8 +--
>  gcc/target.def                               | 20 +++++++
>  gcc/testsuite/g++.target/aarch64/pr94515-1.C | 14 ++++-
>  gcc/testsuite/g++.target/aarch64/pr94515-2.C | 41 +++++++++++---
>  include/dwarf2.h                             |  5 ++
>  libffi/include/ffi_cfi.h                     |  2 +
>  libgcc/config/aarch64/aarch64-asm.h          |  4 +-
>  libitm/config/aarch64/sjlj.S                 | 10 ++--
>  19 files changed, 239 insertions(+), 66 deletions(-)

Reply via email to