Message ID | 20130822150318.GB11005@kam.mff.cuni.cz |
---|---|
State | New |
Headers | show |
On 22/08/13 16:03, Jan Hubicka wrote: > Hi, > this patch fixes overflow happening in -ftime-report when printing memory usage > of bigger WPA compilations. > > Honza > > * timevar.c (validate_phases): Use size_t for memory. > * timevar.h (struct timevar_time_def): Use size_t for ggc_mem. > Index: timevar.c > =================================================================== > --- timevar.c (revision 201919) > +++ timevar.c (working copy) > @@ -430,7 +430,7 @@ validate_phases (FILE *fp) > double phase_user = 0.0; > double phase_sys = 0.0; > double phase_wall = 0.0; > - unsigned phase_ggc_mem = 0; > + size_t phase_ggc_mem = 0; > static char phase_prefix[] = "phase "; > const double tolerance = 1.000001; /* One part in a million. */ > > @@ -465,7 +465,7 @@ validate_phases (FILE *fp) > if (phase_wall > total->wall) > fprintf (fp, "wall %24.18e > %24.18e\n", phase_wall, total->wall); > if (phase_ggc_mem > total->ggc_mem) > - fprintf (fp, "ggc_mem %24u > %24u\n", phase_ggc_mem, total->ggc_mem); > + fprintf (fp, "ggc_mem %24lu > %24lu\n", phase_ggc_mem, total->ggc_mem); > gcc_unreachable (); > Won't that cause compilation errors on platforms where size_t is not unsigned long? R.
> > if (phase_wall > total->wall) > > fprintf (fp, "wall %24.18e > %24.18e\n", phase_wall, total->wall); > > if (phase_ggc_mem > total->ggc_mem) > > - fprintf (fp, "ggc_mem %24u > %24u\n", phase_ggc_mem, total->ggc_mem); > > + fprintf (fp, "ggc_mem %24lu > %24lu\n", phase_ggc_mem, total->ggc_mem); > > gcc_unreachable (); > > > > Won't that cause compilation errors on platforms where size_t is not > unsigned long? You are probably right. I will add the cast shortly. Thanks, Honza > > R.
Index: timevar.c =================================================================== --- timevar.c (revision 201919) +++ timevar.c (working copy) @@ -430,7 +430,7 @@ validate_phases (FILE *fp) double phase_user = 0.0; double phase_sys = 0.0; double phase_wall = 0.0; - unsigned phase_ggc_mem = 0; + size_t phase_ggc_mem = 0; static char phase_prefix[] = "phase "; const double tolerance = 1.000001; /* One part in a million. */ @@ -465,7 +465,7 @@ validate_phases (FILE *fp) if (phase_wall > total->wall) fprintf (fp, "wall %24.18e > %24.18e\n", phase_wall, total->wall); if (phase_ggc_mem > total->ggc_mem) - fprintf (fp, "ggc_mem %24u > %24u\n", phase_ggc_mem, total->ggc_mem); + fprintf (fp, "ggc_mem %24lu > %24lu\n", phase_ggc_mem, total->ggc_mem); gcc_unreachable (); } } Index: timevar.h =================================================================== --- timevar.h (revision 201919) +++ timevar.h (working copy) @@ -62,7 +62,7 @@ struct timevar_time_def double wall; /* Garbage collector memory. */ - unsigned ggc_mem; + size_t ggc_mem; }; /* An enumeration of timing variable identifiers. Constructed from