[3/3] Fix integer overflow in stats of GIMPLE statements.

Message ID 0aca5e4c4a4a463b13c0a0916689e1a4d924bb12.1515744628.git.mliska@suse.cz
State New
Headers show
Series
  • Fix broken --enable-gather-detailed-mem-stats build.
Related show

Commit Message

Martin Liška Jan. 12, 2018, 8:04 a.m.
gcc/ChangeLog:

2018-01-12  Martin Liska  <mliska@suse.cz>

	* gimple.c (gimple_alloc_counts): Use uint64_t instead of int.
	(gimple_alloc_sizes): Likewise.
	(dump_gimple_statistics): Use PRIu64 in printf format.
	* gimple.h: Change uint64_t to int.
---
 gcc/gimple.c | 17 ++++++++++-------
 gcc/gimple.h |  4 ++--
 2 files changed, 12 insertions(+), 9 deletions(-)

Patch

diff --git a/gcc/gimple.c b/gcc/gimple.c
index e24b9fd611d..c1b7229a6b7 100644
--- a/gcc/gimple.c
+++ b/gcc/gimple.c
@@ -77,8 +77,8 @@  EXPORTED_CONST enum gimple_statement_structure_enum gss_for_code_[] = {
 
 /* Gimple stats.  */
 
-int gimple_alloc_counts[(int) gimple_alloc_kind_all];
-int gimple_alloc_sizes[(int) gimple_alloc_kind_all];
+uint64_t gimple_alloc_counts[(int) gimple_alloc_kind_all];
+uint64_t gimple_alloc_sizes[(int) gimple_alloc_kind_all];
 
 /* Keep in sync with gimple.h:enum gimple_alloc_kind.  */
 static const char * const gimple_alloc_kind_names[] = {
@@ -2057,11 +2057,12 @@  gimple_assign_rhs_could_trap_p (gimple *s)
 void
 dump_gimple_statistics (void)
 {
-  int i, total_tuples = 0, total_bytes = 0;
+  int i;
+  uint64_t total_tuples = 0, total_bytes = 0;
 
   if (! GATHER_STATISTICS)
     {
-      fprintf (stderr, "No gimple statistics\n");
+      fprintf (stderr, "No GIMPLE statistics\n");
       return;
     }
 
@@ -2070,13 +2071,15 @@  dump_gimple_statistics (void)
   fprintf (stderr, "---------------------------------------\n");
   for (i = 0; i < (int) gimple_alloc_kind_all; ++i)
     {
-      fprintf (stderr, "%-20s %7d %10d\n", gimple_alloc_kind_names[i],
-	  gimple_alloc_counts[i], gimple_alloc_sizes[i]);
+      fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n",
+	       gimple_alloc_kind_names[i], gimple_alloc_counts[i],
+	       gimple_alloc_sizes[i]);
       total_tuples += gimple_alloc_counts[i];
       total_bytes += gimple_alloc_sizes[i];
     }
   fprintf (stderr, "---------------------------------------\n");
-  fprintf (stderr, "%-20s %7d %10d\n", "Total", total_tuples, total_bytes);
+  fprintf (stderr, "%-20s %7" PRIu64 " %10" PRIu64 "\n", "Total",
+	   total_tuples, total_bytes);
   fprintf (stderr, "---------------------------------------\n");
 }
 
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 8c0e9aefe54..281015ad3e2 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -6386,8 +6386,8 @@  enum gimple_alloc_kind
   gimple_alloc_kind_all
 };
 
-extern int gimple_alloc_counts[];
-extern int gimple_alloc_sizes[];
+extern uint64_t gimple_alloc_counts[];
+extern uint64_t gimple_alloc_sizes[];
 
 /* Return the allocation kind for a given stmt CODE.  */
 static inline enum gimple_alloc_kind