From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 41C013857C5A; Wed, 23 Sep 2020 21:58:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 41C013857C5A From: "slyfox at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: ice-on-valid-code X-Bugzilla-Severity: normal X-Bugzilla-Who: slyfox at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: hubicka at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Sep 2020 21:58:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96394 --- Comment #10 from Sergei Trofimovich --- Finally managed to shrink it down to self-contained example. It has to be s= plit into two .c files (and one header) to prevent analyzer from inferring too m= uch: // 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] =3D { { .has_next =3D 1 , .next_ix =3D 1 , .count =3D 0 }, { .has_next =3D 0 , .next_ix =3D 0 , .count =3D 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 =3D 1; int ab; /* k is either 'h' or 'ap': 50%/50% */ ab =3D k(j); /* loop never gets executed on real data */ for (; j->count >=3D 2; am +=3D 2) if (l) { entry *i =3D &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-in= fo parsermodule.c:20:9: optimized: Indirect call -> direct call k_6(D) =3D> ap= (will resolve by ipa-profile) parsermodule.c:20:9: optimized: Indirect call -> direct call k_6(D) =3D> 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*), i= nt, 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 =20=20=20=20=20=20=20 /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-inli= ne.c:1754 0x163ded7 inline_small_functions =20=20=20=20=20=20=20 /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-inli= ne.c:2218 0x163ded7 ipa_inline =20=20=20=20=20=20=20 /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-inli= ne.c:2697 0x163ded7 execute =20=20=20=20=20=20=20 /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/ipa-inli= ne.c:3099 Please submit a full bug report,=