From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 122531 invoked by alias); 9 Jun 2017 09:04:44 -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 121153 invoked by uid 89); 9 Jun 2017 09:04:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=sk:rep.dot, repdotnopgmailcom, U*rep.dot.nop, sk:repdot X-HELO: mail-ua0-f181.google.com Received: from mail-ua0-f181.google.com (HELO mail-ua0-f181.google.com) (209.85.217.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Jun 2017 09:04:41 +0000 Received: by mail-ua0-f181.google.com with SMTP id h39so30552950uaa.3 for ; Fri, 09 Jun 2017 02:04:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Eh5Xj/tzFxbe9GsEsn3D9JxYIQjJnbm1nbG6xjUwzu4=; b=e5s+EPAyCSovqDkhRoJAToBS8tSZZOqq7jKUZd5RnSNwIPl/D1gG340VXZrkTl6A5Q HIvEEB221TgzQaehIeOPKG8nvMmdm7R6jTGD55ZjQcirCh6AlDhzqr4S5065Xhgvf14r 0Q6ggXQfa0fztEFgmTFowZy0n6WuqE8Dh9HgV1mpMwr1PKq1Cpeeh/DUM6m/KUuRrkTH K4jie47QRrO2Nh9NFsH7ck/xQ+YxqXOxVaQeH88m2kUumpJZ+9RFefM+lKf82mSb5kih kthrbm+FnkNYjqsWYr3LONy3q5k+F5quXR63/BBNC28EkVhyqGrHs0wP+VJfS8hndb99 uiAQ== X-Gm-Message-State: AODbwcA7y+YQ+6HlGiAETSbfXgMsnbQ9tON4ykcWT9MGB94N4q8o4UAF cv8uT6B0UilsbtZAZzaqGQXkko++Y/zv X-Received: by 10.176.28.28 with SMTP id a28mr19013367uaj.38.1496999084134; Fri, 09 Jun 2017 02:04:44 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.50.131 with HTTP; Fri, 9 Jun 2017 02:04:43 -0700 (PDT) In-Reply-To: <4E3B1900-B7BF-4332-B6E4-25FA4BEC81B8@gmail.com> References: <20170608125249.GB65161@kam.mff.cuni.cz> <4E3B1900-B7BF-4332-B6E4-25FA4BEC81B8@gmail.com> From: Christophe Lyon Date: Fri, 09 Jun 2017 09:04:00 -0000 Message-ID: Subject: Re: Statically propagate basic blocks which are likely executed 0 times To: Jan Hubicka Cc: "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg00582.txt.bz2 Hi, On 9 June 2017 at 08:43, Bernhard Reutner-Fischer wrote: > On 8 June 2017 14:52:49 CEST, Jan Hubicka wrote: >>Hi, >>this patch adds static code to detect basic block with 0 execution >>count. >>Those are basic block either reached only by EH or those which leads to >>call of >>function decorated with cold attribute. >> >>Function decorated by noreturn is not sufficient, because exit(0) is a >>call that >>is executed in most of program executions. > > But aren't paths to exit except in main cold resp unlikely, at least exit (!0)? > >> >>Note that internally we have cold and unlikely functions where the >>first is >>optimized for size but the second is known to be unlikely executed by >>the >>program and is offloaded to special unlikely section. >>Perhaps we want to expose this to user and also distinguish between >>cold and >>unlikely function attributes. I guess this however can be done >>incrementally. >> >>As a followup I will decoreate trap/abort and friends with cold >>attributes. >> >>Bootstrapped/regtested x86_64-linux, will commit it shortly. >> > >>+/* Return true if STMT is known to be unlikely executed. */ >>+ >>+static bool >>+unlikely_executed_stmt_p (gimple *stmt) >>+{ >>+ if (!is_gimple_call (stmt)) >>+ return false; >>+ /* NORETURN attribute enough is not strong enough: exit() may be > > s/attribute enough/attribute alone/ > >>quite >>+ likely executed once during program run. */ >>+ if (gimple_call_fntype (stmt) >>+ && lookup_attribute ("cold", >>+ TYPE_ATTRIBUTES (gimple_call_fntype (stmt))) >>+ && !lookup_attribute ("cold", DECL_ATTRIBUTES >>(current_function_decl))) >>+ return true; >>+ tree decl = gimple_call_fndecl (stmt); >>+ if (!decl) >>+ return false; > > Can decl ever be NULL here? > >>+ if (lookup_attribute ("cold", DECL_ATTRIBUTES (decl)) >>+ && !lookup_attribute ("cold", DECL_ATTRIBUTES >>(current_function_decl))) >>+ return true; >>+ >>+ cgraph_node *n = cgraph_node::get (decl); >>+ if (!n) >>+ return false; >>+ enum availability avail; > > Didn't style want us to omit enum here since its C++ now? > >>+ n = n->ultimate_alias_target (&avail); >>+ if (avail < AVAIL_AVAILABLE) >>+ return NULL; > > false > > thanks, > Since this commit (r249013), I've noticed a regression on arm targets: FAIL: gcc.target/arm/cold-lc.c scan-assembler-not bl[^\n]*dump_stack >>+ if (!n->analyzed >>+ || n->decl == current_function_decl) >>+ return false; >>+ return n->frequency == NODE_FREQUENCY_UNLIKELY_EXECUTED; >>+} >