From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25359 invoked by alias); 16 Nov 2016 09:43:12 -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 25258 invoked by uid 89); 16 Nov 2016 09:43:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=BAYES_00,KAM_ASCII_DIVIDERS,RP_MATCHES_RCVD,SPF_PASS autolearn=ham version=3.3.2 spammy=2016-11-16, sum X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 16 Nov 2016 09:42:59 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7B531ADC8; Wed, 16 Nov 2016 09:42:57 +0000 (UTC) Date: Wed, 16 Nov 2016 09:43:00 -0000 From: Richard Biener To: gcc-patches@gcc.gnu.org cc: andrew.n.senkevich@gmail.com, bviyer@gcc.gnu.org Subject: Re: [PATCH] Fix PR78306 In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2016-11/txt/msg01575.txt.bz2 On Tue, 15 Nov 2016, Richard Biener wrote: > > Appearantly for some unknown reason we refuse to inline anything into > functions calling cilk_spawn. That breaks fortified headers and > all other always-inline function calls (intrinsics come to my mind as > well). > > Bootstrapped and tested on x86_64-unknown-linux-gnu, ok for trunk? I had to fix the testcase somewhat to avoid the cilk.h header. I also added correctness checking. I'll commit this to trunk if there are no comments on why we refuse to inline into cilk-spawn containing functions (CCing original author as well) - the code behaves this way since the original merge and there's no testcase showing failure when removing it. Thanks, Richard. 2016-11-16 Richard Biener PR tree-optimization/78306 * ipa-inline-analysis.c (initialize_inline_failed): Do not inhibit inlining if function calls cilk_spawn. (can_inline_edge_p): Likewise. * gcc.dg/cilk-plus/pr78306.c: New testcase. Index: gcc/ipa-inline-analysis.c =================================================================== --- gcc/ipa-inline-analysis.c (revision 242408) +++ gcc/ipa-inline-analysis.c (working copy) @@ -1507,9 +1507,6 @@ initialize_inline_failed (struct cgraph_ e->inline_failed = CIF_BODY_NOT_AVAILABLE; else if (callee->local.redefined_extern_inline) e->inline_failed = CIF_REDEFINED_EXTERN_INLINE; - else if (cfun && fn_contains_cilk_spawn_p (cfun)) - /* We can't inline if the function is spawing a function. */ - e->inline_failed = CIF_CILK_SPAWN; else e->inline_failed = CIF_FUNCTION_NOT_CONSIDERED; gcc_checking_assert (!e->call_stmt_cannot_inline_p Index: gcc/ipa-inline.c =================================================================== --- gcc/ipa-inline.c (revision 242408) +++ gcc/ipa-inline.c (working copy) @@ -368,11 +368,6 @@ can_inline_edge_p (struct cgraph_edge *e e->inline_failed = CIF_FUNCTION_NOT_INLINABLE; inlinable = false; } - else if (inline_summaries->get (caller)->contains_cilk_spawn) - { - e->inline_failed = CIF_CILK_SPAWN; - inlinable = false; - } /* Don't inline a function with mismatched sanitization attributes. */ else if (!sanitize_attrs_match_for_inline_p (caller->decl, callee->decl)) { Index: gcc/testsuite/gcc.dg/cilk-plus/pr78306.c =================================================================== --- gcc/testsuite/gcc.dg/cilk-plus/pr78306.c (revision 0) +++ gcc/testsuite/gcc.dg/cilk-plus/pr78306.c (revision 0) @@ -0,0 +1,30 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fcilkplus" } */ + +#define _FORTIFY_SOURCE 2 +#include + +int sum(int low, int high) +{ + if(low == high) { + return low; + } + + int mid = low + (high-low)/2; + int a = _Cilk_spawn sum(low, mid); + int b = sum(mid+1, high); + + // Some very expensive computation here + int foo[64]; + memset(foo, 0, 64*sizeof(int)); // <--- Fails + + _Cilk_sync; + + return a+b; +} + +int main(void) { + if (sum(0, 100) != 5050) + __builtin_abort (); + return 0; +}