From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 61139 invoked by alias); 24 Jul 2017 22:06:14 -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 59573 invoked by uid 89); 24 Jul 2017 22:06:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=H*Ad:D*gwu.edu, tomorrow 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 ESMTP; Mon, 24 Jul 2017 22:06:11 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id E588F5487A9; Tue, 25 Jul 2017 00:06:08 +0200 (CEST) Date: Mon, 24 Jul 2017 22:06:00 -0000 From: Jan Hubicka To: Jeff Law Cc: Eric Gallager , gcc-patches Subject: Re: Add -Wsuggest-attribute=cold Message-ID: <20170724220608.GA38863@kam.mff.cuni.cz> References: <20170724185633.GA43541@kam.mff.cuni.cz> <20170724190832.GA76225@kam.mff.cuni.cz> <51047328-5f82-a57d-08c3-05432d0d2c98@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <51047328-5f82-a57d-08c3-05432d0d2c98@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2017-07/txt/msg01475.txt.bz2 > On 07/24/2017 01:08 PM, Jan Hubicka wrote: > >> On Mon, Jul 24, 2017 at 2:56 PM, Jan Hubicka wrote: > >>> Hi, > >>> this patch adds -Wsuggest-attribute=cold because we can now statically detect > >>> cold functions atuomatically. > >>> > >>> Bootstrapped/regtested x86_64-linux. Plan to commit it tomorrow if there are no > >>> complains. > >>> > >>> Honza > >>> > >>> * invoke.texi (Wsuggest-attribute=cold): Document. > >>> * common.opt (Wsuggest-attribute=cold): New > >>> * ipa-pure-const.c (warn_function_cold): New function. > >>> * predict.c (compute_function_frequency): Use it. > >>> * predict.h (warn_function_cold): Declare. > >>> > >>> * gcc.dg/cold-1.c: New testcase. > >> > >> Would it be possible to also do -Wsuggest-attribute=hot for symmetry's > >> sake? Just wondering. > > > > It would be nice, but it is kind of impossible to detect hot spots of the > > program with reasonable certainity. (that is why profile feedback is useful :) > > This cold attribute detection looks really for very simple pattern where the > > function inavoidably calls other cold function or does something similarly > > unlikely (Eh or trap). This is fairly limited pattern, but it is useful i.e. > > to detect which libstdc++ functions can have this annotation that further > > improve branch prediction. > So what's the advantage of a user adding the attribute if the compiler > can infer it? Presumably by adding the attribute, it's known without > analysis and can be taken advantage of by its callers? Like most of the other -Wsuggest it only warn on functions that are externally visble. Adding attribute will improve code in other compilation units that does not see the function body. Honza > Jeff