From: "H.J. Lu" <hjl.tools@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] x86: Generate .cfi_undefined for unsaved callee-saved registers
Date: Mon, 29 Jan 2024 08:03:56 -0800 [thread overview]
Message-ID: <CAMe9rOpxBBX5HK690=i9oqqumAi2vdMHAD1yGMpSojTm-OhS-Q@mail.gmail.com> (raw)
In-Reply-To: <Zbd5Fj/j7zJhY/4s@tucnak>
On Mon, Jan 29, 2024 at 2:08 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Sat, Jan 27, 2024 at 12:41:24PM -0800, H.J. Lu wrote:
> > When assembler directives for DWARF frame unwind is enabled, generate
> > the .cfi_undefined directive for unsaved callee-saved registers which
> > have been used in the function.
> >
> > gcc/
> >
> > PR target/38534
> > * config/i386/i386.cc (ix86_post_cfi_startproc): New.
> > (TARGET_ASM_POST_CFI_STARTPROC): Likewise.
> >
> > gcc/testsuite/
> >
> > PR target/38534
> > * gcc.target/i386/no-callee-saved-19.c: New test.
> > * gcc.target/i386/no-callee-saved-20.c: Likewise.
> > * gcc.target/i386/pr38534-7.c: Likewise.
> > * gcc.target/i386/pr38534-8.c: Likewise.
>
> This only works for -fdwarf2-cfi-asm, but doesn't work for
> -fno-dwarf2-cfi-asm. I think we need something that will work for both.
-fno-dwarf2-cfi-asm stops generating all CFI directives.
> So, I'd say we want to add support for REG_CFA_UNDEFINED note, emit those
> notes on some frame related insn in the prologue during prologue expansion
> in pro_and_epilogue pass and handle that in dwarf2cfi.cc pass.
It is a good idea. Here is the patch:
https://patchwork.sourceware.org/project/gcc/list/?series=30314
> One question is where those should be emitted. Emitting them right
> at the start of the function has an advantage that it can be emitted in
> CIE for all FDEs of noreturn functions (or with the new attribute). But
> disadvantage is of course that it will make e.g. debugging experience worse
> even in the prologues of functions where the callee saved registers which
> current function actually doesn't save aren't modified yet.
> E.g. for the cases where callee saved registers are saved to memory or
> registers I think dwarf2cfi.cc attempts to optimize and move the .cfi_*
> directives or .eh_frame record later into the function as long as the
> corresponding original register isn't modified yet. Perhaps that should
> be done also for the undefined case, ideally by using the same dwarf2cfi.cc
> code. So just perhaps at the start of the function read in the
> REG_CFA_UNDEFINED notes for all the ever modified callee saved registers
> which won't be actually saved and turn that into similar record like for
> the saving into stack or other regs, just noting it is undefined instead
> and have it pushed later as much as possible.
My patch doesn't implement this optimization.
--
H.J.
prev parent reply other threads:[~2024-01-29 16:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-27 20:41 H.J. Lu
2024-01-29 10:08 ` Jakub Jelinek
2024-01-29 16:03 ` H.J. Lu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMe9rOpxBBX5HK690=i9oqqumAi2vdMHAD1yGMpSojTm-OhS-Q@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).