This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] simple speedup for Darwin's stubs/non-lazy symbol finding
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 25 Jun 2004 03:18:11 -0400 (EDT)
- Subject: [PATCH] simple speedup for Darwin's stubs/non-lazy symbol finding
When I was looking into how I could get PR8361 faster on Mac OS X,
I noticed the top functions were caused by the darwin back-end.
This patch fixes some of the issue dealing with the back-end but
looking into the length of the strings before calling strcmp.
This is faster as we already know the length for the IDENTIFER_NODE,
IDENTIFIER_LENGTH.
Orginal speed on a dual 2.5GHz G5: 18 seconds
After change to machopic_stub_name: 16.650 seconds
After change to machopic_non_lazy_ptr_name: 16.1 seconds.
I have another change to remove machopic_indirect_call_target
but I have not fixed the i386-darwin back-end yet to do the
output right.
With the removal of machopic_indirect_call_target: 14.3 seconds.
(but note this was not a total removal, just of all code in the function).
All measurements were done with CFLAGS="-O2 -g" with the mainline compiler
as the building the compiler.
OK? Bootstrapped on powerpc-apple-darwin with no regressions.
Thanks,
Andrew Pinski
ChangeLog:
* config/darwin.c (machopic_non_lazy_ptr_name): Check the length of the
the IDENTIFIER before calling strcmp.
(machopic_stub_name): Likewise.
Index: darwin.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.c,v
retrieving revision 1.69
diff -u -p -r1.69 darwin.c
--- darwin.c 3 Jun 2004 22:15:08 -0000 1.69
+++ darwin.c 25 Jun 2004 07:07:32 -0000
@@ -266,6 +266,7 @@ machopic_non_lazy_ptr_name (const char *
{
const char *temp_name;
tree temp, ident = get_identifier (name);
+ int name_len;
for (temp = machopic_non_lazy_pointers;
temp != NULL_TREE;
@@ -277,16 +278,20 @@ machopic_non_lazy_ptr_name (const char *
name = darwin_strip_name_encoding (name);
+ name_len = strlen (name);
+
/* Try again, but comparing names this time. */
for (temp = machopic_non_lazy_pointers;
temp != NULL_TREE;
temp = TREE_CHAIN (temp))
{
+ int tlen;
if (TREE_VALUE (temp))
{
+ tlen = IDENTIFIER_LENGTH (TREE_VALUE (temp)) - 1;
temp_name = IDENTIFIER_POINTER (TREE_VALUE (temp));
temp_name = darwin_strip_name_encoding (temp_name);
- if (strcmp (name, temp_name) == 0)
+ if (tlen == name_len && strcmp (name, temp_name) == 0)
return IDENTIFIER_POINTER (TREE_PURPOSE (temp));
}
}
@@ -336,19 +341,22 @@ machopic_stub_name (const char *name)
{
tree temp, ident = get_identifier (name);
const char *tname;
+ int name_leng = strlen (name);
for (temp = machopic_stubs;
temp != NULL_TREE;
temp = TREE_CHAIN (temp))
{
+ int tlen;
if (ident == TREE_VALUE (temp))
return IDENTIFIER_POINTER (TREE_PURPOSE (temp));
tname = IDENTIFIER_POINTER (TREE_VALUE (temp));
- if (strcmp (name, tname) == 0)
+ tlen = IDENTIFIER_LENGTH (TREE_VALUE (temp)) - 1;
+ if (tlen == name_leng && strcmp (name, tname) == 0)
return IDENTIFIER_POINTER (TREE_PURPOSE (temp));
/* A library call name might not be section-encoded yet, so try
it against a stripped name. */
- if (name[0] != '!'
+ if (tlen - 4 == name_leng && name[0] != '!'
&& tname[0] == '!'
&& strcmp (name, tname + 4) == 0)
return IDENTIFIER_POINTER (TREE_PURPOSE (temp));