This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: RFD - cleaning up C identifier lookup
- From: Geoff Keating <geoffk at geoffk dot org>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 17 Mar 2003 13:51:52 -0800
- Subject: Re: RFD - cleaning up C identifier lookup
- References: <87r895k79i.fsf@egil.codesourcery.com>
Zack Weinberg <zack at codesourcery dot com> writes:
> My suspicion is that block scope external declarations, implicit or
> explicit, are simply not used in modern C.
I believe this is a reasonable statement, in context. It's not true
that they're *never* used, but it is true that they're very uncommon.
> Thus, we can save two more
> pointers per identifier by removing both fields and maintaining a
> global list of such declarations instead; under normal circumstances
> this list will be empty.
I'm not quite sure how this would work. Would the list only be
searched when a declaration is seen that is known to be block scope
external? Or would it need to be searched on *every* decl lookup?
The first is almost certainly a win, the second maybe not.
> Second, the distinction between global_value and local_value is
> artificial. I propose to remove it and use the existing mechanism for
> block-scope shadows to handle shadowing of globals.
I think this also makes sense, especially if it doesn't add overhead
unless an identifier is seen that is actually shadowed (which is also
quite rare).
> That would free
> up another slot, but instead of removing it altogether I plan to
> recycle it for the type-tag namespace:
>
> struct lang_identifier GTY(())
> {
> struct c_common_identifier common_id;
> tree symbol_value;
> tree tag_value;
> tree label_value;
> }
>
> That allows elimination of the disgusting linear-or-worse search
> algorithm used by lookup_tag, and I hope it will allow removal of
> lookup_tag_reverse entirely.
Yes, please!
--
- Geoffrey Keating <geoffk at geoffk dot org>