From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 112214 invoked by alias); 24 Jul 2017 22:19:23 -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 110969 invoked by uid 89); 24 Jul 2017 22:19:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Jul 2017 22:19:21 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9271FC1EA9E9; Mon, 24 Jul 2017 22:19:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9271FC1EA9E9 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=law@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9271FC1EA9E9 Received: from localhost.localdomain (ovpn-116-49.phx2.redhat.com [10.3.116.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id 447FC6EE2D; Mon, 24 Jul 2017 22:19:20 +0000 (UTC) Subject: Re: Add -Wsuggest-attribute=cold To: Jan Hubicka Cc: Eric Gallager , gcc-patches References: <20170724185633.GA43541@kam.mff.cuni.cz> <20170724190832.GA76225@kam.mff.cuni.cz> <51047328-5f82-a57d-08c3-05432d0d2c98@redhat.com> <20170724220608.GA38863@kam.mff.cuni.cz> From: Jeff Law Message-ID: <8953b692-45ac-fa22-43b1-8bd41b06ff29@redhat.com> Date: Mon, 24 Jul 2017 22:19:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20170724220608.GA38863@kam.mff.cuni.cz> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg01479.txt.bz2 On 07/24/2017 04:06 PM, Jan Hubicka wrote: >> 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. OK. THanks for confirming. Jeff