From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 97965 invoked by alias); 20 Aug 2015 08:08:33 -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 97952 invoked by uid 89); 20 Aug 2015 08:08:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.2 required=5.0 tests=AWL,BAYES_50,FREEMAIL_FROM,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-ig0-f175.google.com Received: from mail-ig0-f175.google.com (HELO mail-ig0-f175.google.com) (209.85.213.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 20 Aug 2015 08:08:22 +0000 Received: by igfj19 with SMTP id j19so25112693igf.1 for ; Thu, 20 Aug 2015 01:08:20 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.50.124.33 with SMTP id mf1mr5845154igb.23.1440058100271; Thu, 20 Aug 2015 01:08:20 -0700 (PDT) Received: by 10.107.32.140 with HTTP; Thu, 20 Aug 2015 01:08:20 -0700 (PDT) In-Reply-To: References: Date: Thu, 20 Aug 2015 08:16:00 -0000 Message-ID: Subject: Re: [PATCH] Only accept BUILT_IN_NORMAL stringops for interesting_stringop_to_profile_p From: Richard Biener To: "Yangfei (Felix)" Cc: "gcc-patches@gcc.gnu.org" , Jiangjiji Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg01162.txt.bz2 On Thu, Aug 20, 2015 at 5:17 AM, Yangfei (Felix) wrote: > Hi, > > As DECL_FUNCTION_CODE is overloaded for builtin functions in different classes, so need to check builtin class before using fcode. > Patch posted below. Bootstrapped on x86_64-suse-linux, OK for trunk? > Thanks. Ugh. The code in the callers already looks like it could have some TLC, like instead of fndecl = gimple_call_fndecl (stmt); if (!fndecl) return false; fcode = DECL_FUNCTION_CODE (fndecl); if (!interesting_stringop_to_profile_p (fndecl, stmt, &size_arg)) return false; simply do if (!gimple_call_builtin_p (stmt, BUILT_IN_NORMAL)) return false; if (!interesting_stringop_to_profile_p (gimple_call_fndecl (stmt), ....)) similar for the other caller. interesting_stringop_to_profile_p can also get function-code directly from stmt, removing the redundant first argument or even do the gimple_call_builtin_p call itself. Mind reworking the patch accordingly? Thanks, Richard. > Index: gcc/value-prof.c > =================================================================== > --- gcc/value-prof.c (revision 141081) > +++ gcc/value-prof.c (working copy) > @@ -1547,8 +1547,12 @@ gimple_ic_transform (gimple_stmt_iterator *gsi) > static bool > interesting_stringop_to_profile_p (tree fndecl, gimple call, int *size_arg) > { > - enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl); > + enum built_in_function fcode; > > + if (DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL) > + return false; > + > + fcode = DECL_FUNCTION_CODE (fndecl); > if (fcode != BUILT_IN_MEMCPY && fcode != BUILT_IN_MEMPCPY > && fcode != BUILT_IN_MEMSET && fcode != BUILT_IN_BZERO) > return false; > Index: gcc/ChangeLog > =================================================================== > --- gcc/ChangeLog (revision 141081) > +++ gcc/ChangeLog (working copy) > @@ -1,3 +1,9 @@ > +2015-08-20 Felix Yang > + Jiji Jiang > + > + * value-prof.c (interesting_stringop_to_profile_p): Only accept string > + operations which belong to the BUILT_IN_NORMAL builtin class. > + > 2015-08-18 Segher Boessenkool > > Backport from mainline: