From: Martin Liska Date: Fri, 12 Jan 2018 14:47:26 +0000 (+0100) Subject: Fix integer overflow in stats of GIMPLE statements. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=33b366c3d4e96c37b60d440edff64f915cc1aaaf;p=gcc.git Fix integer overflow in stats of GIMPLE statements. 2018-01-12 Martin Liska * 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. From-SVN: r256584 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 730e8edd02b..70fff293740 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2018-01-12 Martin Liska + + * 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. + 2018-01-12 Martin Liska * tree-core.h: Use uint64_t instead of int. 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