This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: cse "library" routines
- To: Richard Henderson <rth at cygnus dot com>
- Subject: Re: Patch: cse "library" routines
- From: Bernd Schmidt <bernds at balti dot cygnus dot co dot uk>
- Date: Sat, 11 Mar 2000 18:37:43 +0000 (GMT)
- cc: gcc-patches at gcc dot gnu dot org
> > + /* A table that enables us to look up elts by their value. */
> > + #define NBUCKETS 32
> > + #define VALUE_HASH(V) ((V) % NBUCKETS)
> > +
> > + static cselib_val *table[NBUCKETS];
>
> Why your own hash table implementation rather than one of the
> couple of dictionary-type widgets we already have in libiberty?
I think the main reason is that I duplicated some parts from cse.c. I've
had a brief look at hashtab.c now. I could probably use it but some parts
might get more complicated; e.g. the code needs to compute the hash value
before inserting a new element into the table (to avoid entering particular
expressions which can't be hashed), so we'd compute the hash value twice.
IMO not using hashtab.c avoids some complications, but I won't object if you
want this changed.
>
> > + static struct elt_list *
> > + new_elt_list (next, elt)
> [...]
> > + el = (struct elt_list *) xmalloc (sizeof (struct elt_list));
> [...]
> > + new_elt_loc_list (next, loc)
> [...]
> > + el = (struct elt_loc_list *) xmalloc (sizeof (struct elt_loc_list));
>
> I don't see a free to go along with these mallocs. Perhaps
> you meant to do it in clear_table?
Indeed, that seems to be missing. I'll send an update tomorrow. Do you
think the hash table should use the implementation from libiberty?
Thanks for looking at this,
Bernd