This is the mail archive of the gcc-patches@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: [PATCH] Speed-up get_identifier("main")


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


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