public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rsandifo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/114664] -fno-omit-frame-pointer causes an ICE during the build of the greenlet package
Date: Wed, 10 Apr 2024 13:53:48 +0000	[thread overview]
Message-ID: <bug-114664-4-2Z0dZVEF9n@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114664-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114664

--- Comment #12 from Richard Sandiford <rsandifo at gcc dot gnu.org> ---
(In reply to Peter Bergner from comment #11)
> > > but how are users supposed to know whether
> > > -fno-omit-frame-pointer is in effect or not?  I've looked and there is no
> > > pre-defined macro a user could check.
> > That might be a useful thing to have, but if the programmer has no control
> > over the build flags (i.e. cannot require/force -fomit-frame-pointer) then I
> > think the asm has to take care to save and restore the frame pointer itself.
> > 
> > Dropping "31" from the asm means that the asm must preserve the register. 
> > Things will go badly if the asm doesn't do that.
> 
> So r31 which we use as our frame-pointer reg is a non-volatile/callee saved
> register, so it must be saved, but I guess they (greenlet) cannot use the
> method of mentioning it in the asm clobber list to perform that.
I was thinking of just the asm in isolation, rather than its effect on the
containing function's callee-save set.

If you have:

  asm volatile ("…");

then GCC expects r31 after the asm to equal r31 before the asm, regardless of
the -fomit-frame-pointer setting.  If the asm is:

  asm volatile ("li r31,0");

(sorry, I've forgotten the actual Power asm :)) then things will go wrong if
GCC tries to use r31 after the asm.

If the asm clobbers r31 then it must mention it in the clobber list.  As things
stand, it's not possible to mention r31 in the clobber list if
-fno-omit-frame-pointer.  This means that the only option for code that wants
to support -fno-omit-frame-pointer is to make the asm's contents preserve r31,
using an explicit save and restore if necessary.

And that kind-of makes sense.  If an asm clobbers the frame pointer, that
removes GCC's main option for restoring data after the asm.  A lot of other
clobbers would be handled by loading data relative to the frame pointer.  If
the frame pointer itself has gone then things get tricky.

  parent reply	other threads:[~2024-04-10 13:53 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-09 18:42 [Bug rtl-optimization/114664] New: " bergner at gcc dot gnu.org
2024-04-09 18:48 ` [Bug rtl-optimization/114664] " pinskia at gcc dot gnu.org
2024-04-09 19:00 ` bergner at gcc dot gnu.org
2024-04-09 19:01 ` pinskia at gcc dot gnu.org
2024-04-09 19:02 ` bergner at gcc dot gnu.org
2024-04-09 19:04 ` bergner at gcc dot gnu.org
2024-04-09 19:06 ` pinskia at gcc dot gnu.org
2024-04-09 19:21 ` pinskia at gcc dot gnu.org
2024-04-09 19:48 ` bergner at gcc dot gnu.org
2024-04-10  3:14 ` linkw at gcc dot gnu.org
2024-04-10 12:52 ` bergner at gcc dot gnu.org
2024-04-10 13:24 ` rsandifo at gcc dot gnu.org
2024-04-10 13:42 ` bergner at gcc dot gnu.org
2024-04-10 13:53 ` rsandifo at gcc dot gnu.org [this message]
2024-04-10 14:03 ` bergner at gcc dot gnu.org
2024-04-10 14:04 ` rsandifo at gcc dot gnu.org
2024-04-10 14:15 ` bergner at gcc dot gnu.org
2024-04-10 15:37 ` segher at gcc dot gnu.org

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=bug-114664-4-2Z0dZVEF9n@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).