diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-31 16:15:21 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-10-31 16:15:21 +0000 |
commit | bf92ac4d36b27fc4696b8db9e48016eac3404b2a (patch) | |
tree | 08fad3f7c7903ec1e33f03a80d59b58bd18c15f4 /gcc/ipa-inline.c | |
parent | fe35af23e4090cefd42269850386d228f03c5c21 (diff) | |
download | gcc-bf92ac4d36b27fc4696b8db9e48016eac3404b2a.tar.gz |
* ipa-inline.c (ipa_inline): Avoid infinite loop on inlining
empty virtual functions calling themselves.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@193038 138bc75d-0d04-0410-961f-82ee72b054a4
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; + } + } + } } } } |