diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-12-23 14:30:36 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-12-23 14:30:36 +0000 |
commit | 51949610692cda038b73f2605ca30369c80e11e7 (patch) | |
tree | 7448acc1c5f3340010e52d07355ec0e394271f55 /gcc/ggc-common.c | |
parent | 08dd25f69b1c4ec117d01822c86f6eeb57793991 (diff) | |
download | gcc-51949610692cda038b73f2605ca30369c80e11e7.tar.gz |
* toplev.c (dump_memory_report): Break out from...
(finalize): Here.
* toplev.h (dump_memory_report): Declare.
(cmp_statistic): Rename to ...
(final_cmp_statistic): ... this one
(cmp_statistic): New.
(dump_ggc_loc_staitsitcs): New FINAL parpameter.
* common.opt (-fpre-ipa-mem-report, -fpost-ipa-mem-report): Declare.
* varray.c (dump_varray_staitiscs): Do not segfault when no varray was
allocated so far.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120168 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ggc-common.c')
-rw-r--r-- | gcc/ggc-common.c | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c index 3cafc770efd..7341e968edc 100644 --- a/gcc/ggc-common.c +++ b/gcc/ggc-common.c @@ -919,12 +919,31 @@ ggc_free_overhead (void *ptr) /* Helper for qsort; sort descriptors by amount of memory consumed. */ static int -cmp_statistic (const void *loc1, const void *loc2) +final_cmp_statistic (const void *loc1, const void *loc2) { struct loc_descriptor *l1 = *(struct loc_descriptor **) loc1; struct loc_descriptor *l2 = *(struct loc_descriptor **) loc2; - return ((l1->allocated + l1->overhead - l1->freed) - + long diff; + diff = ((long)(l1->allocated + l1->overhead - l1->freed) - (l2->allocated + l2->overhead - l2->freed)); + return diff > 0 ? 1 : diff < 0 ? -1 : 0; +} + +/* Helper for qsort; sort descriptors by amount of memory consumed. */ +static int +cmp_statistic (const void *loc1, const void *loc2) +{ + struct loc_descriptor *l1 = *(struct loc_descriptor **) loc1; + struct loc_descriptor *l2 = *(struct loc_descriptor **) loc2; + long diff; + + diff = ((long)(l1->allocated + l1->overhead - l1->freed - l1->collected) - + (l2->allocated + l2->overhead - l2->freed - l2->collected)); + if (diff) + return diff > 0 ? 1 : diff < 0 ? -1 : 0; + diff = ((long)(l1->allocated + l1->overhead - l1->freed) - + (l2->allocated + l2->overhead - l2->freed)); + return diff > 0 ? 1 : diff < 0 ? -1 : 0; } /* Collect array of the descriptors from hashtable. */ @@ -941,7 +960,7 @@ add_statistics (void **slot, void *b) /* Dump per-site memory statistics. */ #endif void -dump_ggc_loc_statistics (void) +dump_ggc_loc_statistics (bool final ATTRIBUTE_UNUSED) { #ifdef GATHER_STATISTICS int nentries = 0; @@ -958,7 +977,8 @@ dump_ggc_loc_statistics (void) "source location", "Garbage", "Freed", "Leak", "Overhead", "Times"); fprintf (stderr, "-------------------------------------------------------\n"); htab_traverse (loc_hash, add_statistics, &nentries); - qsort (loc_array, nentries, sizeof (*loc_array), cmp_statistic); + qsort (loc_array, nentries, sizeof (*loc_array), + final ? final_cmp_statistic : cmp_statistic); for (i = 0; i < nentries; i++) { struct loc_descriptor *d = loc_array[i]; |