public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "slyfox at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/96394] [10/11 Regression] ICE in add_new_edges_to_heap, at ipa-inline.c:1746 (-O3 PGO)
Date: Wed, 23 Sep 2020 21:58:23 +0000	[thread overview]
Message-ID: <bug-96394-4-Gr1mbZk1Rn@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-96394-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #10 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Finally managed to shrink it down to self-contained example. It has to be split
into two .c files (and one header) to prevent analyzer from inferring too much:

// node.h:
void bug(void);
void * PyErr_Format(const void * ...);

typedef struct _entry {
    int has_next;
    int next_ix;
    int count;
} entry;
extern entry table[];

// main.c:
  #include "node.h"

  void * PyErr_Format(const void * ...){ return 0; }

  int main(void)
  {
    bug();
  }

  entry table[2] = {
    { .has_next = 1
    , .next_ix  = 1
    , .count    = 0
    },
    { .has_next = 0
    , .next_ix  = 0
    , .count    = 0
    },
  };

// parsermodule.c:

  #include "node.h"

  void ae(entry *);
  int h(entry *);
  int ap(entry *);
  int ag(entry *);

  int ag(entry *j) {
    if (j->has_next)
      h(&table[j->next_ix]);
    return 0;
  }
  static int ai(entry *j, int k(entry *), int l, int m) {
    int am = 1;
    int ab;

    /* k is either 'h' or 'ap': 50%/50% */
    ab = k(j);

    /* loop never gets executed on real data */
    for (; j->count >= 2; am += 2)
      if (l) {
        entry *i = &table[am + m];
        PyErr_Format(i);
      }
    return ab;
  }
  void bug() {
    h(table);
    h(table);
  }
  int h(entry *j) { return ai(j, ap, 4, 5); }
  int ap(entry *j) { return ai(j, ag, 14, 4); }

Commands to crash:

$ g++-11.0.0 -O2 -c -fprofile-generate parsermodule.c -o parsermodule.o
$ g++-11.0.0 -O2 -c -fprofile-generate main.c -o main.o
$ g++-11.0.0 -O2 -fprofile-generate main.o parsermodule.o -o b
$ ./b
$ g++-11.0.0 -O2 -c -fprofile-use parsermodule.c -o parsermodule.o -fopt-info

parsermodule.c:20:9: optimized: Indirect call -> direct call k_6(D) => ap (will
resolve by ipa-profile)
parsermodule.c:20:9: optimized: Indirect call -> direct call k_6(D) => ag (will
resolve by ipa-profile)
parsermodule.c:20:9: optimized:  Inlined int ag(entry*)/7 into int ai(entry*,
int (*)(entry*), int, int)/1 which now has time 15.125000 and size 25, net
change of +2.
parsermodule.c:20:9: optimized: converting indirect call in int ai(entry*, int
(*)(entry*), int, int)/8 to direct call to int ag(entry*)/0
parsermodule.c:35:29: optimized:  Inlined int ai(entry*, int (*)(entry*), int,
int)/8 into int ap(entry*)/4 which now has time 8.625000 and size 15, net
change of +6.
parsermodule.c:20:9: optimized: converting indirect call in int ai(entry*, int
(*)(entry*), int, int)/1 to direct call to int ap(entry*)/4
during IPA pass: inline
parsermodule.c:35:45: internal compiler error: in add_new_edges_to_heap, at
ipa-inline.c:1754
   35 | int ap(entry *j) { return ai(j, ag, 14, 4); }
      |                                             ^
0x621b65 add_new_edges_to_heap
       
/usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-inline.c:1754
0x163ded7 inline_small_functions
       
/usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-inline.c:2218
0x163ded7 ipa_inline
       
/usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-inline.c:2697
0x163ded7 execute
       
/usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-inline.c:3099
Please submit a full bug report,

  parent reply	other threads:[~2020-09-23 21:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-30 22:39 [Bug ipa/96394] New: internal compiler error: " slyfox at gcc dot gnu.org
2020-07-30 22:43 ` [Bug ipa/96394] " slyfox at gcc dot gnu.org
2020-07-30 22:48 ` slyfox at gcc dot gnu.org
2020-07-30 23:09 ` slyfox at gcc dot gnu.org
2020-07-31  6:20 ` marxin at gcc dot gnu.org
2020-07-31  6:21 ` marxin at gcc dot gnu.org
2020-07-31  6:52 ` marxin at gcc dot gnu.org
2020-07-31 12:11 ` marxin at gcc dot gnu.org
2020-09-06 11:35 ` [Bug ipa/96394] [10/11 Regression] ICE " slyfox at gcc dot gnu.org
2020-09-06 21:21 ` slyfox at gcc dot gnu.org
2020-09-23 21:58 ` slyfox at gcc dot gnu.org [this message]
2020-09-23 21:59 ` slyfox at gcc dot gnu.org
2020-09-23 22:04 ` slyfox at gcc dot gnu.org
2020-09-24 10:31 ` marxin at gcc dot gnu.org
2020-09-25 14:15 ` jamborm at gcc dot gnu.org
2020-09-25 15:46 ` jamborm at gcc dot gnu.org
2020-09-29  7:41 ` marxin at gcc dot gnu.org
2020-09-29  7:41 ` marxin at gcc dot gnu.org
2020-10-01 17:41 ` jamborm at gcc dot gnu.org
2020-10-01 18:42 ` marxin at gcc dot gnu.org
2020-10-02 23:02 ` slyfox at gcc dot gnu.org
2020-10-07 12:35 ` cvs-commit at gcc dot gnu.org
2020-10-16 10:16 ` cvs-commit at gcc dot gnu.org
2020-10-16 10:20 ` jamborm 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-96394-4-Gr1mbZk1Rn@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).