This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Speed-up get_identifier("main")
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 06 Aug 2003 15:16:19 -0700
- Subject: Re: [PATCH] Speed-up get_identifier("main")
- References: <Pine.LNX.4.44.0308061520110.29762-100000@www.eyesopen.com>
Roger Sayle <roger@eyesopen.com> writes:
> I've started investigating the time it takes to create GCC's builtins
> at start-up. One inefficiency that looks like it could do with tidying
> up are the numerous calls to "get_identifier" with a constant string
> literal argument. stringpool.c provides two APIs for getting an
> identifier, "get_identifier" and "get_identifier_with_length" which is
> slightly more efficient when the length of the string is already known.
> Interestingly, we almost never call get_identifier_with_length, even
> though the majority of calls to get_identifier pass constant strings.
> This results in several thousand needless calls to strlen during GCC's
> initialization.
>
> The following patch introduces a macro form of GET_IDENTIFIER in tree.h
> that mimics the behaviour of get_identifier by calling strlen on its
> argument and then calling get_identifier_with_length. When GCC is built
> with a bootstrap or using GCC as the host compiler, these string lengths
> are evaluated at compile time. However, this idiom is also safe with
> non GCC host compilers.
I like the general idea. I'm wondering if it makes sense to make
get_identifier itself be this macro; the definition of get_identifier
is functionally identical to the macro, and it would avoid having to
change most of the uses of get_identifier. However, it might hurt
code size. Could you experiment, please?
zw