From patchwork Mon Jun 14 09:39:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 55514 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]) by ozlabs.org (Postfix) with SMTP id A7258B7D8B for ; Mon, 14 Jun 2010 20:17:53 +1000 (EST) Received: (qmail 26950 invoked by alias); 14 Jun 2010 10:17:46 -0000 Received: (qmail 26842 invoked by uid 22791); 14 Jun 2010 10:17:43 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_CF, TW_VF, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 14 Jun 2010 10:17:39 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5EAHbRf016048 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 14 Jun 2010 06:17:37 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5EAHZZu006419 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 14 Jun 2010 06:17:36 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o5E9dH4D003617; Mon, 14 Jun 2010 11:39:17 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o5E9dGIC003496; Mon, 14 Jun 2010 11:39:16 +0200 Date: Mon, 14 Jun 2010 11:39:16 +0200 From: Jakub Jelinek To: Vladimir Makarov , Alexander Monakov , Andrey Belevantsev Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Change sel_print from vararg macro to out of line function Message-ID: <20100614093916.GF7811@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes 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 Hi! This patch saves almost 19KB of .text (roughly 21% of sel-sched{,-dump}.c .text) and removes varargs macro while doing that (which don't have to be supported by pre-ISOC99 bootstrap compilers). Not that I care much about such bootstrap compilers, but having large inline expansion of this macro in almost 150 places when it is in code not enabled by default is strange (and sched_dump_to_dot_p is only true when invoking sel_debug_cfg{,_1} from the debugger). Invoking sel_debug_cfg{,_1} from the debugger ICEs for me though even before the patch, I probably don't know where is the right spot to invoke this function, so I haven't tested sel_print when creating the *.dot file, can one of the sel-sched authors please test that? 2010-06-14 Jakub Jelinek PR bootstrap/44426 * sel-sched-dump.h (sel_prepare_string_for_dot_label): Remove prototype. (sel_print_to_dot): Remove macro. (sel_print): Likewise. New prototype. * sel-sched-dump.c (sel_prepare_string_for_dot_label): Make static. (sel_print): New function. Jakub --- gcc/sel-sched-dump.h.jj 2010-06-14 11:08:04.000000000 +0200 +++ gcc/sel-sched-dump.h 2010-06-14 11:15:38.000000000 +0200 @@ -177,34 +177,13 @@ extern void dump_insn_1 (insn_t, int); extern void dump_insn (insn_t); extern void debug_insn (insn_t); -extern void sel_prepare_string_for_dot_label (char *); - /* When this flag is on, we are dumping to the .dot file. When it is off, we are dumping to log. */ extern bool sched_dump_to_dot_p; - -/* This macro acts like printf but dumps information to the .dot file. - Used when dumping control flow. */ -#define sel_print_to_dot(...) \ - do { \ - int __j = 1 + 2 * snprintf (NULL, 0, __VA_ARGS__); \ - char *__s = XALLOCAVEC (char, __j); \ - snprintf (__s, __j, __VA_ARGS__); \ - sel_prepare_string_for_dot_label (__s); \ - fprintf (sched_dump, "%s", __s); \ - } while (0) - -/* This macro acts like printf but dumps to the sched_dump file. */ -#define sel_print(...) \ - do { \ - if (sched_dump_to_dot_p) \ - sel_print_to_dot (__VA_ARGS__); \ - else \ - fprintf (sched_dump, __VA_ARGS__); \ - } while (0) /* Functions from sel-sched-dump.c. */ +extern void sel_print (const char *fmt, ...) ATTRIBUTE_PRINTF_1; extern const char * sel_print_insn (const_rtx, int); extern void free_sel_dump_data (void); --- gcc/sel-sched-dump.c.jj 2010-06-14 11:08:04.000000000 +0200 +++ gcc/sel-sched-dump.c 2010-06-14 11:14:56.000000000 +0200 @@ -566,7 +566,7 @@ replace_str_in_buf (char *buf, const cha } /* Replace characters in BUF that have special meaning in .dot file. */ -void +static void sel_prepare_string_for_dot_label (char *buf) { static char specials_from[7][2] = { "<", ">", "{", "|", "}", "\"", @@ -579,6 +579,28 @@ sel_prepare_string_for_dot_label (char * replace_str_in_buf (buf, specials_from[i], specials_to[i]); } +/* This function acts like printf but dumps to the sched_dump file. */ +void +sel_print (const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + if (sched_dump_to_dot_p) + { + char *message; + if (vasprintf (&message, fmt, ap) >= 0 && message != NULL) + { + message = (char *) xrealloc (message, 2 * strlen (message) + 1); + sel_prepare_string_for_dot_label (message); + fprintf (sched_dump, "%s", message); + free (message); + } + } + else + vfprintf (sched_dump, fmt, ap); + va_end (ap); +} + /* Dump INSN with FLAGS. */ static void sel_dump_cfg_insn (insn_t insn, int flags)