[PATCH] simple speedup for Darwin's stubs/non-lazy symbol finding

Andrew Pinski pinskia@physics.uc.edu
Fri Jun 25 12:07:00 GMT 2004


> 
> 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.

One more I noticed which gets it down to 15.3 seconds
(without the removal of machopic_indirect_call_target).

With removal of machopic_indirect_call_target: 13.6 seconds.

OK? Boostrapped on powerpc-apple-darwin with no regressions.

Oh by the way I made sure that the code for PR8361 was the same for all
of these compilers.

Andrew Pinski

ChangeLog:

	* darwin.c (update_stubs): Check the length of the 
	IDENTIFIER before calling strcmp.

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:34:28 -0000
@@ -1102,16 +1110,20 @@ update_stubs (const char *name)
 {
   const char *name1, *name2;
   tree temp;
+  int name_len;
 
   name1 = darwin_strip_name_encoding (name);
 
+  name_len = strlen (name1);
+
   for (temp = machopic_stubs;
        temp != NULL_TREE;
        temp = TREE_CHAIN (temp))
     {
       const char *sym_name = IDENTIFIER_POINTER (TREE_VALUE (temp));
+      int syn_len = IDENTIFIER_LENGTH (TREE_VALUE (temp)) - 1;
 
-      if (*sym_name == '!')
+      if (*sym_name == '!' && syn_len == name_len)
 	{
 	  name2 = darwin_strip_name_encoding (sym_name);
 	  if (strcmp (name1, name2) == 0)




More information about the Gcc-patches mailing list