public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Michael Matz <matz@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Biener <richard.guenther@gmail.com>,
	 Uros Bizjak <ubizjak@gmail.com>,
	hjl.tools@gmail.com,  gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] i386: For noreturn functions save at least the bp register if it is used [PR114116]
Date: Thu, 29 Feb 2024 17:25:39 +0100 (CET)	[thread overview]
Message-ID: <9c5e0111-441e-04a3-d1b4-467b582a0ffd@suse.de> (raw)
In-Reply-To: <Zd3Q5Ti+/bgymUun@tucnak>

Hello,

On Tue, 27 Feb 2024, Jakub Jelinek wrote:

> On Tue, Feb 27, 2024 at 10:13:14AM +0100, Jakub Jelinek wrote:
> > For __libc_start_main, glibc surely just could use no_callee_saved_registers
> > attribute, because that is typically the outermost frame in backtrace,
> > there is no need to save those there.
> > And for kernel if it really wants it and nothing will use the backtraces,
> > perhaps the patch wouldn't need to be reverted completely but just guarded
> > the implicit no_callee_saved_registers treatment of noreturn
> > functions on -mcmodel=kernel or -fno-asynchronous-unwind-tables.
> 
> Guarding on -fno-asynchronous-unwind-tables isn't a good idea,
> with just -g we emit in that case unwind info in .debug_frame section
> and even that shouldn't break, and we shouldn't generate different code for
> -g vs. -g0.
> The problem with the changes is that it breaks the unwinding and debugging
> experience not just in the functions on which the optimization triggers,
> but on all functions in the backtrace as well.
> 
> So, IMHO either revert the changes altogether, or guard on -mcmodel=kernel
> (but talk to kernel people on linux-toolchains if that is what they actually
> want).

What is the underlying real purpose of the changes anyway?  It's a 
nano-optimization: for functions to be called multiple times 
they must either return or be recursive.  The latter is not very likely, 
so a noreturn function is called only once in the vast majority of cases.  
Any optimizations that diddle with the frame setup code for functions 
called only once seems to be ... well, not so very useful, especially so 
when they impact anything that is actually useful, like debugging.

I definitely think this shouldn't be done by default.


Ciao,
Michael.

      parent reply	other threads:[~2024-02-29 16:25 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27  8:40 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
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         ` Michael Matz [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=9c5e0111-441e-04a3-d1b4-467b582a0ffd@suse.de \
    --to=matz@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=jakub@redhat.com \
    --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).