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: [libstdc++ PATH] tr1::bind support


On Wednesday 23 March 2005 13:40, Jonathan Wakely wrote:
> On Wed, Mar 23, 2005 at 12:58:56PM +0100, Steven Bosscher wrote:
> > On Tuesday 22 March 2005 11:27, Chris Jefferson wrote:
> > > Steven Bosscher wrote:
> > > > Could you send me a preprocessed file for this?  I want to know
> > > > where all that time is going in a non-PCH compile (I have a few
> > > > ideas, but I'd like to check them...).
> > >
> > > Heres a bzip2ed, preprocessed copy of
> > > testsuite/tr1/6_containers/tuple/comparison_operators/comparisons.cc.
> > > (for 4.1.0 20050315) Have fun ;)
> >
> > Blech.  Almost *all* compile time is sucked up in the C++ front end
> > name look stuff (at any -On, here at -O0):
> >
> > Execution times (seconds)
> >  life analysis         :   0.00 ( 0%) usr   0.00 ( 0%) sys   0.01 ( 0%)
> > wall preprocessing         :   0.30 ( 4%) usr   0.20 (15%) sys   0.59 (
> > 7%) wall parser                :   1.61 (22%) usr   0.63 (46%) sys   2.41
> > (27%) wall name lookup           :   5.40 (73%) usr   0.50 (37%) sys  
> > 5.65 (64%) wall tree gimplify         :   0.03 ( 0%) usr   0.01 ( 1%) sys
> >   0.03 ( 0%) wall tree CFG construction :   0.01 ( 0%) usr   0.00 ( 0%)
> > sys   0.00 ( 0%) wall expand                :   0.00 ( 0%) usr   0.00 (
> > 0%) sys   0.01 ( 0%) wall varconst              :   0.00 ( 0%) usr   0.01
> > ( 1%) sys   0.01 ( 0%) wall local alloc           :   0.01 ( 0%) usr  
> > 0.00 ( 0%) sys   0.00 ( 0%) wall global alloc          :   0.03 ( 0%) usr
> >   0.00 ( 0%) sys   0.01 ( 0%) wall final                 :   0.00 ( 0%)
> > usr   0.00 ( 0%) sys   0.01 ( 0%) wall rest of compilation   :   0.00 (
> > 0%) usr   0.00 ( 0%) sys   0.01 ( 0%) wall TOTAL                 :   7.40
> >             1.36             8.78
> >
> > On a bootstrapped cc1plus of today, oprofile tells me that comptypes
> > takes a rediculous amount of time, as does strlen.  Is this a known
> > bottleneck in the C++ front end?
>
> I think the names of template specialisations for 20-parameter tuples
> will be very long, and will probably only differ at the end of the
> strings, so it may not be such a problem with most other code.

Well, if you are right, and C++ continues in this direction as a language,
this is still something we need to find a solution for.

BTW the patch below, to not compare target attributes until after
making sure that the types are the same from a target-independent
POV, also cuts off 40% of the compile time of this test case for
me.  Will re-post after testing and such...

Gr.
Steven

Index: typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.620
diff -u -3 -p -r1.620 typeck.c
--- typeck.c	22 Mar 2005 09:30:06 -0000	1.620
+++ typeck.c	23 Mar 2005 12:35:58 -0000
@@ -905,8 +905,6 @@ comp_array_types (tree t1, tree t2, bool
 bool
 comptypes (tree t1, tree t2, int strict)
 {
-  int retval;
-
   if (t1 == t2)
     return true;
 
@@ -969,9 +967,7 @@ comptypes (tree t1, tree t2, int strict)
       && TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
     return true;
 
-  if (!(*targetm.comp_type_attributes) (t1, t2))
-    return false;
-
+  /* Compare the types.  Break out if they could be the same.  */
   switch (TREE_CODE (t1))
     {
     case TEMPLATE_TEMPLATE_PARM:
@@ -984,7 +980,7 @@ comptypes (tree t1, tree t2, int strict)
 	   DECL_TEMPLATE_PARMS (TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (t2))))
 	return false;
       if (TREE_CODE (t1) == TEMPLATE_TEMPLATE_PARM)
-	return true;
+	break;
       /* Don't check inheritance.  */
       strict = COMPARE_STRICT;
       /* Fall through.  */
@@ -995,18 +991,17 @@ comptypes (tree t1, tree t2, int strict)
 	  && (TYPE_TI_TEMPLATE (t1) == TYPE_TI_TEMPLATE (t2)
 	      || TREE_CODE (t1) == BOUND_TEMPLATE_TEMPLATE_PARM)
 	  && comp_template_args (TYPE_TI_ARGS (t1), TYPE_TI_ARGS (t2)))
-	return true;
+	break;
       
       if ((strict & COMPARE_BASE) && DERIVED_FROM_P (t1, t2))
-	return true;
+	break;
       else if ((strict & COMPARE_DERIVED) && DERIVED_FROM_P (t2, t1))
-	return true;
+	break;
       
-      /* We may be dealing with Objective-C instances...  */
+      /* We may be dealing with Objective-C instances.  */
       if (TREE_CODE (t1) == RECORD_TYPE
-	  && ((retval = objc_comptypes (t1, t2, 0)) >= 0))
-         return retval;
-      /* ...but fall through if we are not.  */
+	  && objc_comptypes (t1, t2, 0) >= 0)
+	break;
 
       return false;
 
@@ -1014,51 +1009,72 @@ comptypes (tree t1, tree t2, int strict)
       if (!comptypes (TYPE_OFFSET_BASETYPE (t1), TYPE_OFFSET_BASETYPE (t2),
 		      strict & ~COMPARE_REDECLARATION))
 	return false;
-      return same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
+      if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
+	return false;
+      break;
 
     case POINTER_TYPE:
     case REFERENCE_TYPE:
-      return TYPE_MODE (t1) == TYPE_MODE (t2)
-	     && TYPE_REF_CAN_ALIAS_ALL (t1) == TYPE_REF_CAN_ALIAS_ALL (t2)
-	     && same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
+      if (TYPE_MODE (t1) != TYPE_MODE (t2)
+	  || TYPE_REF_CAN_ALIAS_ALL (t1) != TYPE_REF_CAN_ALIAS_ALL (t2)
+	  || !same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
+	return false;
+      break;
 
     case METHOD_TYPE:
     case FUNCTION_TYPE:
       if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
 	return false;
-      return compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2));
+      if (!compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2)))
+	return false;
+      break;
 
     case ARRAY_TYPE:
       /* Target types must match incl. qualifiers.  */
-      return comp_array_types (t1, t2, !!(strict & COMPARE_REDECLARATION));
+      if (!comp_array_types (t1, t2, !!(strict & COMPARE_REDECLARATION)))
+	return false;
+      break;
 
     case TEMPLATE_TYPE_PARM:
-      return (TEMPLATE_TYPE_IDX (t1) == TEMPLATE_TYPE_IDX (t2)
-	      && TEMPLATE_TYPE_LEVEL (t1) == TEMPLATE_TYPE_LEVEL (t2));
+      if (TEMPLATE_TYPE_IDX (t1) != TEMPLATE_TYPE_IDX (t2)
+	  || TEMPLATE_TYPE_LEVEL (t1) != TEMPLATE_TYPE_LEVEL (t2))
+	return false;
+      break;
 
     case TYPENAME_TYPE:
       if (!cp_tree_equal (TYPENAME_TYPE_FULLNAME (t1),
 			  TYPENAME_TYPE_FULLNAME (t2)))
         return false;
-      return same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2));
+      if (!same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2)))
+	return false;
+      break;
 
     case UNBOUND_CLASS_TEMPLATE:
       if (!cp_tree_equal (TYPE_IDENTIFIER (t1), TYPE_IDENTIFIER (t2)))
         return false;
-      return same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2));
+      if (!same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2)))
+	return false;
+      break;
 
     case COMPLEX_TYPE:
-      return same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
+      if (!same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2)))
+	return false;
+      break;
 
     case VECTOR_TYPE:
-      return TYPE_VECTOR_SUBPARTS (t1) == TYPE_VECTOR_SUBPARTS (t2)
-	     && same_type_p (TREE_TYPE (t1), TREE_TYPE (t2));
+      if (TYPE_VECTOR_SUBPARTS (t1) != TYPE_VECTOR_SUBPARTS (t2)
+	  || !same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
+	return false;
       break;
 
     default:
-      break;
+      return false;
     }
-  return false;
+
+  /* If we get here, we know that from a target independent POV the
+     types are the same.  Make sure the target attributes are also
+     the same.  */
+  return targetm.comp_type_attributes (t1, t2);
 }
 
 /* Returns 1 if TYPE1 is at least as qualified as TYPE2.  */


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