From: Jakub Jelinek <jakub@redhat.com>
To: Jonathan Yong <10walls@gmail.com>
Cc: 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: Thu, 1 Feb 2024 14:01:17 +0100 [thread overview]
Message-ID: <ZbuWHbFKWq62HtBX@tucnak> (raw)
In-Reply-To: <4700e066-1b50-4e7b-92f7-d8c33a330bbf@gmail.com>
On Thu, Feb 01, 2024 at 12:45:31PM +0000, Jonathan Yong wrote:
> Attached patch OK? Copied inline for review convenience.
No, I think e.g. AIX doesn't support the z modifier.
I don't see %zd or %zu used anywhere except in gcc/jit/ which presumably
doesn't work on AIX.
If you really want to avoid truncation, perhaps do something like
if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
{
if (sizeof (void *) <= sizeof (long))
fprintf (ira_dump_file,
"+++Allocating %lu bytes for conflict table "
"(uncompressed size %lu)\n",
(unsigned long) (sizeof (IRA_INT_TYPE) * allocated_words_num),
(unsigned long) (sizeof (IRA_INT_TYPE) * object_set_words
* ira_objects_num));
else
fprintf (ira_dump_file,
"+++Allocating %l" PRIu64 "bytes for conflict table "
"(uncompressed size %" PRIu64 ")\n",
(unsigned HOST_WIDE_INT) (sizeof (IRA_INT_TYPE)
* allocated_words_num),
(unsigned HOST_WIDE_INT) (sizeof (IRA_INT_TYPE)
* object_set_words
* ira_objects_num));
}
> diff --git a/gcc/ira-conflicts.cc b/gcc/ira-conflicts.cc
> index 671b4e42b6f..e966afe6cdc 100644
> --- a/gcc/ira-conflicts.cc
> +++ b/gcc/ira-conflicts.cc
> @@ -150,9 +150,9 @@ build_conflict_bit_table (void)
> 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));
> + "+++Allocating %zu bytes for conflict table (uncompressed size %zu)\n",
> + (size_t)(allocated_words_num * sizeof (IRA_INT_TYPE)),
> + (size_t)(object_set_words * ira_objects_num * sizeof (IRA_INT_TYPE)));
> objects_live = sparseset_alloc (ira_objects_num);
> for (i = 0; i < ira_max_point; i++)
> From 48861b8578526ac199b123ff71af8f9778c396c3 Mon Sep 17 00:00:00 2001
> From: Jonathan Yong <10walls@gmail.com>
> Date: Thu, 1 Feb 2024 12:35:52 +0000
> Subject: [PATCH] PR target/43613: use %zu for build_conflict_bit_table
>
> LLP64 platforms like uses 32bit for long and may truncate. Use
> size_t and %zu to guarantee 64bit lengths.
>
> gcc:
> *ira-conflicts.cc: use %zu for build_conflict_bit_table.
> ---
> gcc/ira-conflicts.cc | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/gcc/ira-conflicts.cc b/gcc/ira-conflicts.cc
> index 671b4e42b6f..e966afe6cdc 100644
> --- a/gcc/ira-conflicts.cc
> +++ b/gcc/ira-conflicts.cc
> @@ -150,9 +150,9 @@ build_conflict_bit_table (void)
> 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));
> + "+++Allocating %zu bytes for conflict table (uncompressed size %zu)\n",
> + (size_t)(allocated_words_num * sizeof (IRA_INT_TYPE)),
> + (size_t)(object_set_words * ira_objects_num * sizeof (IRA_INT_TYPE)));
>
> objects_live = sparseset_alloc (ira_objects_num);
> for (i = 0; i < ira_max_point; i++)
> --
> 2.43.0
>
Jakub
next prev parent reply other threads:[~2024-02-01 13:01 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 [this message]
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
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=ZbuWHbFKWq62HtBX@tucnak \
--to=jakub@redhat.com \
--cc=10walls@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/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).