From patchwork Thu Jun 13 01:00:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sriraman Tallam X-Patchwork-Id: 250949 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 9BB992C007A for ; Thu, 13 Jun 2013 11:00:48 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; q=dns; s=default; b=iESlUNTP6GsESjoZe5 gAkqerHB4goR2vAWiNEI+i8xrpnHb9tXEJQ4qMZx+VgehTpCW/Ibea0C6TV4NNxZ U8jZnui8dZeUMSivEk4N3Iiz7XKtnQOfXWwUKOpgwYJexn1s4HxrudQe8K3JJNBi 8nNQxinHUCKlUeVAcxAhcf+2k= 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 :mime-version:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; s=default; bh=XDbQqzC31Rq/PvjrXH2jGSkz cl0=; b=pSlX9Bxy1Rcl0XhRiF0FF2Od8drncwhedooTHP0Es/Oa7QFaE+5sNTGY H9hetkvTCbFuaI/ujaaItIX9C0MYP5CXLeKW4jqrHqb8zEMiXwAfzaTrswoAyyMe a2JRD/6vYXJ7PZsqVmEw7k0FK8xoYqdOKvR568c9sm+albXywiE= Received: (qmail 20358 invoked by alias); 13 Jun 2013 01:00:42 -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 20347 invoked by uid 89); 13 Jun 2013 01:00:42 -0000 X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=AWL, BAYES_00, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.1 Received: from mail-ie0-f179.google.com (HELO mail-ie0-f179.google.com) (209.85.223.179) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 13 Jun 2013 01:00:40 +0000 Received: by mail-ie0-f179.google.com with SMTP id c10so16469001ieb.38 for ; Wed, 12 Jun 2013 18:00:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:x-gm-message-state; bh=k4VpAlqEA8AaSfqqtU0YNv7WZ8eVCkb4cqjX0U5h81E=; b=dKl96haUjePS+Sg3eNKamsaxHPqJvslWFHpeop8iVAd6TRnFGOPlX6m37bGqB9mMPV DOXCNqTfE0WijioSCSDV94s0tS2EhN2Egt8db+6NBsjMNO3m+T2ZvrAHkykVCquYKgWm /E8ZAM+SXuDGjGI3HmixO4/lmeakBomroDI52TcXA0v+YWoXYa0fNogEkP1F2O0ysj26 dCLNQosSoqPEghu0cO20R9QrIHhzSmMgmQpGtIpDDRHg31t/PQFA/5zuOMPJ+HG1hfRr CyCgsJn6OqWP5m61Fd+IgLfHhuEomMiRao+UWf2XjA0CW+WNU762GLtwuHpVHMYHC9Hi chwg== MIME-Version: 1.0 X-Received: by 10.50.129.8 with SMTP id ns8mr1791682igb.25.1371085239489; Wed, 12 Jun 2013 18:00:39 -0700 (PDT) Received: by 10.231.63.2 with HTTP; Wed, 12 Jun 2013 18:00:39 -0700 (PDT) In-Reply-To: References: <20130514083913.GJ1377@tucnak.redhat.com> <20130514100419.GM1377@tucnak.redhat.com> <20130517054931.GM1377@tucnak.redhat.com> <20130518062136.GF1377@tucnak.redhat.com> Date: Wed, 12 Jun 2013 18:00:39 -0700 Message-ID: Subject: Re: GCC does not support *mmintrin.h with function specific opts From: Sriraman Tallam To: Jakub Jelinek , Jan Hubicka Cc: GCC Patches , Uros Bizjak , "H.J. Lu" , "Joseph S. Myers" , Diego Novillo , David Li X-Gm-Message-State: ALoCoQlK+5ZRFPUibwi6QdEAQ4rJwHKel+HkUQWNjD6fhGtz2jEAgreVNItRFkOsOxqnygEPsXKy9fowWsA3hNZf49fnOWi/tDjmaRSrteZAFItc8CEUJphVDynCYVkSW2KBi2r/+JfDq+0Vh84bQSzW5N+8vBO0mte6d52SEPs6eoXBzKEq6KM+Lz5VJ5Vc3Zk5D17OgGSrrilCDdwPxkYw8VRIU8A84A== X-Virus-Found: No X-IsSubscribed: yes Hi Honza, I have isolated the ipa-inline.c part into a separate patch with a test and attached it here. The patch is simple. Could you please take a look? * ipa-inline.c (can_early_inline_edge_p): Flag an error when the function that cannot be inlined is target specific. * gcc.target/i386/inline_error.c: New test. Thanks Sri On Mon, Jun 10, 2013 at 4:10 PM, Sriraman Tallam wrote: > Ping. > > On Tue, Jun 4, 2013 at 2:41 PM, Sriraman Tallam wrote: >> Ping. >> >> On Thu, May 23, 2013 at 2:41 PM, Sriraman Tallam wrote: >>> Ping, for review of ipa-inline.c change. >>> >>> Sri >>> >>> On Mon, May 20, 2013 at 11:04 AM, Sriraman Tallam wrote: >>>> On Fri, May 17, 2013 at 11:21 PM, Jakub Jelinek wrote: >>>>> On Fri, May 17, 2013 at 09:00:21PM -0700, Sriraman Tallam wrote: >>>>>> --- ipa-inline.c (revision 198950) >>>>>> +++ ipa-inline.c (working copy) >>>>>> @@ -374,7 +374,33 @@ can_early_inline_edge_p (struct cgraph_edge *e) >>>>>> return false; >>>>>> } >>>>>> if (!can_inline_edge_p (e, true)) >>>>>> - return false; >>>>>> + { >>>>>> + enum availability avail; >>>>>> + struct cgraph_node *callee >>>>>> + = cgraph_function_or_thunk_node (e->callee, &avail); >>>>>> + /* Flag an error when the inlining cannot happen because of target option >>>>>> + mismatch but the callee is marked as "always_inline". In -O0 mode >>>>>> + this will go undetected because the error flagged in >>>>>> + "expand_call_inline" in tree-inline.c might not execute and the >>>>>> + inlining will not happen. Then, the linker could complain about a >>>>>> + missing body for the callee if it turned out that the callee was >>>>>> + also marked "gnu_inline" with extern inline keyword as bodies of such >>>>>> + functions are not generated. */ >>>>>> + if ((!optimize >>>>>> + || flag_no_inline) >>>>> >>>>> This should be if ((!optimize || flag_no_inline) on one line. >>>>> >>>>> I'd prefer also the testcase for the ICEs, something like: >>>>> >>>>> /* Test case to check if AVX intrinsics and function specific target >>>>> optimizations work together. Check by including x86intrin.h */ >>>>> >>>>> /* { dg-do compile } */ >>>>> /* { dg-options "-O2 -mno-sse -mno-avx" } */ >>>>> >>>>> #include >>>>> >>>>> __m256 a, b, c; >>>>> void __attribute__((target ("avx"))) >>>>> foo (void) >>>>> { >>>>> a = _mm256_and_ps (b, c); >>>>> } >>>>> >>>>> and another testcase that does: >>>>> >>>>> /* { dg-do compile } */ >>>>> #pragma GCC target ("mavx") /* { dg-error "whatever" } */ >>>>> >>>>> Otherwise it looks good to me, but I'd prefer the i?86 maintainers to review >>>>> it too (and Honza for ipa-inline.c?). >>>> >>>> Honza, could you please take a look at the ipa-inline.c fix? I will >>>> split the patches and submit after Honza's review. I will also make >>>> the changes mentioned. >>>> >>>> Thanks >>>> Sri >>>> >>>> >>>>> >>>>> Jakub * ipa-inline.c (can_early_inline_edge_p): Flag an error when the function that cannot be inlined is target specific. * gcc.target/i386/inline_error.c: New test. Index: testsuite/gcc.target/i386/inline_error.c =================================================================== --- testsuite/gcc.target/i386/inline_error.c (revision 0) +++ testsuite/gcc.target/i386/inline_error.c (revision 0) @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O0 -mno-popcnt" } */ + +inline int __attribute__ ((__gnu_inline__, __always_inline__, target("popcnt"))) +foo () /* { dg-error "inlining failed in call to extern gnu_inline .* target specific option mismatch" } */ +{ + return 0; +} + +int bar() +{ + return foo (); +} /* { dg-error "called from here" } */ Index: ipa-inline.c =================================================================== --- ipa-inline.c (revision 200034) +++ ipa-inline.c (working copy) @@ -374,7 +374,31 @@ can_early_inline_edge_p (struct cgraph_edge *e) return false; } if (!can_inline_edge_p (e, true)) - return false; + { + enum availability avail; + struct cgraph_node *callee + = cgraph_function_or_thunk_node (e->callee, &avail); + /* Flag an error here when the inlining cannot happen because of target + option mismatch but the callee is marked as "always_inline". + Otherwise, in -O0 mode this could go unreported because the error + flagged in "expand_call_inline" in tree-inline.c might not execute. + Then, the linker could complain about a missing body for the callee + if it turned out that the callee was also marked "gnu_inline" with + extern inline keyword as bodies of such functions are not + generated. */ + if (!optimize + && e->inline_failed == CIF_TARGET_OPTION_MISMATCH + && lookup_attribute ("always_inline", DECL_ATTRIBUTES (callee->symbol.decl)) + && lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (callee->symbol.decl)) + && DECL_DECLARED_INLINE_P (callee->symbol.decl)) + { + error ("inlining failed in call to extern gnu_inline %q+F: %s", + callee->symbol.decl, + cgraph_inline_failed_string (CIF_TARGET_OPTION_MISMATCH)); + error ("called from here"); + } + return false; + } return true; }