* gcc.dg/vect/vect-outer-simd-1.c: Remove cleanup-tree-dump directive.
[official-gcc.git] / gcc / alloc-pool.c
blobe9fdc86b01675d6ba026f9cb07e0f481d38304b5
1 /* Functions to support a pool of allocatable objects.
2 Copyright (C) 1987-2015 Free Software Foundation, Inc.
3 Contributed by Daniel Berlin <dan@cgsoftware.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
10 version.
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #include "config.h"
22 #include "system.h"
23 #include "coretypes.h"
24 #include "alloc-pool.h"
25 #include "hash-table.h"
26 #include "hash-map.h"
28 ALLOC_POOL_ID_TYPE last_id;
30 /* Hashtable mapping alloc_pool names to descriptors. */
31 hash_map<const char *, alloc_pool_descriptor> *alloc_pool_hash;
33 struct alloc_pool_descriptor *
34 allocate_pool_descriptor (const char *name)
36 if (!alloc_pool_hash)
37 alloc_pool_hash = new hash_map<const char *, alloc_pool_descriptor> (10,
38 false,
39 false);
41 return &alloc_pool_hash->get_or_insert (name);
44 /* Output per-alloc_pool statistics. */
46 /* Used to accumulate statistics about alloc_pool sizes. */
47 struct pool_output_info
49 unsigned long total_created;
50 unsigned long total_allocated;
53 /* Called via hash_map.traverse. Output alloc_pool descriptor pointed out by
54 SLOT and update statistics. */
55 bool
56 print_alloc_pool_statistics (const char *const &name,
57 const alloc_pool_descriptor &d,
58 struct pool_output_info *i)
60 if (d.allocated)
62 fprintf (stderr,
63 "%-22s %6d %10lu %10lu(%10lu) %10lu(%10lu) %10lu(%10lu)\n",
64 name, d.elt_size, d.created, d.allocated,
65 d.allocated / d.elt_size, d.peak, d.peak / d.elt_size,
66 d.current, d.current / d.elt_size);
67 i->total_allocated += d.allocated;
68 i->total_created += d.created;
70 return 1;
73 /* Output per-alloc_pool memory usage statistics. */
74 void
75 dump_alloc_pool_statistics (void)
77 struct pool_output_info info;
79 if (! GATHER_STATISTICS)
80 return;
82 if (!alloc_pool_hash)
83 return;
85 fprintf (stderr, "\nAlloc-pool Kind Elt size Pools Allocated (elts) Peak (elts) Leak (elts)\n");
86 fprintf (stderr, "--------------------------------------------------------------------------------------------------------------\n");
87 info.total_created = 0;
88 info.total_allocated = 0;
89 alloc_pool_hash->traverse <struct pool_output_info *,
90 print_alloc_pool_statistics> (&info);
91 fprintf (stderr, "--------------------------------------------------------------------------------------------------------------\n");
92 fprintf (stderr, "%-22s %7lu %10lu\n",
93 "Total", info.total_created, info.total_allocated);
94 fprintf (stderr, "--------------------------------------------------------------------------------------------------------------\n");