public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Jonathan Yong <10walls@gmail.com>, Xi Ruoyao <xry111@xry111.site>,
	 Gcc Patch List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Change gcc/ira-conflicts.cc build_conflict_bit_table to use size_t/%zu
Date: Fri, 9 Feb 2024 11:33:47 +0100	[thread overview]
Message-ID: <CAFiYyc0HGcbYA3qHGSzxwR53ja6SLqi9vU+KfhH55LuoPbBf-w@mail.gmail.com> (raw)
In-Reply-To: <Zbu34FTR73081bMb@tucnak>

On Thu, Feb 1, 2024 at 4:26 PM Jakub Jelinek <jakub@redhat.com> wrote:
>
> On Thu, Feb 01, 2024 at 03:55:51PM +0100, Jakub Jelinek wrote:
> > No, besides the formatting being incorrect both in ChangeLog and in the
> > patch, this pessimizes ILP32 hosts unnecessarily.
>
> So like this instead?

OK.

Thanks,
Richard.

> 2024-02-01  Jakub Jelinek  <jakub@redhat.com>
>
>         * hwint.h (GCC_PRISZ, fmt_size_t, HOST_SIZE_T_PRINT_DEC,
>         HOST_SIZE_T_PRINT_UNSIGNED, HOST_SIZE_T_PRINT_HEX,
>         HOST_SIZE_T_PRINT_HEX_PURE): Define.
>         * ira-conflicts.cc (build_conflict_bit_table): Use it.  Formatting
>         fixes.
>
> --- gcc/hwint.h.jj      2024-01-03 11:51:32.676715299 +0100
> +++ gcc/hwint.h 2024-02-01 16:22:53.037013522 +0100
> @@ -115,6 +115,27 @@ typedef HOST_WIDE_INT __gcc_host_wide_in
>  #define HOST_WIDE_INT_PRINT_DOUBLE_HEX "0x%" PRIx64 "%016" PRIx64
>  #define HOST_WIDE_INT_PRINT_PADDED_HEX "%016" PRIx64
>
> +/* Similarly format modifier for printing size_t.  As not all hosts support
> +   z modifier in printf, use GCC_PRISZ and cast argument to fmt_size_t.
> +   So, instead of doing fprintf ("%zu\n", sizeof (x) * y); use
> +   fprintf (HOST_SIZE_T_PRINT_UNSIGNED "\n",
> +           (fmt_size_t) (sizeof (x) * y));  */
> +#if SIZE_MAX <= INT_MAX
> +# define GCC_PRISZ ""
> +# define fmt_size_t unsigned int
> +#elif SIZE_MAX <= LONG_MAX
> +# define GCC_PRISZ HOST_LONG_FORMAT
> +# define fmt_size_t unsigned long int
> +#else
> +# define GCC_PRISZ HOST_LONG_LONG_FORMAT
> +# define fmt_size_t unsigned long long int
> +#endif
> +
> +#define HOST_SIZE_T_PRINT_DEC "%" GCC_PRISZ "d"
> +#define HOST_SIZE_T_PRINT_UNSIGNED "%" GCC_PRISZ "u"
> +#define HOST_SIZE_T_PRINT_HEX "%#" GCC_PRISZ "x"
> +#define HOST_SIZE_T_PRINT_HEX_PURE "%" GCC_PRISZ "x"
> +
>  /* Define HOST_WIDEST_FAST_INT to the widest integer type supported
>     efficiently in hardware.  (That is, the widest integer type that fits
>     in a hardware register.)  Normally this is "long" but on some hosts it
> --- gcc/ira-conflicts.cc.jj     2024-01-03 11:51:31.748728178 +0100
> +++ gcc/ira-conflicts.cc        2024-02-01 16:12:02.156137005 +0100
> @@ -115,10 +115,10 @@ build_conflict_bit_table (void)
>             > (uint64_t) param_ira_max_conflict_table_size * 1024 * 1024)
>           {
>             if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
> -             fprintf
> -               (ira_dump_file,
> -                "+++Conflict table will be too big(>%dMB) -- don't use it\n",
> -                param_ira_max_conflict_table_size);
> +             fprintf (ira_dump_file,
> +                      "+++Conflict table will be too big(>%dMB) "
> +                      "-- don't use it\n",
> +                      param_ira_max_conflict_table_size);
>             return false;
>           }
>        }
> @@ -148,11 +148,13 @@ build_conflict_bit_table (void)
>
>    object_set_words = (ira_objects_num + IRA_INT_BITS - 1) / IRA_INT_BITS;
>    if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
> -    fprintf
> -      (ira_dump_file,
> -       "+++Allocating %ld bytes for conflict table (uncompressed size %ld)\n",
> -       (long) allocated_words_num * sizeof (IRA_INT_TYPE),
> -       (long) object_set_words * ira_objects_num * sizeof (IRA_INT_TYPE));
> +    fprintf (ira_dump_file,
> +            "+++Allocating " HOST_SIZE_T_PRINT_UNSIGNED
> +            " bytes for conflict table (uncompressed size "
> +            HOST_SIZE_T_PRINT_UNSIGNED ")\n",
> +            (fmt_size_t) (sizeof (IRA_INT_TYPE) * allocated_words_num),
> +            (fmt_size_t) (sizeof (IRA_INT_TYPE) * object_set_words
> +                          * ira_objects_num));
>
>    objects_live = sparseset_alloc (ira_objects_num);
>    for (i = 0; i < ira_max_point; i++)
>
>
>         Jakub
>

  parent reply	other threads:[~2024-02-09 10:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-01 12:45 Jonathan Yong
2024-02-01 13:01 ` Jakub Jelinek
2024-02-01 13:06   ` Xi Ruoyao
2024-02-01 13:42     ` Jonathan Yong
2024-02-01 13:55       ` Jakub Jelinek
2024-02-01 14:33         ` Xi Ruoyao
2024-02-01 14:53           ` Jonathan Yong
2024-02-01 14:55             ` Jakub Jelinek
2024-02-01 15:25               ` Jakub Jelinek
2024-02-01 15:33                 ` Jonathan Yong
2024-02-02 23:43                   ` Jonathan Yong
2024-02-03  0:03                     ` Jakub Jelinek
2024-02-09 10:33                 ` Richard Biener [this message]
2024-02-01 13:13   ` Jakub Jelinek
2024-02-01 14:53     ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFiYyc0HGcbYA3qHGSzxwR53ja6SLqi9vU+KfhH55LuoPbBf-w@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=10walls@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=xry111@xry111.site \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).