From patchwork Tue May 9 19:00:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 760301 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 3wMpcG1WBpz9s06 for ; Wed, 10 May 2017 05:01:01 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="k0SOXTw5"; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=YdjOBGbV1UkctaRkfvUQTlVShfvTdhrF+SJZREKreyUrwHcgav 4hQ/BAGFkascrgGjQdsR87V0WWdGRquKjE0JlLERtIeWNSmxNQr0PWpMSS0eholn m6MR/ThnR34Vsj3/L8guF4R08DyO62ezzOQgR3W9cHURMLkNKFRWxDFRs= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=cGa/s0Y16OkeCo3b9dPeCZsb2is=; b=k0SOXTw5TEGhFkLOTuTR qeGxlpH7VotrvSXUefcD2xjXFEvRS9QazjQ7F39hQVKpVsK9jyM56lS5TPi6z4CP jl41h0tBohSb4/7G0arZGmcz/xutj2cvFHZNtaCAWdwKcEIhehbQ8c3J149kvC32 BQGBCFknrq636mepIi+ZToA= Received: (qmail 53402 invoked by alias); 9 May 2017 19:00:46 -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 53329 invoked by uid 89); 9 May 2017 19:00:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=extracts X-HELO: mail-yw0-f170.google.com Received: from mail-yw0-f170.google.com (HELO mail-yw0-f170.google.com) (209.85.161.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 May 2017 19:00:37 +0000 Received: by mail-yw0-f170.google.com with SMTP id l135so5218390ywb.2 for ; Tue, 09 May 2017 12:00:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=zWteV/8NHviNgwaPfFf1d+/JXAC3aGSf4uOUWc2PE+U=; b=MJo6I4I3d/BG/KXQm2k4edEQLCxb0cXbGa+Pb++4089AnLHp5ZvGK+nj4lHgUtlZ4/ JEamKyGnmhdXrAtI/fUeKMszE3UKPNg03quskUq1J6cqXu9DecFPrWdLsALWmfcSaC64 1z0m9W9Jv5sfAi0el650DB/4aWIU/ol55A6AMX2B0omK7zxvxKoeiKJWi9iDO1+eiCWx pPx3dOJiSeKpVmAg22WnAbS8ONyve1EAfSyvTBUAiK5gqGxbhHOsrKalFdsrHFjx1Kul 3Og0QOFQP4KgJuAei83T5i106ctR3cGfS/zqf5HSRDz1bT03YUjto3gr2VU6iwSa2plS 1Lsw== X-Gm-Message-State: AODbwcBdVnCE6u5YeKrWPYPUFCuwBEVo8Tom5JktqMnfPjs3WMMr+4aa BitFrJiBx8nGZA== X-Received: by 10.13.234.77 with SMTP id t74mr1394304ywe.66.1494356426553; Tue, 09 May 2017 12:00:26 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:f6d0:5ac5:64cd:f102? ([2620:10d:c091:200::2:16e0]) by smtp.googlemail.com with ESMTPSA id 141sm398188ywf.66.2017.05.09.12.00.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 May 2017 12:00:26 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [PATCH] make RTL/TREE/IPA dump kind an index Message-ID: <9eb0ff26-4b3a-a1ab-c0ae-6e39639ab179@acm.org> Date: Tue, 9 May 2017 15:00:24 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0 MIME-Version: 1.0 Currently, the TDF_foo flags serve 3 purposes: 1) what kind of dump 2) how detailed to print it 3) auxiliary message control This addresses #1, which currently uses a bit mask of TDF_{TREE,RTL,IPA}, of which exactly one must be set. The patch changes things so that these are now an index value (I hesitate to say enumeration, because they're still raw ints). A TDF_KIND(X) accessor extracts this value. (I left the spare bit between the TDF_KIND_MASK and TDF_ADDRESS for the moment.) In addition I added 'TDF_LANG' for language-specific dump control, of which -fdump-translation-unit and -fdump-class-hierarchy become. And can also be controlled by -fdump-lang-all. (rather than -fdump-tree-all) Next move will be to move -fdump-class-hierarchy into a more generic structure (and -fdump-translation-unit, if my patch to remove it is not accepted). ok? nathan 2017-05-09 Nathan Sidwell * dumpfile.h (TDI_lang_all): New. (TDF_KIND): New. Renumber others (TDF_LANG, TDF_TREE, TDF_RTL, TDF_IPA): Enumerate value, rather than bits. * dumpfile.c (dump_files): Mark language dumps as TDF_LANG. add lang-all. (get_dump_file_name): Adjust suffix generation. (dump_enable_all): Use TDF_KIND. * doc/invoke.texi (-fdump-lang-all): Document. Index: doc/invoke.texi =================================================================== --- doc/invoke.texi (revision 247809) +++ doc/invoke.texi (working copy) @@ -543,6 +543,7 @@ Objective-C and Objective-C++ Dialects}. -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol -fdump-final-insns@r{[}=@var{file}@r{]} -fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline @gol +-fdump-lang-all @gol -fdump-passes @gol -fdump-rtl-@var{pass} -fdump-rtl-@var{pass}=@var{filename} @gol -fdump-statistics @gol @@ -12970,6 +12971,10 @@ Dump after function inlining. @end table +@item -fdump-lang-all +@opindex fdump-lang-all +Control the dumping of language-specific information. + @item -fdump-passes @opindex fdump-passes Print on @file{stderr} the list of optimization passes that are turned Index: dumpfile.c =================================================================== --- dumpfile.c (revision 247809) +++ dumpfile.c (working copy) @@ -57,9 +57,9 @@ static struct dump_file_info dump_files[ 0, 0, 0, 0, 0, false, false}, {".ipa-clones", "ipa-clones", NULL, NULL, NULL, NULL, NULL, TDF_IPA, 0, 0, 0, 0, 0, false, false}, - {".tu", "translation-unit", NULL, NULL, NULL, NULL, NULL, TDF_TREE, + {".tu", "translation-unit", NULL, NULL, NULL, NULL, NULL, TDF_LANG, 0, 0, 0, 0, 1, false, false}, - {".class", "class-hierarchy", NULL, NULL, NULL, NULL, NULL, TDF_TREE, + {".class", "class-hierarchy", NULL, NULL, NULL, NULL, NULL, TDF_LANG, 0, 0, 0, 0, 2, false, false}, {".original", "tree-original", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 0, 0, 3, false, false}, @@ -69,6 +69,8 @@ static struct dump_file_info dump_files[ 0, 0, 0, 0, 5, false, false}, #define FIRST_AUTO_NUMBERED_DUMP 6 + {NULL, "lang-all", NULL, NULL, NULL, NULL, NULL, TDF_LANG, + 0, 0, 0, 0, 0, false, false}, {NULL, "tree-all", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 0, 0, 0, false, false}, {NULL, "rtl-all", NULL, NULL, NULL, NULL, NULL, TDF_RTL, @@ -115,7 +117,7 @@ static const struct dump_option_value_in {"missed", MSG_MISSED_OPTIMIZATION}, {"note", MSG_NOTE}, {"optall", MSG_ALL}, - {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA + {"all", ~(TDF_KIND_MASK | TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC | TDF_VERBOSE | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV | TDF_GIMPLE)}, @@ -282,15 +284,11 @@ get_dump_file_name (struct dump_file_inf dump_id[0] = '\0'; else { - char suffix; - if (dfi->pflags & TDF_TREE) - suffix = 't'; - else if (dfi->pflags & TDF_IPA) - suffix = 'i'; - else - suffix = 'r'; - - if (snprintf (dump_id, sizeof (dump_id), ".%03d%c", dfi->num, suffix) < 0) + /* LANG, TREE, RTL, IPA. */ + char suffix = "ltri"[TDF_KIND (dfi->pflags)]; + + if (snprintf (dump_id, sizeof (dump_id), ".%03d%c", dfi->num, suffix) + < 0) dump_id[0] = '\0'; } @@ -657,13 +655,13 @@ int gcc::dump_manager:: dump_enable_all (int flags, const char *filename) { - int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA)); + int ir_dump_type = TDF_KIND (flags); int n = 0; size_t i; for (i = TDI_none + 1; i < (size_t) TDI_end; i++) { - if ((dump_files[i].pflags & ir_dump_type)) + if (TDF_KIND (dump_files[i].pflags) == ir_dump_type) { const char *old_filename = dump_files[i].pfilename; dump_files[i].pstate = -1; @@ -684,7 +682,7 @@ dump_enable_all (int flags, const char * for (i = 0; i < m_extra_dump_files_in_use; i++) { - if ((m_extra_dump_files[i].pflags & ir_dump_type)) + if (TDF_KIND (m_extra_dump_files[i].pflags) & ir_dump_type) { const char *old_filename = m_extra_dump_files[i].pfilename; m_extra_dump_files[i].pstate = -1; Index: dumpfile.h =================================================================== --- dumpfile.h (revision 247809) +++ dumpfile.h (working copy) @@ -35,6 +35,8 @@ enum tree_dump_index TDI_original, /* dump each function before optimizing it */ TDI_generic, /* dump each function after genericizing it */ TDI_nested, /* dump each function after unnesting it */ + + TDI_lang_all, /* enable all the language dumps. */ TDI_tree_all, /* enable all the GENERIC/GIMPLE dumps. */ TDI_rtl_all, /* enable all the RTL dumps. */ TDI_ipa_all, /* enable all the IPA dumps. */ @@ -47,21 +49,25 @@ enum tree_dump_index the DUMP_OPTIONS array in dumpfile.c. The TDF_* flags coexist with MSG_* flags (for -fopt-info) and the bit values must be chosen to allow that. */ -#define TDF_ADDRESS (1 << 0) /* dump node addresses */ -#define TDF_SLIM (1 << 1) /* don't go wild following links */ -#define TDF_RAW (1 << 2) /* don't unparse the function */ -#define TDF_DETAILS (1 << 3) /* show more detailed info about +#define TDF_LANG 0 /* is a lang-specific dump. */ +#define TDF_TREE 1 /* is a tree dump */ +#define TDF_RTL 2 /* is a RTL dump */ +#define TDF_IPA 3 /* is an IPA dump */ +#define TDF_KIND_MASK 3 +#define TDF_KIND(X) ((X) & TDF_KIND_MASK) + +#define TDF_ADDRESS (1 << 3) /* dump node addresses */ +#define TDF_SLIM (1 << 4) /* don't go wild following links */ +#define TDF_RAW (1 << 5) /* don't unparse the function */ +#define TDF_DETAILS (1 << 6) /* show more detailed info about each pass */ -#define TDF_STATS (1 << 4) /* dump various statistics about +#define TDF_STATS (1 << 7) /* dump various statistics about each pass */ -#define TDF_BLOCKS (1 << 5) /* display basic block boundaries */ -#define TDF_VOPS (1 << 6) /* display virtual operands */ -#define TDF_LINENO (1 << 7) /* display statement line numbers */ -#define TDF_UID (1 << 8) /* display decl UIDs */ - -#define TDF_TREE (1 << 9) /* is a tree dump */ -#define TDF_RTL (1 << 10) /* is a RTL dump */ -#define TDF_IPA (1 << 11) /* is an IPA dump */ +#define TDF_BLOCKS (1 << 8) /* display basic block boundaries */ +#define TDF_VOPS (1 << 9) /* display virtual operands */ +#define TDF_LINENO (1 << 10) /* display statement line numbers */ +#define TDF_UID (1 << 11) /* display decl UIDs */ + #define TDF_STMTADDR (1 << 12) /* Address of stmt. */ #define TDF_GRAPH (1 << 13) /* a graph dump is being emitted */