This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFD - cleaning up C identifier lookup


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>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]