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]

Remove method_class_type


Hi,
when I introduced method_class_type I was not aware that TYPE_METHOD_BASETYPE
gives previsely the same information. 

Bootstrapped/regtested x86_64-linux, will commit it shortly.

	* ipa-utils.h (method_class_type): Remove.
	* cgraphunit.c (walk_polymorphic_call_targets): Use TYPE_METHOD_BASETYPE.
	* ipa-devirt.c (type_in_anonymous_namespace_p): Check that it is called
	on main variants only.
	(method_class_type): Remove.
	(update_type_inheritance_graph): Use TYPE_METHOD_BASETYPE.
	(build_type_inheritance_graph): Likewise.
	* ipa-icf.c (sem_function::equals_wpa): Likewise.
	* pa-polymorphic-call.c (decl_maybe_in_construction_p, 
	check_stmt_for_type_change): Use TYPE_METHOD_BASETYPE.
	* ipa.c (walk_polymorphic_call_targets): Likewise.
	* tree.c (verify_type): Verify that TYPE_METHOD_BASETYPE is main variant.
Index: gcc/cgraphunit.c
===================================================================
--- gcc/cgraphunit.c	(revision 223628)
+++ gcc/cgraphunit.c	(working copy)
@@ -866,9 +866,8 @@
 		  (TREE_TYPE (targets[i]->decl))
 		   == METHOD_TYPE
 	      && !type_in_anonymous_namespace_p
-		   (method_class_type
-		     (TREE_TYPE (targets[i]->decl))))
-	  enqueue_node (targets[i]);
+		   (TYPE_METHOD_BASETYPE (TREE_TYPE (targets[i]->decl))))
+	    enqueue_node (targets[i]);
 	}
     }
 
Index: gcc/ipa-devirt.c
===================================================================
--- gcc/ipa-devirt.c	(revision 223628)
+++ gcc/ipa-devirt.c	(working copy)
@@ -2279,18 +2280,6 @@
     }
 }
 
-/* Given method type T, return type of class it belongs to.
-   Look up this pointer and get its type.    */
-
-tree
-method_class_type (const_tree t)
-{
-  tree first_parm_type = TREE_VALUE (TYPE_ARG_TYPES (t));
-  gcc_assert (TREE_CODE (t) == METHOD_TYPE);
-
-  return TREE_TYPE (first_parm_type);
-}
-
 /* Initialize IPA devirt and build inheritance tree graph.  */
 
 void
@@ -2314,8 +2303,7 @@
     if (is_a <cgraph_node *> (n)
 	&& DECL_VIRTUAL_P (n->decl)
 	&& n->real_symbol_p ())
-      get_odr_type (TYPE_MAIN_VARIANT (method_class_type (TREE_TYPE (n->decl))),
-		    true);
+      get_odr_type (TYPE_METHOD_BASETYPE (TREE_TYPE (n->decl)), true);
 
     /* Look also for virtual tables of types that do not define any methods.
  
@@ -3446,8 +3434,7 @@
     if (DECL_VIRTUAL_P (n->decl)
 	&& !n->definition
 	&& n->real_symbol_p ())
-      get_odr_type (method_class_type (TYPE_MAIN_VARIANT (TREE_TYPE (n->decl))),
-				       true);
+      get_odr_type (TYPE_METHOD_BASETYPE (TREE_TYPE (n->decl)), true);
   timevar_pop (TV_IPA_INHERITANCE);
 }
 
Index: gcc/ipa-icf.c
===================================================================
--- gcc/ipa-icf.c	(revision 223628)
+++ gcc/ipa-icf.c	(working copy)
@@ -663,8 +663,8 @@
       if (TREE_CODE (TREE_TYPE (item->decl)) != METHOD_TYPE)
         return return_false_with_msg ("DECL_CXX_CONSTURCTOR type mismatch");
       else if (!func_checker::compatible_polymorphic_types_p
-		 (method_class_type (TREE_TYPE (decl)),
-		  method_class_type (TREE_TYPE (item->decl)), false))
+		 (TYPE_METHOD_BASETYPE (TREE_TYPE (decl)),
+		  TYPE_METHOD_BASETYPE (TREE_TYPE (item->decl)), false))
         return return_false_with_msg ("ctor polymorphic type mismatch");
     }
 
@@ -753,8 +753,8 @@
       if (TREE_CODE (TREE_TYPE (decl)) != TREE_CODE (TREE_TYPE (item->decl)))
 	return return_false_with_msg ("METHOD_TYPE and FUNCTION_TYPE mismatch");
       if (!func_checker::compatible_polymorphic_types_p
-	   (method_class_type (TREE_TYPE (decl)),
-	    method_class_type (TREE_TYPE (item->decl)), false))
+	   (TYPE_METHOD_BASETYPE (TREE_TYPE (decl)),
+	    TYPE_METHOD_BASETYPE (TREE_TYPE (item->decl)), false))
 	return return_false_with_msg ("THIS pointer ODR type mismatch");
     }
 
@@ -2722,7 +2722,7 @@
 	{
 	  if (TREE_CODE (TREE_TYPE (m_items[i]->decl)) == METHOD_TYPE
 	      && contains_polymorphic_type_p
-		   (method_class_type (TREE_TYPE (m_items[i]->decl)))
+		   (TYPE_METHOD_BASETYPE (TREE_TYPE (m_items[i]->decl)))
 	      && (DECL_CXX_CONSTRUCTOR_P (m_items[i]->decl)
 		  || (static_cast<sem_function *> (m_items[i])->param_used_p (0)
 		      && static_cast<sem_function *> (m_items[i])
@@ -2729,7 +2729,7 @@
 			   ->compare_polymorphic_p ())))
 	     {
 	        tree class_type
-		  = method_class_type (TREE_TYPE (m_items[i]->decl));
+		  = TYPE_METHOD_BASETYPE (TREE_TYPE (m_items[i]->decl));
 		inchash::hash hstate (m_items[i]->hash);
 
 		if (TYPE_NAME (class_type)
Index: gcc/ipa-polymorphic-call.c
===================================================================
--- gcc/ipa-polymorphic-call.c	(revision 223628)
+++ gcc/ipa-polymorphic-call.c	(working copy)
@@ -588,7 +588,7 @@
        block = BLOCK_SUPERCONTEXT (block))
     if (tree fn = inlined_polymorphic_ctor_dtor_block_p (block, check_clones))
       {
-	tree type = TYPE_MAIN_VARIANT (method_class_type (TREE_TYPE (fn)));
+	tree type = TYPE_METHOD_BASETYPE (TREE_TYPE (fn));
 
 	if (!outer_type || !types_odr_comparable (type, outer_type))
 	  {
@@ -618,7 +618,7 @@
 		  && !DECL_CXX_DESTRUCTOR_P (function)))
 	    return false;
 	}
-      tree type = TYPE_MAIN_VARIANT (method_class_type (TREE_TYPE (function)));
+      tree type = TYPE_METHOD_BASETYPE (TREE_TYPE (function));
       if (!outer_type || !types_odr_comparable (type, outer_type))
 	{
 	  if (TREE_CODE (type) == RECORD_TYPE
@@ -1399,7 +1399,7 @@
 	  && gimple_call_num_args (stmt))
       {
 	tree op = walk_ssa_copies (gimple_call_arg (stmt, 0));
-	tree type = method_class_type (TREE_TYPE (fn));
+	tree type = TYPE_METHOD_BASETYPE (TREE_TYPE (fn));
 	HOST_WIDE_INT offset = 0, size, max_size;
 
 	if (dump_file)
Index: gcc/ipa-utils.h
===================================================================
--- gcc/ipa-utils.h	(revision 223628)
+++ gcc/ipa-utils.h	(working copy)
@@ -72,7 +72,6 @@
 bool possible_polymorphic_call_target_p (tree, HOST_WIDE_INT,
 				         const ipa_polymorphic_call_context &,
 					 struct cgraph_node *);
-tree method_class_type (const_tree);
 tree inlined_polymorphic_ctor_dtor_block_p (tree, bool);
 bool decl_maybe_in_construction_p (tree, tree, gimple, tree);
 tree vtable_pointer_value_to_binfo (const_tree);
Index: gcc/ipa.c
===================================================================
--- gcc/ipa.c	(revision 223628)
+++ gcc/ipa.c	(working copy)
@@ -197,7 +197,7 @@
 	     unused.  */
 	  if (TREE_CODE (TREE_TYPE (n->decl)) == METHOD_TYPE
 	      && type_in_anonymous_namespace_p
-		    (method_class_type (TREE_TYPE (n->decl))))
+		    (TYPE_METHOD_BASETYPE (TREE_TYPE (n->decl))))
 	    continue;
 
 	   symtab_node *body = n->function_symbol ();
Index: gcc/tree.c
===================================================================
--- gcc/tree.c	(revision 223628)
+++ gcc/tree.c	(working copy)
@@ -13262,8 +13262,16 @@
 	}
     }
   
+  /* ipa-devirt makes an assumption that TYPE_METHOD_BASETYPE is always
+     TYPE_MAIN_VARIANT and it would be odd to add methods only to variatns
+     of a type. */
+  if (TREE_CODE (t) == METHOD_TYPE
+      && TYPE_MAIN_VARIANT (TYPE_METHOD_BASETYPE (t)) != TYPE_METHOD_BASETYPE (t))
+    {
+	error ("TYPE_METHOD_BASETYPE is not main variant");
+	error_found = true;
+    }
 
-
   if (error_found)
     {
       debug_tree (const_cast <tree> (t));


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