public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dani at danielbertalan dot dev" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/103819] New: [12 Regression] ICE in redirect_callee, at cgraph.c:1389 with __attribute__((flatten)) and -O2
Date: Thu, 23 Dec 2021 19:07:49 +0000	[thread overview]
Message-ID: <bug-103819-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 103819
           Summary: [12 Regression] ICE in redirect_callee, at
                    cgraph.c:1389 with __attribute__((flatten)) and -O2
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dani at danielbertalan dot dev
                CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Created attachment 52052
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52052&action=edit
Test case

Link to Compiler Explorer: https://godbolt.org/z/5bE9zsvfh

The following code fails to compile with gcc 12 (commit
61e53698a08dc1d9a54d785218af687a6751c1b3):

===
template <typename T> struct Optional {
  ~Optional() {
    if (m_has_value)
      value();
  }
  T value();
  void release_value() { m_has_value = false; }
  bool m_has_value;
};
struct Completion {
  Optional<int> m_target;
};
struct ThrowCompletionOr {
  void release_error() { m_throw_completion.release_value(); }
  Optional<Completion> m_throw_completion;
} __trans_tmp_1;

__attribute__((flatten)) void value_to_numeric() {
  auto _temporary_result(__trans_tmp_1);
  _temporary_result.release_error();
}
===

The issue is both present in Compiler Explorer's trunk compiler, and in my
local build that has SerenityOS-specific patches applied. The error, as
reported by the latter, is:

$ g++ -O2 -v -save-temps -c repro.ii:
Using built-in specs.
COLLECT_GCC=../../Toolchain/Local/gcc-12/i686/bin/i686-pc-serenity-g++
Target: i686-pc-serenity
Configured with: ../../Tarballs/gcc/configure
--prefix=/home/dani/Projects/contributions/serenity/Toolchain/Local/gcc-12/i686
--target=i686-pc-serenity
--with-sysroot=/home/dani/Projects/contributions/serenity/Build/i686/Root
--disable-nls --with-newlib --enable-shared --enable-languages=c,c++
--enable-default-pie --enable-lto --enable-threads=posix
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20211223 (experimental) (GCC)
COLLECT_GCC_OPTIONS='-O2' '-v' '-save-temps' '-c' '-shared-libgcc'
'-mtune=generic' '-march=pentiumpro'

/home/dani/Projects/contributions/serenity/Toolchain/Local/gcc-12/i686/libexec/gcc/i686-pc-serenity/12.0.0/cc1plus
-fpreprocessed repro.ii -ftls-model=initial-exec -fPIC
-fno-semantic-interposition -quiet -dumpbase repro.ii -dumpbase-ext .ii
-mtune=generic -march=pentiumpro -O2 -version -ftls-model=initial-exec -o
repro.s
GNU C++17 (GCC) version 12.0.0 20211223 (experimental) (i686-pc-serenity)
        compiled by GNU C version 11.1.0, GMP version 6.2.1, MPFR version
4.1.0-p13, MPC version 1.2.1, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++17 (GCC) version 12.0.0 20211223 (experimental) (i686-pc-serenity)
        compiled by GNU C version 11.1.0, GMP version 6.2.1, MPFR version
4.1.0-p13, MPC version 1.2.1, isl version none
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 42faffcdcc480dea6a6ccc95e1bcf344
during IPA pass: inline
repro.ii:21:1: internal compiler error: in redirect_callee, at cgraph.c:1389
   21 | }
      | ^
0x761a99 cgraph_edge::redirect_callee(cgraph_node*)
        ../../../Tarballs/gcc/gcc/cgraph.c:1389
0xf0a8af redirect_to_unreachable
        ../../../Tarballs/gcc/gcc/ipa-fnsummary.c:260
0xf0a8af edge_set_predicate
        ../../../Tarballs/gcc/gcc/ipa-fnsummary.c:284
0xf0ad3d remap_edge_summaries
        ../../../Tarballs/gcc/gcc/ipa-fnsummary.c:4037
0xf0e246 ipa_merge_fn_summary_after_inlining(cgraph_edge*)
        ../../../Tarballs/gcc/gcc/ipa-fnsummary.c:4200
0xf23cd5 inline_call(cgraph_edge*, bool, vec<cgraph_edge*, va_heap, vl_ptr>*,
int*, bool, bool*)
        ../../../Tarballs/gcc/gcc/ipa-inline-transform.c:504
0x1eb2477 flatten_function
        ../../../Tarballs/gcc/gcc/ipa-inline.c:2413
0x1eb69eb ipa_inline
        ../../../Tarballs/gcc/gcc/ipa-inline.c:2736
0x1eb69eb execute
        ../../../Tarballs/gcc/gcc/ipa-inline.c:3148

             reply	other threads:[~2021-12-23 19:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-23 19:07 dani at danielbertalan dot dev [this message]
2021-12-23 19:47 ` [Bug ipa/103819] " pinskia at gcc dot gnu.org
2021-12-23 19:50 ` [Bug ipa/103819] [10/11/12 " pinskia at gcc dot gnu.org
2021-12-28 10:17 ` [Bug ipa/103819] [10/11/12 Regression] ICE in redirect_callee, at cgraph.c:1389 with __attribute__((flatten)) and -O2 since r11-7940-ge7fd3b783238d034 marxin at gcc dot gnu.org
2022-01-24 21:57 ` dani at danielbertalan dot dev
2022-03-08 13:21 ` rguenth at gcc dot gnu.org
2022-04-09 20:59 ` hubicka at gcc dot gnu.org
2022-05-06  8:32 ` [Bug ipa/103819] [10/11/12/13 " jakub at gcc dot gnu.org
2023-05-08 12:23 ` [Bug ipa/103819] [10/11/12/13/14 " 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-103819-4@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).