diff options
author | Jan Hubicka <jh@suse.cz> | 2012-10-31 17:15:21 +0100 |
---|---|---|
committer | Jan Hubicka <hubicka@gcc.gnu.org> | 2012-10-31 16:15:21 +0000 |
commit | e3c7b49cd858f9d9984963544feb58c64abee40e (patch) | |
tree | 08fad3f7c7903ec1e33f03a80d59b58bd18c15f4 /gcc/ipa-inline.c | |
parent | 737df6e61771e330559a152be1653b173012172b (diff) | |
download | gcc-e3c7b49cd858f9d9984963544feb58c64abee40e.tar.gz |
ipa-inline.c (ipa_inline): Avoid infinite loop on inlining empty virtual functions calling themselves.
* ipa-inline.c (ipa_inline): Avoid infinite loop on inlining
empty virtual functions calling themselves.
From-SVN: r193038
Diffstat (limited to 'gcc/ipa-inline.c')
-rw-r--r-- | gcc/ipa-inline.c | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index 773220b60cc..cd58d332c9d 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -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; + } + } + } } } } |