public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Hongtao Liu <crazylht@gmail.com>
Cc: Jakub Jelinek <jakub@redhat.com>,
	Richard Biener <richard.guenther@gmail.com>,
	 Uros Bizjak <ubizjak@gmail.com>, Jan Hubicka <jh@suse.cz>,
	gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] i386: Guard noreturn no-callee-saved-registers optimization with -mnoreturn-no-callee-saved-registers [PR38534]
Date: Thu, 29 Feb 2024 04:26:00 -0800	[thread overview]
Message-ID: <CAMe9rOp0thPFO29D+f32XTt3Nsek6ihap_U=R5p2gisOkHhvAQ@mail.gmail.com> (raw)
In-Reply-To: <CAMZc-bzPiYq_TYXc8=EJOqRnOOHoeZ5efT-T2ibBpP769b2LJA@mail.gmail.com>

On Wed, Feb 28, 2024 at 10:20 PM Hongtao Liu <crazylht@gmail.com> wrote:
>
> On Wed, Feb 28, 2024 at 4:54 PM Jakub Jelinek <jakub@redhat.com> wrote:
> >
> > Hi!
> >
> > Adding Hongtao and Honza into the loop as the ones who acked the original
> > patch.
> >
> > The no_callee_saved_registers by default for noreturn functions change can
> > break in-process backtrace(3) or backtraces from debugger or other process
> > (quite often, any time the noreturn function decides to use the bp register
> > and any of the parent frames uses a frame pointer; the unwinder just crashes
> > in the libgcc unwinder case, gdb prints stack corrupted message), so I'd
> > like to save bp register in that case:
> >
> > https://gcc.gnu.org/pipermail/gcc-patches/2024-February/646591.html
> I think this patch makes sense and LGTM, we save and restore frame
> pointer for noreturn.
> >
> > and additionally the no_callee_saved_registers by default for noreturn
> > functions change can make debugging harder, again not localized to the
> > noreturn function, but any of its callers.  So, if say glibc abort function
> > implementation needs a lot of normally callee-saved registers, no matter how
> > users recompile their apps, they will see garbage or optimized out
> > vars/parameters in their code unless they rebuild their glibc with -O0.
> > So, I think we should guard that by a non-default option:
> >
> > https://gcc.gnu.org/pipermail/gcc-patches/2024-February/646649.html
> So it turns off the optimization for noreturn functions by default,
> I'm not sure about this.
> Any comments, H.J?

We need BP for backtrace.  I don't think we need to save other
registers.  True, GDB may not see function parameters.  But
optimization always has this impact.  When I need to debug a
program, I always use -O0 or -Og.

> >
> > Plus we need to somehow make sure to emit DW_CFA_undefined for the modified
> > but not saved normally callee-saved registers, so that we at least don't get
> > garbage in debug info.  H.J. posted some patches for that, so far I wasn't
> > happy about the implementation but the actual change is desirable.
> >
> > Your thoughts on this?
> >
> >         Jakub
> >
>
>
> --
> BR,
> Hongtao



-- 
H.J.

  reply	other threads:[~2024-02-29 12:26 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27  8:40 [PATCH] i386: For noreturn functions save at least the bp register if it is used [PR114116] Jakub Jelinek
2024-02-27  8:54 ` Richard Biener
2024-02-27  9:04   ` Jakub Jelinek
2024-02-27  9:13     ` Jakub Jelinek
2024-02-27  9:50       ` Richard Biener
2024-02-27  9:55       ` Jakub Jelinek
2024-02-27 12:09       ` Jakub Jelinek
2024-02-27 14:57         ` [PATCH] i386: Guard noreturn no-callee-saved-registers optimization with -mnoreturn-no-callee-saved-registers [PR38534] Jakub Jelinek
2024-02-28  8:00           ` Jakub Jelinek
2024-02-28  8:53             ` Jakub Jelinek
2024-02-29  6:20               ` Hongtao Liu
2024-02-29 12:26                 ` H.J. Lu [this message]
2024-02-29 12:47                   ` Jakub Jelinek
2024-02-29 13:24                     ` Richard Biener
2024-02-29 13:31                       ` Jan Hubicka
2024-02-29 13:56                         ` Jakub Jelinek
2024-02-29 14:15                           ` Jan Hubicka
2024-02-29 14:28                             ` H.J. Lu
2024-02-29 15:10                             ` Jakub Jelinek
2024-02-29 15:26                               ` Jan Hubicka
2024-03-05  4:52                 ` Hongtao Liu
2024-02-29 16:25         ` [PATCH] i386: For noreturn functions save at least the bp register if it is used [PR114116] Michael Matz

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='CAMe9rOp0thPFO29D+f32XTt3Nsek6ihap_U=R5p2gisOkHhvAQ@mail.gmail.com' \
    --to=hjl.tools@gmail.com \
    --cc=crazylht@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=jh@suse.cz \
    --cc=richard.guenther@gmail.com \
    --cc=ubizjak@gmail.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).