On 2/1/24 15:25, Jakub Jelinek 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?

2024-02-01  Jakub Jelinek  <ja...@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"
+

...

-      (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


Looks good for ILP32/LLP64.

Reply via email to