+2012-12-13 Steven Bosscher <steven@gcc.gnu.org>
+
+ * bitmap.c (struct bitmap_descriptor): Remove forward declaration.
+ (struct bitmap_head_def): Remove desc pointer. Add descriptor_id
+ field. Reorder fields for pointer alignment.
+ * bitmap.c: Include vec.h.
+ (struct bitmap_descriptor): Rename to bitmap_descriptor_d.
+ (bitmap_descriptor): New typedef, pointer to bitmap_descriptor_d.
+ Update all struct bitmap_descriptor references.
+ (next_bitmap_desc_id): New running index for bitmap desciptors.
+ (bitmap_descriptors): Vec of all bitmap descriptors by descriptor id.
+ (hash_descriptor, eq_descriptor): Update for struct bitmap_descriptor
+ change.
+ (bitmap_descriptor): Rename function to get_bitmap_descriptor.
+ Stuff newly allocated bitmap descriptor into bitmap_descriptors.
+ Set the bitmap descriptor id.
+ (bitmap_register): Lookup bitmap desciptor and store its ID in
+ the passed bitmap.
+ (register_overhead): Likewise.
+ (bitmap_find_bit): Lookup descriptor by id in bitmap_descriptors.
+ (print_statistics): Update for struct bitmap_descriptor change.
+
2012-12-13 Richard Biener <rguenther@suse.de>
* tree-ssa-pre.c (get_representative_for): Adjust dumping.
#include "ggc.h"
#include "bitmap.h"
#include "hashtab.h"
+#include "vec.h"
-/* Store information about each particular bitmap. */
-struct bitmap_descriptor
+/* Store information about each particular bitmap, per allocation site. */
+struct bitmap_descriptor_d
{
+ int id;
const char *function;
const char *file;
int line;
int search_iter;
};
+typedef struct bitmap_descriptor_d *bitmap_descriptor;
+typedef const struct bitmap_descriptor_d *const_bitmap_descriptor;
+
+/* Next available unique id number for bitmap desciptors. */
+static int next_bitmap_desc_id = 0;
+
+/* Vector mapping descriptor ids to descriptors. */
+static vec<bitmap_descriptor> bitmap_descriptors;
+
/* Hashtable mapping bitmap names to descriptors. */
static htab_t bitmap_desc_hash;
static hashval_t
hash_descriptor (const void *p)
{
- const struct bitmap_descriptor *const d =
- (const struct bitmap_descriptor *) p;
+ const_bitmap_descriptor d = (const_bitmap_descriptor) p;
return htab_hash_pointer (d->file) + d->line;
}
struct loc
static int
eq_descriptor (const void *p1, const void *p2)
{
- const struct bitmap_descriptor *const d =
- (const struct bitmap_descriptor *) p1;
+ const_bitmap_descriptor d = (const_bitmap_descriptor) p1;
const struct loc *const l = (const struct loc *) p2;
return d->file == l->file && d->function == l->function && d->line == l->line;
}
/* For given file and line, return descriptor, create new if needed. */
-static struct bitmap_descriptor *
-bitmap_descriptor (const char *file, int line, const char *function)
+static bitmap_descriptor
+get_bitmap_descriptor (const char *file, int line, const char *function)
{
- struct bitmap_descriptor **slot;
+ bitmap_descriptor *slot;
struct loc loc;
loc.file = file;
if (!bitmap_desc_hash)
bitmap_desc_hash = htab_create (10, hash_descriptor, eq_descriptor, NULL);
- slot = (struct bitmap_descriptor **)
+ slot = (bitmap_descriptor *)
htab_find_slot_with_hash (bitmap_desc_hash, &loc,
htab_hash_pointer (file) + line,
INSERT);
if (*slot)
return *slot;
- *slot = XCNEW (struct bitmap_descriptor);
+
+ *slot = XCNEW (struct bitmap_descriptor_d);
+ bitmap_descriptors.safe_push (*slot);
+ (*slot)->id = next_bitmap_desc_id++;
(*slot)->file = file;
(*slot)->function = function;
(*slot)->line = line;
void
bitmap_register (bitmap b MEM_STAT_DECL)
{
- b->desc = bitmap_descriptor (ALONE_FINAL_PASS_MEM_STAT);
- b->desc->created++;
+ bitmap_descriptor desc = get_bitmap_descriptor (ALONE_FINAL_PASS_MEM_STAT);
+ desc->created++;
+ b->descriptor_id = desc->id;
}
/* Account the overhead. */
static void
register_overhead (bitmap b, int amount)
{
- b->desc->current += amount;
+ bitmap_descriptor desc = bitmap_descriptors[b->descriptor_id];
+ desc->current += amount;
if (amount > 0)
- b->desc->allocated += amount;
- gcc_assert (b->desc->current >= 0);
- if (b->desc->peak < b->desc->current)
- b->desc->peak = b->desc->current;
+ desc->allocated += amount;
+ gcc_assert (desc->current >= 0);
+ if (desc->peak < desc->current)
+ desc->peak = desc->current;
}
/* Global data */
return head->current;
if (GATHER_STATISTICS)
- head->desc->nsearches++;
+ bitmap_descriptors[head->descriptor_id]->nsearches++;
if (head->indx < indx)
/* INDX is beyond head->indx. Search from head->current
element = element->next)
{
if (GATHER_STATISTICS)
- head->desc->search_iter++;
+ bitmap_descriptors[head->descriptor_id]->search_iter++;
}
else if (head->indx / 2 < indx)
element = element->prev)
{
if (GATHER_STATISTICS)
- head->desc->search_iter++;
+ bitmap_descriptors[head->descriptor_id]->search_iter++;
}
else
element = element->next)
if (GATHER_STATISTICS)
{
- head->desc->search_iter++;
+ bitmap_descriptors[head->descriptor_id]->search_iter++;
}
/* `element' is the nearest to the one we want. If it's not the one we
static int
print_statistics (void **slot, void *b)
{
- struct bitmap_descriptor *d = (struct bitmap_descriptor *) *slot;
+ bitmap_descriptor d = (bitmap_descriptor) *slot;
struct output_info *i = (struct output_info *) b;
char s[4096];
BITMAP_WORD bits[BITMAP_ELEMENT_WORDS]; /* Bits that are set. */
} bitmap_element;
-struct bitmap_descriptor;
-/* Head of bitmap linked list. gengtype ignores ifdefs, but for
- statistics we need to add a bitmap descriptor pointer. As it is
- not collected, we can just GTY((skip(""))) it. Likewise current
- points to something already pointed to by the chain started by first,
- no need to walk it again. */
+/* Head of bitmap linked list. The 'current' member points to something
+ already pointed to by the chain started by first, so GTY((skip)) it. */
typedef struct GTY(()) bitmap_head_def {
+ unsigned int indx; /* Index of last element looked at. */
+ unsigned int descriptor_id; /* Unique identifier for the allocation
+ site of this bitmap, for detailed
+ statistics gathering. */
bitmap_element *first; /* First element in linked list. */
bitmap_element * GTY((skip(""))) current; /* Last element looked at. */
- unsigned int indx; /* Index of last element looked at. */
bitmap_obstack *obstack; /* Obstack to allocate elements from.
If NULL, then use GGC allocation. */
- struct bitmap_descriptor GTY((skip(""))) *desc;
} bitmap_head;
/* Global data */