]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* ipa-inline.c (ipa_inline): Avoid infinite loop on inlining
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 31 Oct 2012 16:15:21 +0000 (16:15 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 31 Oct 2012 16:15:21 +0000 (16:15 +0000)
empty virtual functions calling themselves.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193038 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ipa-inline.c

index 92c327cc0edf2cae1da2a64711847ceeda52bef5..8286b1d9b800b3c1097d887fd3a5425d8748a6af 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-31  Jan Hubicka  <jh@suse.cz>
+
+       * ipa-inline.c (ipa_inline): Avoid infinite loop on inlining
+       empty virtual functions calling themselves.
+
 2012-10-31  Tom Tromey  <tromey@redhat.com>
 
        PR other/50899
index 773220b60cc32f96df281da6dde7e77372f60b64..cd58d332c9dd77fdc591c027cd857e3436c8e60b 100644 (file)
@@ -1767,29 +1767,41 @@ ipa_inline (void)
          FOR_EACH_DEFINED_FUNCTION (node)
            {
              if (want_inline_function_to_all_callers_p (node, cold))
-               while (node->callers && !node->global.inlined_to)
-                 {
-                   struct cgraph_node *caller = node->callers->caller;
-
-                   if (dump_file)
-                     {
+               {
+                 int num_calls = 0;
+                 struct cgraph_edge *e;
+                 for (e = node->callers; e; e = e->next_caller)
+                   num_calls++;
+                 while (node->callers && !node->global.inlined_to)
+                   {
+                     struct cgraph_node *caller = node->callers->caller;
+
+                     if (dump_file)
+                       {
+                         fprintf (dump_file,
+                                  "\nInlining %s size %i.\n",
+                                  cgraph_node_name (node),
+                                  inline_summary (node)->size);
+                         fprintf (dump_file,
+                                  " Called once from %s %i insns.\n",
+                                  cgraph_node_name (node->callers->caller),
+                                  inline_summary (node->callers->caller)->size);
+                       }
+
+                     inline_call (node->callers, true, NULL, NULL, true);
+                     if (dump_file)
                        fprintf (dump_file,
-                                "\nInlining %s size %i.\n",
-                                cgraph_node_name (node),
-                                inline_summary (node)->size);
-                       fprintf (dump_file,
-                                " Called once from %s %i insns.\n",
-                                cgraph_node_name (node->callers->caller),
-                                inline_summary (node->callers->caller)->size);
-                     }
-
-                   inline_call (node->callers, true, NULL, NULL, true);
-                   if (dump_file)
-                     fprintf (dump_file,
-                              " Inlined into %s which now has %i size\n",
-                              cgraph_node_name (caller),
-                              inline_summary (caller)->size);
-                 }
+                                " Inlined into %s which now has %i size\n",
+                                cgraph_node_name (caller),
+                                inline_summary (caller)->size);
+                     if (!num_calls--)
+                       {
+                         if (dump_file)
+                           fprintf (dump_file, "New calls found; giving up.\n");
+                         break;
+                       }
+                   }
+               }
            }
        }
     }