This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 1/2] Update iterator of next
> On Fri, Nov 15, 2019 at 10:16 AM Richard Biener
> <richard.guenther@gmail.com> wrote:
> >
> > On Fri, Nov 15, 2019 at 9:10 AM Jan Hubicka <hubicka@ucw.cz> wrote:
> > >
> > > > next is initialized only in the loop before, it is never updated
> > > > in it's own loop.
> > > >
> > > > gcc/ChangeLog
> > > >
> > > > 2019-11-15 Xiong Hu Luo <luoxhu@linux.ibm.com>
> > > >
> > > > * ipa-inline.c (inline_small_functions): Update iterator of next.
> > >
> > > OK,
> > > thanks!
> >
> > This breaks bootstrap and the loop before is similarly odd.
> >
> > (gdb) p edge
> > $1 = (cgraph_edge *) 0xa5a5a5a5a5a5a5a5
> >
> > so apparently edge->next_callee is GCed (thus 'edge' itself is freed?)
>
> edge->resolve_speculation ();
>
> can remove the edge, so maybe
>
> Index: gcc/ipa-inline.c
> ===================================================================
> --- gcc/ipa-inline.c (revision 278280)
> +++ gcc/ipa-inline.c (working copy)
> @@ -1932,13 +1932,13 @@ inline_small_functions (void)
> if (has_speculative)
> for (edge = node->callees; edge; edge = next)
> {
> + next = edge->next_callee;
> if (edge->speculative
> && !speculation_useful_p (edge, edge->aux != NULL))
> {
> edge->resolve_speculation ();
> update = true;
> }
> - next = edge->next_callee;
> }
> if (update)
> {
>
> which I'll commit after verifying it fixes bootstrap.
I stasrted testing:
Index: ../gcc/ipa-inline.c
===================================================================
--- ../gcc/ipa-inline.c (revision 278281)
+++ ../gcc/ipa-inline.c (working copy)
@@ -1913,9 +1913,8 @@ inline_small_functions (void)
if (dump_file)
fprintf (dump_file, "Enqueueing calls in %s.\n", node->dump_name ());
- for (edge = node->callees; edge; edge = next)
+ for (edge = node->callees; edge; edge = edge->next_callee)
{
- next = edge->next_callee;
if (edge->inline_failed
&& !edge->aux
&& can_inline_edge_p (edge, true)
@@ -1932,13 +1931,13 @@ inline_small_functions (void)
if (has_speculative)
for (edge = node->callees; edge; edge = next)
{
+ next = edge->next_callee;
if (edge->speculative
&& !speculation_useful_p (edge, edge->aux != NULL))
{
edge->resolve_speculation ();
update = true;
}
- next = edge->next_callee;
}
if (update)
{
Since the previous loop never removes edges (I suppose the bug came to
be by splitting this loop to two incorrectly).
Where is the other non-looping loop?
Honza