From patchwork Mon Jun 5 09:46:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 771169 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wh91w5tpXz9s2P for ; Mon, 5 Jun 2017 19:46:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="IkPVO5Qn"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=D+ruVPHSbJON5dr7p +v94asT7Pb22XfL3GEGh373x68w3uodMIh8dzhOpmaR+38ri8BkRINZXLOHnmqnr lkbM0NjBiK/ZyH2Qg89HfB+iW/eCttG8xnz2uuAynMViXStEfsmDnXGNXpGFi6Cb 2o2pKIkRImnO/5092vpM3nM7XA= 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:date :from:to:cc:subject:message-id:reply-to:references:mime-version :content-type:in-reply-to; s=default; bh=NlpKyLSZ3IhfEcuaKSCTw3d vFCo=; b=IkPVO5Qn/1C1gA/zp5G4gfutXVdd/S6dMUJ3O8/sdrM2JtqUq/Pc9eY fNkeEAIu1kRvDB/NZfbNmdu+O5sI1nB+UxJqw+3A/JDVZ/RAL/eAb7Kx+g/SMaKu pmYcSKv3RbT/U6oVEUsPbvmlMY+rdDwSZs6V+QDwjsBAfZuFW55A= Received: (qmail 114205 invoked by alias); 5 Jun 2017 09:46:09 -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 113656 invoked by uid 89); 5 Jun 2017 09:46:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.9 required=5.0 tests=BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*a:set, H*a:sender 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, 05 Jun 2017 09:46:07 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E02A883F47; Mon, 5 Jun 2017 09:46:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E02A883F47 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E02A883F47 Received: from tucnak.zalov.cz (ovpn-116-214.ams2.redhat.com [10.36.116.214]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7275A17979; Mon, 5 Jun 2017 09:46:09 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v559k6GA013276; Mon, 5 Jun 2017 11:46:06 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v559k3bK013275; Mon, 5 Jun 2017 11:46:03 +0200 Date: Mon, 5 Jun 2017 11:46:03 +0200 From: Jakub Jelinek To: Nathan Sidwell Cc: GCC Patches , Richard Biener , Martin =?utf-8?B?TGnFoWth?= Subject: Re: [PATCH] gcc::context creation Message-ID: <20170605094603.GB2154@tucnak> Reply-To: Jakub Jelinek References: <7f7f64a5-f820-a19a-d4ea-77b05f746499@acm.org> <98b0273e-9390-18ce-c041-31f843b8b1f8@acm.org> <20170524105728.GZ8499@tucnak> <9f46c2f8-2bee-ef41-3c98-acf7d0012e54@acm.org> <20170524115731.GE8499@tucnak> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes On Wed, May 24, 2017 at 08:00:30AM -0400, Nathan Sidwell wrote: > On 05/24/2017 07:57 AM, Jakub Jelinek wrote: > > > The numbering is not to differentiate between dumps of the same name, that > > is done through numbered suffixes of the dump names, but to make the order > > of passes visible to the user and for sorted file listing to be provided in > > that order. So, rather than having lang files unnumbered, I think it is > > better to number them and just have a maximum of lang dumps and if some FE > > registers fewers, bump m_next_dump accordingly (create a hole). > > That is pretty much the standard behavior, if some dump is registered, but > > for whatever reason not dumped, you also get a hole. > > oh, ok. Seems fine to me. Here is a patch to implement that. I chose to keep the 3 dumps predefined dumps and just tweak their registered number, otherwise the changes would be bigger. The patch additionally renames TDI_generic to TDI_gimple (to match the dump name and content) and because we have more than 256 dumps these days and we register them all even at -O0, the patch avoids 4 unnecessary reallocations. Ok for trunk if testing passes? 2017-06-05 Jakub Jelinek * dumpfile.h (enum tree_dump_index): Rename TDI_generic to TDI_gimple. (class dump_manager): Add register_dumps method. * dumpfile.c: Include langhooks.h. (dump_files): Use 0 instead of 3/4/5 for TDI_{original,gimple,nested}. (FIRST_AUTO_NUMBERED_DUMP): Decrease to 1. (FIRST_ME_AUTO_NUMBERED_DUMP): Define. (dump_manager::dump_register): Start with 512 entries instead of 32. (dump_manager::register_dumps): New method. * toplev.c (general_init): Instead of invoking register_dumps langhook, invoke register_dumps method on the dump manager. * gimplify.c (gimplify_function_tree): Use TDI_gimple instead of TDI_generic. * gimple-parser.c (c_parser_parse_gimple_body): Use TDI_gimple instead of TDI_generic. Jakub --- gcc/dumpfile.h.jj 2017-06-02 09:01:10.000000000 +0200 +++ gcc/dumpfile.h 2017-06-05 11:20:07.563008969 +0200 @@ -31,7 +31,7 @@ enum tree_dump_index TDI_inheritance, /* dump type inheritance graph. */ TDI_clones, /* dump IPA cloning decisions. */ TDI_original, /* dump each function before optimizing it */ - TDI_generic, /* dump each function after genericizing it */ + TDI_gimple, /* dump each function after gimplifying it */ TDI_nested, /* dump each function after unnesting it */ TDI_lang_all, /* enable all the language dumps. */ @@ -212,6 +212,11 @@ public: dump_register (const char *suffix, const char *swtch, const char *glob, dump_kind dkind, int optgroup_flags, bool take_ownership); + /* Allow languages and middle-end to register their dumps before the + optimization passes. */ + void + register_dumps (); + /* Return the dump_file_info for the given phase. */ struct dump_file_info * get_dump_file_info (int phase) const; --- gcc/dumpfile.c.jj 2017-06-02 09:01:10.000000000 +0200 +++ gcc/dumpfile.c 2017-06-05 11:21:27.381013150 +0200 @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. #include "dumpfile.h" #include "context.h" #include "tree-cfg.h" +#include "langhooks.h" /* If non-NULL, return one past-the-end of the matching SUBPART of the WHOLE string. */ @@ -59,10 +60,11 @@ static struct dump_file_info dump_files[ DUMP_FILE_INFO (".cgraph", "ipa-cgraph", DK_ipa, 0), DUMP_FILE_INFO (".type-inheritance", "ipa-type-inheritance", DK_ipa, 0), DUMP_FILE_INFO (".ipa-clones", "ipa-clones", DK_ipa, 0), - DUMP_FILE_INFO (".original", "tree-original", DK_tree, 3), - DUMP_FILE_INFO (".gimple", "tree-gimple", DK_tree, 4), - DUMP_FILE_INFO (".nested", "tree-nested", DK_tree, 5), -#define FIRST_AUTO_NUMBERED_DUMP 3 + DUMP_FILE_INFO (".original", "tree-original", DK_tree, 0), + DUMP_FILE_INFO (".gimple", "tree-gimple", DK_tree, 0), + DUMP_FILE_INFO (".nested", "tree-nested", DK_tree, 0), +#define FIRST_AUTO_NUMBERED_DUMP 1 +#define FIRST_ME_AUTO_NUMBERED_DUMP 3 DUMP_FILE_INFO (NULL, "lang-all", DK_lang, 0), DUMP_FILE_INFO (NULL, "tree-all", DK_tree, 0), @@ -179,7 +181,7 @@ dump_register (const char *suffix, const if (count >= m_extra_dump_files_alloced) { if (m_extra_dump_files_alloced == 0) - m_extra_dump_files_alloced = 32; + m_extra_dump_files_alloced = 512; else m_extra_dump_files_alloced *= 2; m_extra_dump_files = XRESIZEVEC (struct dump_file_info, @@ -200,6 +202,25 @@ dump_register (const char *suffix, const } +/* Allow languages and middle-end to register their dumps before the + optimization passes. */ +void +gcc::dump_manager:: +register_dumps () +{ + lang_hooks.register_dumps (this); + /* If this assert fails, some FE registered more than + FIRST_ME_AUTO_NUMBERED_DUMP - FIRST_AUTO_NUMBERED_DUMP + dump files. Bump FIRST_ME_AUTO_NUMBERED_DUMP accordingly. */ + gcc_assert (m_next_dump <= FIRST_ME_AUTO_NUMBERED_DUMP); + if (m_next_dump < FIRST_ME_AUTO_NUMBERED_DUMP) + m_next_dump = FIRST_ME_AUTO_NUMBERED_DUMP; + dump_files[TDI_original].num = m_next_dump++; + dump_files[TDI_gimple].num = m_next_dump++; + dump_files[TDI_nested].num = m_next_dump++; +} + + /* Return the dump_file_info for the given phase. */ struct dump_file_info * --- gcc/toplev.c.jj 2017-06-02 09:01:10.000000000 +0200 +++ gcc/toplev.c 2017-06-05 11:04:04.085038583 +0200 @@ -1168,9 +1168,9 @@ general_init (const char *argv0, bool in dump manager. */ g = new gcc::context (); - /* Allow languages to register their dumps before the optimization - passes. */ - lang_hooks.register_dumps (g->get_dumps ()); + /* Allow languages and middle-end to register their dumps before the + optimization passes. */ + g->get_dumps ()->register_dumps (); /* Create the passes. */ g->set_passes (new gcc::pass_manager (g)); --- gcc/gimplify.c.jj 2017-06-02 09:01:20.000000000 +0200 +++ gcc/gimplify.c 2017-06-05 11:21:45.097792114 +0200 @@ -12732,7 +12732,7 @@ gimplify_function_tree (tree fndecl) pop_cfun (); - dump_function (TDI_generic, fndecl); + dump_function (TDI_gimple, fndecl); } /* Return a dummy expression of type TYPE in order to keep going after an --- gcc/c/gimple-parser.c.jj 2017-06-02 09:01:07.000000000 +0200 +++ gcc/c/gimple-parser.c 2017-06-05 11:22:04.636548346 +0200 @@ -116,7 +116,7 @@ c_parser_parse_gimple_body (c_parser *pa we have to go through lowering again. */ cfun->curr_properties = PROP_gimple_any; - dump_function (TDI_generic, current_function_decl); + dump_function (TDI_gimple, current_function_decl); } /* Parse a compound statement in gimple function body.