gcov-dump.c (tag_summary): Remove max_sum

* gcov-dump.c (tag_summary): Remove max_sum
	* gcov-io.h (gcov_summary, gcov_write_summary, gcov_read_summary): Kill
	max_sum.
	* libgcov.c (gcov_exit): Do one pass over the data.  Make error message
	more verbose.

From-SVN: r65758
This commit is contained in:
Jan Hubicka 2003-04-18 01:33:05 +02:00 committed by Jan Hubicka
parent 04c5580f37
commit d101590bee
4 changed files with 78 additions and 73 deletions

View File

@ -1,5 +1,11 @@
Fri Apr 18 01:28:51 CEST 2003 Jan Hubicka <jh@suse.cz> Fri Apr 18 01:28:51 CEST 2003 Jan Hubicka <jh@suse.cz>
* gcov-dump.c (tag_summary): Remove max_sum
* gcov-io.h (gcov_summary, gcov_write_summary, gcov_read_summary): Kill
max_sum.
* libgcov.c (gcov_exit): Do one pass over the data. Make error message
more verbose.
* emit-rtl.c (subreg_hard_regno): Check that register is representable. * emit-rtl.c (subreg_hard_regno): Check that register is representable.
* reload.c (reload_inner_reg_of_subreg): When register is not * reload.c (reload_inner_reg_of_subreg): When register is not
representable, reload the whole thing. representable, reload the whole thing.

View File

@ -407,9 +407,6 @@ tag_summary (filename, tag, length)
printf (", arc_max_one="); printf (", arc_max_one=");
printf (HOST_WIDEST_INT_PRINT_DEC, printf (HOST_WIDEST_INT_PRINT_DEC,
(HOST_WIDEST_INT)summary.arc_max_one); (HOST_WIDEST_INT)summary.arc_max_one);
printf ("\n%s:\t\tmax_sum=", filename);
printf (HOST_WIDEST_INT_PRINT_DEC,
(HOST_WIDEST_INT)summary.arc_max_sum);
printf (", sum_max="); printf (", sum_max=");
printf (HOST_WIDEST_INT_PRINT_DEC, printf (HOST_WIDEST_INT_PRINT_DEC,
(HOST_WIDEST_INT)summary.arc_sum_max); (HOST_WIDEST_INT)summary.arc_sum_max);

View File

@ -120,7 +120,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
announce_function: header string:name int32:checksum announce_function: header string:name int32:checksum
arc_counts: header int64:count* arc_counts: header int64:count*
summary: in32:checksum int32:runs int32:arcs int64:sum int64:max \ summary: in32:checksum int32:runs int32:arcs int64:sum int64:max \
int64:max_sum int64:sum_max int64:sum_max
The ANNOUNCE_FUNCTION record is the same as that in the BBG file, The ANNOUNCE_FUNCTION record is the same as that in the BBG file,
but without the source location. but without the source location.
@ -220,7 +220,6 @@ struct gcov_summary
unsigned arcs; /* number of instrumented arcs */ unsigned arcs; /* number of instrumented arcs */
gcov_type arc_sum; /* sum of all arc counters */ gcov_type arc_sum; /* sum of all arc counters */
gcov_type arc_max_one; /* max counter on any one run */ gcov_type arc_max_one; /* max counter on any one run */
gcov_type arc_max_sum; /* maximum arc_sum */
gcov_type arc_sum_max; /* sum of max_one */ gcov_type arc_sum_max; /* sum of max_one */
}; };
@ -618,7 +617,6 @@ gcov_write_summary (unsigned tag, const struct gcov_summary *summary)
gcov_write_unsigned (summary->arcs); gcov_write_unsigned (summary->arcs);
gcov_write_counter (summary->arc_sum); gcov_write_counter (summary->arc_sum);
gcov_write_counter (summary->arc_max_one); gcov_write_counter (summary->arc_max_one);
gcov_write_counter (summary->arc_max_sum);
gcov_write_counter (summary->arc_sum_max); gcov_write_counter (summary->arc_sum_max);
gcov_write_length (base); gcov_write_length (base);
} }
@ -718,7 +716,6 @@ gcov_read_summary (struct gcov_summary *summary)
summary->arcs = gcov_read_unsigned (); summary->arcs = gcov_read_unsigned ();
summary->arc_sum = gcov_read_counter (); summary->arc_sum = gcov_read_counter ();
summary->arc_max_one = gcov_read_counter (); summary->arc_max_one = gcov_read_counter ();
summary->arc_max_sum = gcov_read_counter ();
summary->arc_sum_max = gcov_read_counter (); summary->arc_sum_max = gcov_read_counter ();
} }

View File

@ -97,15 +97,38 @@ gcov_exit (void)
{ {
struct gcov_info *ptr; struct gcov_info *ptr;
unsigned ix, jx; unsigned ix, jx;
struct gcov_summary program;
gcov_type program_max_one = 0; gcov_type program_max_one = 0;
gcov_type program_max_sum = 0;
gcov_type program_sum = 0; gcov_type program_sum = 0;
unsigned program_arcs = 0; unsigned program_arcs = 0;
struct gcov_summary last_prg;
memset (&program, 0, sizeof (program)); last_prg.runs = 0;
program.checksum = gcov_crc32;
for (ptr = gcov_list; ptr; ptr = ptr->next)
{
unsigned arc_data_index;
gcov_type *count_ptr;
if (!ptr->filename)
continue;
for (arc_data_index = 0;
arc_data_index < ptr->n_counter_sections
&& ptr->counter_sections[arc_data_index].tag != GCOV_TAG_ARC_COUNTS;
arc_data_index++)
continue;
for (ix = ptr->counter_sections[arc_data_index].n_counters,
count_ptr = ptr->counter_sections[arc_data_index].counters; ix--;)
{
gcov_type count = *count_ptr++;
if (count > program_max_one)
program_max_one = count;
program_sum += count;
}
program_arcs += ptr->counter_sections[arc_data_index].n_counters;
}
for (ptr = gcov_list; ptr; ptr = ptr->next) for (ptr = gcov_list; ptr; ptr = ptr->next)
{ {
struct gcov_summary object; struct gcov_summary object;
@ -119,8 +142,8 @@ gcov_exit (void)
gcov_type object_max_one = 0; gcov_type object_max_one = 0;
unsigned tag, length; unsigned tag, length;
unsigned arc_data_index, f_sect_index, sect_index; unsigned arc_data_index, f_sect_index, sect_index;
long summary_pos = 0;
ptr->wkspc = 0;
if (!ptr->filename) if (!ptr->filename)
continue; continue;
@ -148,8 +171,6 @@ gcov_exit (void)
if (count > object_max_one) if (count > object_max_one)
object_max_one = count; object_max_one = count;
} }
if (object_max_one > program_max_one)
program_max_one = object_max_one;
memset (&local_prg, 0, sizeof (local_prg)); memset (&local_prg, 0, sizeof (local_prg));
memset (&object, 0, sizeof (object)); memset (&object, 0, sizeof (object));
@ -248,9 +269,7 @@ gcov_exit (void)
tag = gcov_read_unsigned (); tag = gcov_read_unsigned ();
gcov_read_unsigned (); gcov_read_unsigned ();
if (tag != GCOV_TAG_PROGRAM_SUMMARY if (tag != GCOV_TAG_PROGRAM_SUMMARY)
&& tag != GCOV_TAG_PLACEHOLDER_SUMMARY
&& tag != GCOV_TAG_INCORRECT_SUMMARY)
goto read_mismatch; goto read_mismatch;
gcov_read_summary (&local_prg); gcov_read_summary (&local_prg);
if ((error = gcov_is_error ())) if ((error = gcov_is_error ()))
@ -263,29 +282,38 @@ gcov_exit (void)
goto read_fatal; goto read_fatal;
} }
if (local_prg.checksum != program.checksum) if (local_prg.checksum != gcov_crc32)
continue;
if (tag == GCOV_TAG_PLACEHOLDER_SUMMARY)
{ {
fprintf (stderr, memset (&local_prg, 0, sizeof (local_prg));
"profiling:%s:Concurrent race detected\n", continue;
ptr->filename);
goto read_fatal;
} }
merging = 0; merging = 0;
if (tag != GCOV_TAG_PROGRAM_SUMMARY) if (tag != GCOV_TAG_PROGRAM_SUMMARY)
break; break;
if (program.runs /* If everything done correctly, the summaries should be
&& memcmp (&program, &local_prg, sizeof (program))) computed equal for each module. */
if (last_prg.runs
#ifdef TARGET_HAS_F_SETLKW
&& last_prg.runs == local_prg.runs
#endif
&& memcmp (&last_prg, &local_prg, sizeof (last_prg)))
{ {
fprintf (stderr, "profiling:%s:Invocation mismatch\n", #ifdef TARGET_HAS_F_SETLKW
fprintf (stderr, "profiling:%s:Invocation mismatch\n\
Probably some files were removed\n",
ptr->filename); ptr->filename);
#else
fprintf (stderr, "profiling:%s:Invocation mismatch\n\
Probably some files were removed or parallel race happent because libgcc\n\
is compiled without file locking support.\n",
ptr->filename);
#endif
local_prg.runs = 0; local_prg.runs = 0;
} }
else else
memcpy (&program, &local_prg, sizeof (program)); memcpy (&last_prg, &local_prg, sizeof (last_prg));
ptr->wkspc = base; summary_pos = base;
break; break;
} }
gcov_seek (0, 0); gcov_seek (0, 0);
@ -335,8 +363,6 @@ gcov_exit (void)
if (tag == GCOV_TAG_ARC_COUNTS) if (tag == GCOV_TAG_ARC_COUNTS)
{ {
object.arc_sum += count; object.arc_sum += count;
if (object.arc_max_sum < count)
object.arc_max_sum = count;
} }
gcov_write_counter (count); gcov_write_counter (count);
} }
@ -347,61 +373,40 @@ gcov_exit (void)
/* Object file summary. */ /* Object file summary. */
gcov_write_summary (GCOV_TAG_OBJECT_SUMMARY, &object); gcov_write_summary (GCOV_TAG_OBJECT_SUMMARY, &object);
/* Generate whole program statistics. */
local_prg.runs++;
local_prg.checksum = gcov_crc32;
local_prg.arcs = program_arcs;
local_prg.arc_sum += program_sum;
if (local_prg.arc_max_one < program_max_one)
local_prg.arc_max_one = program_max_one;
local_prg.arc_sum_max += program_max_one;
if (merging) if (merging)
{ {
ptr->wkspc = gcov_seek_end (); gcov_seek_end ();
gcov_write_summary (GCOV_TAG_PLACEHOLDER_SUMMARY, &program); gcov_write_summary (GCOV_TAG_PROGRAM_SUMMARY, &local_prg);
} }
else if (ptr->wkspc) else if (summary_pos)
{ {
/* Zap trailing program summary */ /* Zap trailing program summary */
gcov_seek (ptr->wkspc, 0); gcov_seek (summary_pos, 0);
if (!local_prg.runs) if (!local_prg.runs)
ptr->wkspc = 0; ptr->wkspc = 0;
gcov_write_unsigned (local_prg.runs gcov_write_summary (GCOV_TAG_PROGRAM_SUMMARY, &local_prg);
? GCOV_TAG_PLACEHOLDER_SUMMARY
: GCOV_TAG_INCORRECT_SUMMARY);
} }
if (gcov_close ()) if (gcov_close ())
{ {
fprintf (stderr, "profiling:%s:Error writing\n", ptr->filename); fprintf (stderr, "profiling:%s:Error writing\n", ptr->filename);
ptr->filename = 0; ptr->filename = 0;
} }
else
{
program_arcs += ptr->counter_sections[arc_data_index].n_counters;
program_sum += object.arc_sum;
if (program_max_sum < object.arc_max_sum)
program_max_sum = object.arc_max_sum;
}
free(counters);
} }
/* All statistic we gather can be done in one pass trought the file.
/* Generate whole program statistics. */ Originally we did two - one for counts and other for the statistics. This
program.runs++; brings problem with the file locking interface, but it is possible to
program.arcs = program_arcs; implement so if need appears in the future - first pass updates local
program.arc_sum = program_sum; statistics and number of runs. Second pass then overwrite global
if (program.arc_max_one < program_max_one) statistics only when number of runs match. */
program.arc_max_one = program_max_one;
if (program.arc_max_sum < program_max_sum)
program.arc_max_sum = program_max_sum;
program.arc_sum_max += program_max_one;
/* Upate whole program statistics. */
for (ptr = gcov_list; ptr; ptr = ptr->next)
if (ptr->filename && ptr->wkspc)
{
if (!gcov_open (ptr->filename, 1))
{
fprintf (stderr, "profiling:%s:Cannot open\n", ptr->filename);
continue;
}
gcov_seek (ptr->wkspc, 0);
gcov_write_summary (GCOV_TAG_PROGRAM_SUMMARY, &program);
if (gcov_close ())
fprintf (stderr, "profiling:%s:Error writing\n", ptr->filename);
}
} }
/* Add a new object file onto the bb chain. Invoked automatically /* Add a new object file onto the bb chain. Invoked automatically