From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 81527 invoked by alias); 2 Mar 2015 20:33:41 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 81516 invoked by uid 89); 2 Mar 2015 20:33:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 02 Mar 2015 20:33:40 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 123845452F9; Mon, 2 Mar 2015 21:33:35 +0100 (CET) Date: Mon, 02 Mar 2015 20:33:00 -0000 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: Avoid cycles in the inline plan Message-ID: <20150302203335.GC846@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-03/txt/msg00100.txt.bz2 Hi, in the testcase bellow we manage to produce cycle in inline plan because there is indirectly recrusive function that appears called once. I am having problems with the testcase. The second file outht to be compiled with -O2, but it is not. Is the dg-options in the LTO testsuite broken now or did I missed something obvious? The testcase excercises the new paths anyway (just does not ice) so I decided to commit it as it is for now. Bootstrapped/regtested x86_64-linux, commited. Honza PR ipa/65130 * ipa-inline.c (check_callers): Looks for recursion. (inline_to_all_callers): Give up on uninlinable or recursive edges. * ipa-inline-analysis.c (inline_summary_t::duplicate): Do not update summary of inline clones. (do_estimate_growth_1): Fix recursion check. * gcc.dg/lto/pr65130_0.c: New testcase. * gcc.dg/lto/pr65130_1.c: New testcase. Index: ipa-inline.c =================================================================== --- ipa-inline.c (revision 221122) +++ ipa-inline.c (working copy) @@ -952,6 +952,8 @@ check_callers (struct cgraph_node *node, return true; if (!can_inline_edge_p (e, true)) return true; + if (e->recursive_p ()) + return true; if (!(*(bool *)has_hot_call) && e->maybe_hot_p ()) *(bool *)has_hot_call = true; } @@ -2094,6 +2096,15 @@ inline_to_all_callers (struct cgraph_nod { struct cgraph_node *caller = node->callers->caller; + if (!can_inline_edge_p (node->callers, true) + || node->callers->recursive_p ()) + { + if (dump_file) + fprintf (dump_file, "Uninlinable call found; giving up.\n"); + *num_calls = 0; + return false; + } + if (dump_file) { fprintf (dump_file, Index: testsuite/gcc.dg/lto/pr65130_0.c =================================================================== --- testsuite/gcc.dg/lto/pr65130_0.c (revision 0) +++ testsuite/gcc.dg/lto/pr65130_0.c (revision 0) @@ -0,0 +1,19 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options { { -flto -O1 -fdevirtualize } } } */ +extern void fn3 (void); + +void fn2(void) +{ + fn3(); +} + +void fn1(void) +{ + fn2(); +} + +void fn4(void) +{ + fn2(); +} + Index: testsuite/gcc.dg/lto/pr65130_1.c =================================================================== --- testsuite/gcc.dg/lto/pr65130_1.c (revision 0) +++ testsuite/gcc.dg/lto/pr65130_1.c (revision 0) @@ -0,0 +1,17 @@ +/* { dg-options "-O2 -fdevirtualize" } */ +extern void fn1(void); +extern void fn4 (void); + +int a; + +void fn3(void) +{ + for (; a;) + fn4(); +} + +int main() { + fn1(); + return 0; +} + Index: ipa-inline-analysis.c =================================================================== --- ipa-inline-analysis.c (revision 221122) +++ ipa-inline-analysis.c (working copy) @@ -1291,7 +1291,8 @@ inline_summary_t::duplicate (cgraph_node set_hint_predicate (&info->array_index, p); } } - inline_update_overall_summary (dst); + if (!dst->global.inlined_to) + inline_update_overall_summary (dst); } @@ -3924,10 +3925,11 @@ do_estimate_growth_1 (struct cgraph_node continue; } - if (e->caller == d->node - || (e->caller->global.inlined_to - && e->caller->global.inlined_to == d->node)) - d->self_recursive = true; + if (e->recursive_p ()) + { + d->self_recursive = true; + continue; + } d->growth += estimate_edge_growth (e); } return false;