From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 67253 invoked by alias); 31 Jul 2018 12:51:29 -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 67243 invoked by uid 89); 31 Jul 2018 12:51:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=streams, SPC, spc, dmalcolm@redhat.com X-HELO: mail-lj1-f195.google.com Received: from mail-lj1-f195.google.com (HELO mail-lj1-f195.google.com) (209.85.208.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 31 Jul 2018 12:51:27 +0000 Received: by mail-lj1-f195.google.com with SMTP id f8-v6so13624864ljk.1 for ; Tue, 31 Jul 2018 05:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5iggVgeBIffsPtppWQUlYQ4MjBo9j8T3VNEk+YaMMa0=; b=Sk6to4/KkqzJp7zNhcfUIe5vVwLd15GeDC7eG/tGHZBD8sh2jMsaBkdOr/G0vFPwDB uC4ZL5l2h8LGXDOxot2TeiL5yzlw37RmS8DaZVxnhhMLASmB3aAF3BDebofW6yfA+1ZZ XHW11NkLbIx3/hRcbbxDra7WR/pnUGano6w0aaJhFAuSmDJG3fK1tVuUKsM5qdDF7tSD gXLMb06ZXX/TJWHexP+V9ni6IddwP6v/qebkiPzw/qELhwRGcAgv4hsbR49neG3lhrIT j5mv2gxwVbtznZMnYHbBqqIvqg8thbr17NE2s8G46+JIG7s7dOInr5q6bRV/R4/G3c93 xDyg== MIME-Version: 1.0 References: <1532730752-10525-1-git-send-email-dmalcolm@redhat.com> <1532730752-10525-2-git-send-email-dmalcolm@redhat.com> In-Reply-To: <1532730752-10525-2-git-send-email-dmalcolm@redhat.com> From: Richard Biener Date: Tue, 31 Jul 2018 12:51:00 -0000 Message-ID: Subject: Re: [PATCH 1/5] Simplify dump_context by adding a dump_loc member function To: David Malcolm Cc: GCC Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg01938.txt.bz2 On Fri, Jul 27, 2018 at 11:48 PM David Malcolm wrote: > > This patch removes some duplicated code in dumpfile.c by > reimplementing the various dump_foo_loc calls in terms of dump_foo. OK. Richard. > gcc/ChangeLog: > * dump-context.h (dump_context::dump_loc): New decl. > * dumpfile.c (dump_context::dump_loc): New member function. > (dump_context::dump_gimple_stmt_loc): Reimplement using dump_loc > and dump_gimple_stmt. > (dump_context::dump_gimple_expr_loc): Likewise, using > dump_gimple_expr. > (dump_context::dump_generic_expr_loc): Likewise, using > dump_generic_expr. > (dump_context::dump_printf_loc_va): Likewise, using > dump_printf_va. > (dump_context::begin_scope): Explicitly using the global function > "dump_loc", rather than the member function. > --- > gcc/dump-context.h | 2 + > gcc/dumpfile.c | 119 ++++++++++++++--------------------------------------- > 2 files changed, 33 insertions(+), 88 deletions(-) > > diff --git a/gcc/dump-context.h b/gcc/dump-context.h > index a191e3a..f6df0b4 100644 > --- a/gcc/dump-context.h > +++ b/gcc/dump-context.h > @@ -39,6 +39,8 @@ class dump_context > > ~dump_context (); > > + void dump_loc (dump_flags_t dump_kind, const dump_location_t &loc); > + > void dump_gimple_stmt (dump_flags_t dump_kind, dump_flags_t extra_dump_flags, > gimple *gs, int spc); > > diff --git a/gcc/dumpfile.c b/gcc/dumpfile.c > index 176c9b8..3c8bc38 100644 > --- a/gcc/dumpfile.c > +++ b/gcc/dumpfile.c > @@ -474,6 +474,27 @@ dump_context::~dump_context () > delete m_pending; > } > > +/* Print LOC to the appropriate dump destinations, given DUMP_KIND. > + If optinfos are enabled, begin a new optinfo. */ > + > +void > +dump_context::dump_loc (dump_flags_t dump_kind, const dump_location_t &loc) > +{ > + location_t srcloc = loc.get_location_t (); > + > + if (dump_file && (dump_kind & pflags)) > + ::dump_loc (dump_kind, dump_file, srcloc); > + > + if (alt_dump_file && (dump_kind & alt_flags)) > + ::dump_loc (dump_kind, alt_dump_file, srcloc); > + > + if (optinfo_enabled_p ()) > + { > + optinfo &info = begin_next_optinfo (loc); > + info.handle_dump_file_kind (dump_kind); > + } > +} > + > /* Dump gimple statement GS with SPC indentation spaces and > EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled. */ > > @@ -504,25 +525,8 @@ dump_context::dump_gimple_stmt_loc (dump_flags_t dump_kind, > dump_flags_t extra_dump_flags, > gimple *gs, int spc) > { > - location_t srcloc = loc.get_location_t (); > - if (dump_file && (dump_kind & pflags)) > - { > - dump_loc (dump_kind, dump_file, srcloc); > - print_gimple_stmt (dump_file, gs, spc, dump_flags | extra_dump_flags); > - } > - > - if (alt_dump_file && (dump_kind & alt_flags)) > - { > - dump_loc (dump_kind, alt_dump_file, srcloc); > - print_gimple_stmt (alt_dump_file, gs, spc, dump_flags | extra_dump_flags); > - } > - > - if (optinfo_enabled_p ()) > - { > - optinfo &info = begin_next_optinfo (loc); > - info.handle_dump_file_kind (dump_kind); > - info.add_gimple_stmt (gs, spc, dump_flags | extra_dump_flags); > - } > + dump_loc (dump_kind, loc); > + dump_gimple_stmt (dump_kind, extra_dump_flags, gs, spc); > } > > /* Dump gimple statement GS with SPC indentation spaces and > @@ -557,25 +561,8 @@ dump_context::dump_gimple_expr_loc (dump_flags_t dump_kind, > gimple *gs, > int spc) > { > - location_t srcloc = loc.get_location_t (); > - if (dump_file && (dump_kind & pflags)) > - { > - dump_loc (dump_kind, dump_file, srcloc); > - print_gimple_expr (dump_file, gs, spc, dump_flags | extra_dump_flags); > - } > - > - if (alt_dump_file && (dump_kind & alt_flags)) > - { > - dump_loc (dump_kind, alt_dump_file, srcloc); > - print_gimple_expr (alt_dump_file, gs, spc, dump_flags | extra_dump_flags); > - } > - > - if (optinfo_enabled_p ()) > - { > - optinfo &info = begin_next_optinfo (loc); > - info.handle_dump_file_kind (dump_kind); > - info.add_gimple_expr (gs, spc, dump_flags | extra_dump_flags); > - } > + dump_loc (dump_kind, loc); > + dump_gimple_expr (dump_kind, extra_dump_flags, gs, spc); > } > > > @@ -611,25 +598,8 @@ dump_context::dump_generic_expr_loc (dump_flags_t dump_kind, > dump_flags_t extra_dump_flags, > tree t) > { > - location_t srcloc = loc.get_location_t (); > - if (dump_file && (dump_kind & pflags)) > - { > - dump_loc (dump_kind, dump_file, srcloc); > - print_generic_expr (dump_file, t, dump_flags | extra_dump_flags); > - } > - > - if (alt_dump_file && (dump_kind & alt_flags)) > - { > - dump_loc (dump_kind, alt_dump_file, srcloc); > - print_generic_expr (alt_dump_file, t, dump_flags | extra_dump_flags); > - } > - > - if (optinfo_enabled_p ()) > - { > - optinfo &info = begin_next_optinfo (loc); > - info.handle_dump_file_kind (dump_kind); > - info.add_tree (t, dump_flags | extra_dump_flags); > - } > + dump_loc (dump_kind, loc); > + dump_generic_expr (dump_kind, extra_dump_flags, t); > } > > /* Output a formatted message using FORMAT on appropriate dump streams. */ > @@ -672,35 +642,8 @@ dump_context::dump_printf_loc_va (dump_flags_t dump_kind, > const dump_location_t &loc, > const char *format, va_list ap) > { > - location_t srcloc = loc.get_location_t (); > - > - if (dump_file && (dump_kind & pflags)) > - { > - dump_loc (dump_kind, dump_file, srcloc); > - va_list aq; > - va_copy (aq, ap); > - vfprintf (dump_file, format, aq); > - va_end (aq); > - } > - > - if (alt_dump_file && (dump_kind & alt_flags)) > - { > - dump_loc (dump_kind, alt_dump_file, srcloc); > - va_list aq; > - va_copy (aq, ap); > - vfprintf (alt_dump_file, format, aq); > - va_end (aq); > - } > - > - if (optinfo_enabled_p ()) > - { > - optinfo &info = begin_next_optinfo (loc); > - info.handle_dump_file_kind (dump_kind); > - va_list aq; > - va_copy (aq, ap); > - info.add_printf_va (format, aq); > - va_end (aq); > - } > + dump_loc (dump_kind, loc); > + dump_printf_va (dump_kind, format, ap); > } > > /* Output VALUE in decimal to appropriate dump streams. */ > @@ -767,13 +710,13 @@ dump_context::begin_scope (const char *name, const dump_location_t &loc) > > if (dump_file) > { > - dump_loc (MSG_NOTE, dump_file, loc.get_location_t ()); > + ::dump_loc (MSG_NOTE, dump_file, loc.get_location_t ()); > fprintf (dump_file, "=== %s ===\n", name); > } > > if (alt_dump_file) > { > - dump_loc (MSG_NOTE, alt_dump_file, loc.get_location_t ()); > + ::dump_loc (MSG_NOTE, alt_dump_file, loc.get_location_t ()); > fprintf (alt_dump_file, "=== %s ===\n", name); > } > > -- > 1.8.5.3 >