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

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Just to recap here, we inline fun3 via inline_always_inline_functions and
then early_inline_small_functions bails on the call because foo4
doesn't yet have a function summary:

      /* We can encounter not-yet-analyzed function during
         early inlining on callgraphs with strongly
         connected components.  */
      ipa_fn_summary *s = ipa_fn_summaries->get (callee);
      if (s == NULL || !s->inlinable || !e->inline_failed)
        continue;

that's where the ordering constraint comes in.  That's also a hard error
in can_inline_edge_p which does

  else if (ipa_fn_summaries->get (callee) == NULL
           || !ipa_fn_summaries->get (callee)->inlinable)
    { 
      e->inline_failed = CIF_FUNCTION_NOT_INLINABLE;
      inlinable = false;

even if we'd try harder and re-do inline_always_inline_functions after
each inline step (up to max early inliner iterations).  Maybe for QOI
we can handle this special case in ipa_reverse_postorder by putting
address-taken nodes without any calls last (we don't seem to have
indirect edges at this point to do a better job):

diff --git a/gcc/ipa-utils.cc b/gcc/ipa-utils.cc
index 67dd42f4faf..75e1387714e 100644
--- a/gcc/ipa-utils.cc
+++ b/gcc/ipa-utils.cc
@@ -294,7 +294,7 @@ ipa_reverse_postorder (struct cgraph_node **order)
   for (pass = 0; pass < 2; pass++)
     FOR_EACH_FUNCTION (node)
       if (!node->aux
-         && (pass
+         && ((pass && !(!node->callees && node->address_taken))
              || (!node->address_taken
                  && !node->inlined_to
                  && !node->alias && !node->thunk
@@ -346,7 +346,10 @@ ipa_reverse_postorder (struct cgraph_node **order)
        }
   free (stack);
   FOR_EACH_FUNCTION (node)
-    node->aux = NULL;
+    if (!node->aux)
+      order[order_pos++] = node;
+    else
+      node->aux = NULL;
   return order_pos;
 }

Reply via email to