bitmap.c (struct bitmap_descriptor): Remove forward declaration.
* 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. From-SVN: r194469
This commit is contained in:
parent
a044f0e791
commit
3c53f55a97
3 changed files with 65 additions and 31 deletions
|
@ -1,3 +1,25 @@
|
|||
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.
|
||||
|
|
60
gcc/bitmap.c
60
gcc/bitmap.c
|
@ -24,10 +24,12 @@ along with GCC; see the file COPYING3. If not see
|
|||
#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;
|
||||
|
@ -39,6 +41,15 @@ struct bitmap_descriptor
|
|||
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;
|
||||
|
||||
|
@ -46,8 +57,7 @@ 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
|
||||
|
@ -59,17 +69,16 @@ 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;
|
||||
|
@ -79,13 +88,16 @@ bitmap_descriptor (const char *file, int line, const char *function)
|
|||
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;
|
||||
|
@ -96,20 +108,22 @@ bitmap_descriptor (const char *file, int line, const char *function)
|
|||
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 */
|
||||
|
@ -556,7 +570,7 @@ bitmap_find_bit (bitmap head, unsigned int bit)
|
|||
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
|
||||
|
@ -566,7 +580,7 @@ bitmap_find_bit (bitmap head, unsigned int bit)
|
|||
element = element->next)
|
||||
{
|
||||
if (GATHER_STATISTICS)
|
||||
head->desc->search_iter++;
|
||||
bitmap_descriptors[head->descriptor_id]->search_iter++;
|
||||
}
|
||||
|
||||
else if (head->indx / 2 < indx)
|
||||
|
@ -577,7 +591,7 @@ bitmap_find_bit (bitmap head, unsigned int bit)
|
|||
element = element->prev)
|
||||
{
|
||||
if (GATHER_STATISTICS)
|
||||
head->desc->search_iter++;
|
||||
bitmap_descriptors[head->descriptor_id]->search_iter++;
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -588,7 +602,7 @@ bitmap_find_bit (bitmap head, unsigned int bit)
|
|||
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
|
||||
|
@ -2127,7 +2141,7 @@ struct output_info
|
|||
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];
|
||||
|
||||
|
|
14
gcc/bitmap.h
14
gcc/bitmap.h
|
@ -174,20 +174,18 @@ typedef struct GTY((chain_next ("%h.next"), chain_prev ("%h.prev"))) bitmap_elem
|
|||
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 */
|
||||
|
|
Loading…
Add table
Reference in a new issue