public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/108691] [13 Regression] ICE with function ptr and setjmp/returns twice at -O1
Date: Mon, 13 Feb 2023 09:34:49 +0000	[thread overview]
Message-ID: <bug-108691-4-r1d3K2P25s@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108691-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
The reason is that gimple_call_flags returns a different answer from the
indirect function call vs. the direct function call after propagating of
the &setjmp constant.  First of all 'returns_twice' is an attribute that
cannot be set on a function type:

int __attribute__((returns_twice)) (*foo) (void);
> gcc-12 -S t.c -Wall
t.c:1:1: warning: 'returns_twice' attribute ignored [-Wattributes]
    1 | int __attribute__((returns_twice)) (*foo) (void);
      | ^~~

so one cannot have an indirect call annotated.  But even then we for
example treat indirect missing 'noreturn' conservatively, not requiring
it to end a BB and only enforce that in the fixup-CFG pass.

Now, for return_twice we could similarly check gimple_call_ctrl_altering.

That still leaves us with missing abnormal edges - David, was this reduced
from an actual program?

When fixing up DCE to not set cfun->calls_setjmp it will eventually be
set late in emit_call_1 via

  if (ecf_flags & ECF_RETURNS_TWICE)
    {
      add_reg_note (call_insn, REG_SETJMP, const0_rtx);
      cfun->calls_setjmp = 1;
    }

a "fix" here would be to _check_ for cfun->calls_setjmp instead of setting it
(or assert it is set).  The control-altering flag has no representation
on GENERIC, and we're still expanding calls via intermediate GENERIC ...

  parent reply	other threads:[~2023-02-13  9:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 10:04 [Bug c/108691] New: ICE when compiling for AArch64 with BTI protection " david.spickett at linaro dot org
2023-02-07 10:06 ` [Bug c/108691] " david.spickett at linaro dot org
2023-02-07 10:16 ` [Bug tree-optimization/108691] ICE with function ptr and setjmp/returns twice " pinskia at gcc dot gnu.org
2023-02-07 10:17 ` [Bug tree-optimization/108691] [13 Regression] " pinskia at gcc dot gnu.org
2023-02-07 10:17 ` pinskia at gcc dot gnu.org
2023-02-07 10:21 ` pinskia at gcc dot gnu.org
2023-02-07 14:07 ` rguenth at gcc dot gnu.org
2023-02-13  9:34 ` rguenth at gcc dot gnu.org [this message]
2023-02-13  9:51 ` david.spickett at linaro dot org
2023-02-13 10:01 ` rguenth at gcc dot gnu.org
2023-02-13 14:57 ` cvs-commit at gcc dot gnu.org
2023-02-13 14:58 ` rguenth at gcc dot gnu.org
2023-02-15  8:19 ` david.spickett at linaro dot org
2023-02-21  9:27 ` rguenth at gcc dot gnu.org
2023-02-21  9:50 ` sam at gentoo dot org
2023-02-21  9:59 ` jakub at gcc dot gnu.org
2023-02-21 13:08 ` cvs-commit at gcc dot gnu.org
2023-02-21 13:08 ` rguenth 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-108691-4-r1d3K2P25s@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).