From patchwork Mon Mar 2 20:33:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 445424 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 02B7F140146 for ; Tue, 3 Mar 2015 07:33:49 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=EREcuZlQ; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=dRgJ4wBjZbMmNoashdiJJJwWhmX+9q3gmRbw5XXVJjMLjZSjUH33h rgmM7CRXO9sO3DfXd2voFGK5/Tw+K47IidoNRsIhURUAjZ0RqHMScJu0kvoJ52V8 8MVnF0E7t4QQtwHMFNWXcAsPw3xACHS+iDWxkZkvzye2/WaXbMlyhY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=jtufkD3rVjAXErmYIdzD9PgdzgI=; b=EREcuZlQrEt+PRqFr20X 4AAUrxuuh/XN66cZ1FtbPcozJGrEHfG/xrC8oHeZ/GUaEMU24Np3uQM7+Pm3m4t5 BlzCF/Xd+fHe90fZt4YrAg8tIk16XAEDEX9qYdRNIXV/kHp38F0bog0zWbUwY3kR nUveMtWVdEn0zdb8vR5Tbj8= 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-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@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, 2 Mar 2015 21:33:35 +0100 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-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) 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;