public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Move DECL_VINDEX and DECL_SAVED_TREE into function_decl
@ 2014-06-23 20:25 Jan Hubicka
  2014-06-24 14:53 ` Jason Merrill
  2014-07-10  9:50 ` Thomas Schwinge
  0 siblings, 2 replies; 8+ messages in thread
From: Jan Hubicka @ 2014-06-23 20:25 UTC (permalink / raw)
  To: gcc-patches, rguenther, jason

Hi,
this patch makes DECL_VINDEX and DECL_SAVED_TREE to be FUNCTION_DECL only.
This needs to resolve overloading in C++ FE. For namespaces I added new fields
in lang specific annotation and for TEMPLATE_DECL I moved the overload to
UNIT_SIZE that is currently unused.

My incremental plan is to
 1) Move DECL_RESULT/DECL_ARGUMENTS into FUNCTION_DECL only.  This is easier than
    moving them all to struct function at once, but still need to resolve
    (ab)use of those fields in the frontends.
 2) Move DECL_SAVED_TREE to struct function (since it is a generic body).
    This needs bit more changes on users of DECL_SAVED_TREE to be usre that we
    have STRUCT_FUNCTION around and well.
 3) Move DECL_RESULT/DECL_ARGUMENTS (if possible - so far I only got
    C/C++/Fortran working with this change, but I think I am almost there.

Bootstrapped/regtested x86_64-linux, OK?

	* class.c (check_methods, create_vtable_ptr, determine_key_method,
	add_vcall_offset_vtbl_entries_1): Guard VINDEX checks by FUNCTION_DECL check.
	* cp-tree.h (lang_decl_ns): Add ns_using and ns_users.
	(DECL_NAMESPACE_USING, DECL_NAMESPACE_USERS): Use lang_decl_ns.
	(DECL_NAMESPACE_ASSOCIATIONS): Use DECL_INITIAL.
	(DECL_TEMPLATE_INSTANTIATIONS): Use DECL_SIZE_UNIT.
	* tree.c (find_decls_types_r): Do not check DECL_VINDEX for TYPE_DECL.
	* tree.h (DECL_VINDEX, DECL_SAVED_TREE): Restrict to DECL_FUNCTION.
	* tree-core.h (tree_decl_non_common): Move saved_tree and vindex...
	(tree_function_decl): ... here.
	* tree-streamer-out.c (write_ts_decl_non_common_tree_pointers): Move
	streaming of vindex to ...
	(write_ts_function_decl_tree_pointers): ... here.

	* tree-streamer-in.c (lto_input_ts_decl_non_common_tree_pointers):
	Do not stream DECL_VINDEX.
	(lto_input_ts_function_decl_tree_pointers): Stream it here.

	* lto.c (mentions_vars_p_decl_non_common): Move DECL_VINDEX check to ..
	(mentions_vars_p_function): ... here.
	(compare_tree_sccs_1): Update VINDEX checks.
	(lto_fixup_prevailing_decls): Likewise.
Index: cp/class.c
===================================================================
--- cp/class.c	(revision 211838)
+++ cp/class.c	(working copy)
@@ -4356,11 +4356,11 @@ check_methods (tree t)
   for (x = TYPE_METHODS (t); x; x = DECL_CHAIN (x))
     {
       check_for_override (x, t);
-      if (DECL_PURE_VIRTUAL_P (x) && ! DECL_VINDEX (x))
+      if (DECL_PURE_VIRTUAL_P (x) && (TREE_CODE (x) != FUNCTION_DECL || ! DECL_VINDEX (x)))
 	error ("initializer specified for non-virtual method %q+D", x);
       /* The name of the field is the original field name
 	 Save this in auxiliary field for later overloading.  */
-      if (DECL_VINDEX (x))
+      if (TREE_CODE (x) == FUNCTION_DECL && DECL_VINDEX (x))
 	{
 	  TYPE_POLYMORPHIC_P (t) = 1;
 	  if (DECL_PURE_VIRTUAL_P (x))
@@ -5658,7 +5658,8 @@ create_vtable_ptr (tree t, tree* virtual
 
   /* Collect the virtual functions declared in T.  */
   for (fn = TYPE_METHODS (t); fn; fn = DECL_CHAIN (fn))
-    if (DECL_VINDEX (fn) && !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn)
+    if (TREE_CODE (fn) == FUNCTION_DECL
+	&& DECL_VINDEX (fn) && !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn)
 	&& TREE_CODE (DECL_VINDEX (fn)) != INTEGER_CST)
       {
 	tree new_virtual = make_node (TREE_LIST);
@@ -6327,7 +6328,8 @@ determine_key_method (tree type)
      this function until the end of the translation unit.  */
   for (method = TYPE_METHODS (type); method != NULL_TREE;
        method = DECL_CHAIN (method))
-    if (DECL_VINDEX (method) != NULL_TREE
+    if (TREE_CODE (method) == FUNCTION_DECL
+	&& DECL_VINDEX (method) != NULL_TREE
 	&& ! DECL_DECLARED_INLINE_P (method)
 	&& ! DECL_PURE_VIRTUAL_P (method))
       {
@@ -9139,7 +9141,7 @@ add_vcall_offset_vtbl_entries_1 (tree bi
   for (orig_fn = TYPE_METHODS (BINFO_TYPE (binfo));
        orig_fn;
        orig_fn = DECL_CHAIN (orig_fn))
-    if (DECL_VINDEX (orig_fn))
+    if (TREE_CODE (orig_fn) == FUNCTION_DECL && DECL_VINDEX (orig_fn))
       add_vcall_offset (orig_fn, binfo, vid);
 }
 
Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h	(revision 211838)
+++ cp/cp-tree.h	(working copy)
@@ -2048,6 +2048,8 @@ struct GTY(()) lang_decl_fn {
 struct GTY(()) lang_decl_ns {
   struct lang_decl_base base;
   cp_binding_level *level;
+  tree ns_using;
+  tree ns_users;
 };
 
 /* DECL_LANG_SPECIFIC for parameters.  */
@@ -2580,16 +2582,16 @@ struct GTY(()) lang_decl {
 /* For a NAMESPACE_DECL: the list of using namespace directives
    The PURPOSE is the used namespace, the value is the namespace
    that is the common ancestor.  */
-#define DECL_NAMESPACE_USING(NODE) DECL_VINDEX (NAMESPACE_DECL_CHECK (NODE))
+#define DECL_NAMESPACE_USING(NODE) (LANG_DECL_NS_CHECK (NODE)->ns_using)
 
 /* In a NAMESPACE_DECL, the DECL_INITIAL is used to record all users
    of a namespace, to record the transitive closure of using namespace.  */
-#define DECL_NAMESPACE_USERS(NODE) DECL_INITIAL (NAMESPACE_DECL_CHECK (NODE))
+#define DECL_NAMESPACE_USERS(NODE) (LANG_DECL_NS_CHECK (NODE)->ns_users)
 
 /* In a NAMESPACE_DECL, the list of namespaces which have associated
    themselves with this one.  */
 #define DECL_NAMESPACE_ASSOCIATIONS(NODE) \
-  (NAMESPACE_DECL_CHECK (NODE)->decl_non_common.saved_tree)
+  DECL_INITIAL (NAMESPACE_DECL_CHECK (NODE))
 
 /* In a NAMESPACE_DECL, points to the original namespace if this is
    a namespace alias.  */
@@ -3784,7 +3786,7 @@ more_aggr_init_expr_args_p (const aggr_i
 
    This list is not used for other templates.  */
 #define DECL_TEMPLATE_INSTANTIATIONS(NODE) \
-  DECL_VINDEX (TEMPLATE_DECL_CHECK (NODE))
+  DECL_SIZE_UNIT (TEMPLATE_DECL_CHECK (NODE))
 
 /* For a class template, this list contains the partial
    specializations of this template.  (Full specializations are not
Index: tree-streamer-in.c
===================================================================
--- tree-streamer-in.c	(revision 211838)
+++ tree-streamer-in.c	(working copy)
@@ -726,7 +726,6 @@ lto_input_ts_decl_non_common_tree_pointe
 {
   if (TREE_CODE (expr) == TYPE_DECL)
     DECL_ORIGINAL_TYPE (expr) = stream_read_tree (ib, data_in);
-  DECL_VINDEX (expr) = stream_read_tree (ib, data_in);
 }
 
 
@@ -773,8 +772,8 @@ static void
 lto_input_ts_function_decl_tree_pointers (struct lto_input_block *ib,
 					  struct data_in *data_in, tree expr)
 {
-  /* DECL_STRUCT_FUNCTION is handled by lto_input_function.  FIXME lto,
-     maybe it should be handled here?  */
+  DECL_VINDEX (expr) = stream_read_tree (ib, data_in);
+  /* DECL_STRUCT_FUNCTION is loaded on demand by cgraph_get_body.  */
   DECL_FUNCTION_PERSONALITY (expr) = stream_read_tree (ib, data_in);
   /* DECL_FUNCTION_SPECIFIC_TARGET is regenerated from attributes.  */
   DECL_FUNCTION_SPECIFIC_OPTIMIZATION (expr) = stream_read_tree (ib, data_in);
Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 211838)
+++ lto/lto.c	(working copy)
@@ -779,7 +780,6 @@ mentions_vars_p_decl_non_common (tree t)
     return true;
   CHECK_NO_VAR (DECL_ARGUMENT_FLD (t));
   CHECK_NO_VAR (DECL_RESULT_FLD (t));
-  CHECK_NO_VAR (DECL_VINDEX (t));
   return false;
 }
 
@@ -790,6 +790,7 @@ mentions_vars_p_function (tree t)
 {
   if (mentions_vars_p_decl_non_common (t))
     return true;
+  CHECK_NO_VAR (DECL_VINDEX (t));
   CHECK_VAR (DECL_FUNCTION_PERSONALITY (t));
   return false;
 }
@@ -1514,7 +1515,6 @@ compare_tree_sccs_1 (tree t1, tree t2, t
 	}
       else if (code == TYPE_DECL)
 	compare_tree_edges (DECL_ORIGINAL_TYPE (t1), DECL_ORIGINAL_TYPE (t2));
-      compare_tree_edges (DECL_VINDEX (t1), DECL_VINDEX (t2));
     }
 
   if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
@@ -1540,6 +1540,7 @@ compare_tree_sccs_1 (tree t1, tree t2, t
     {
       compare_tree_edges (DECL_FUNCTION_PERSONALITY (t1),
 			  DECL_FUNCTION_PERSONALITY (t2));
+      compare_tree_edges (DECL_VINDEX (t1), DECL_VINDEX (t2));
       /* DECL_FUNCTION_SPECIFIC_TARGET is not yet created.  We compare
          the attribute list instead.  */
       compare_tree_edges (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (t1),
@@ -2716,10 +2719,12 @@ lto_fixup_prevailing_decls (tree t)
 	{
 	  LTO_NO_PREVAIL (DECL_ARGUMENT_FLD (t));
 	  LTO_NO_PREVAIL (DECL_RESULT_FLD (t));
-	  LTO_NO_PREVAIL (DECL_VINDEX (t));
 	}
       if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
-	LTO_SET_PREVAIL (DECL_FUNCTION_PERSONALITY (t));
+	{
+	  LTO_SET_PREVAIL (DECL_FUNCTION_PERSONALITY (t));
+	  LTO_NO_PREVAIL (DECL_VINDEX (t));
+	}
       if (CODE_CONTAINS_STRUCT (code, TS_FIELD_DECL))
 	{
 	  LTO_SET_PREVAIL (DECL_FIELD_OFFSET (t));
Index: tree.c
===================================================================
--- tree.c	(revision 211838)
+++ tree.c	(working copy)
@@ -5306,7 +5306,6 @@ find_decls_types_r (tree *tp, int *ws, v
       else if (TREE_CODE (t) == TYPE_DECL)
 	{
 	  fld_worklist_push (DECL_ARGUMENT_FLD (t), fld);
-	  fld_worklist_push (DECL_VINDEX (t), fld);
 	  fld_worklist_push (DECL_ORIGINAL_TYPE (t), fld);
 	}
       else if (TREE_CODE (t) == FIELD_DECL)
Index: tree.h
===================================================================
--- tree.h	(revision 211838)
+++ tree.h	(working copy)
@@ -2470,10 +2470,9 @@ extern void decl_fini_priority_insert (t
    is the FUNCTION_DECL which this FUNCTION_DECL will replace as a virtual
    function.  When the class is laid out, this pointer is changed
    to an INTEGER_CST node which is suitable for use as an index
-   into the virtual function table.
-   C++ also uses this field in namespaces, hence the DECL_NON_COMMON_CHECK.  */
+   into the virtual function table. */
 #define DECL_VINDEX(NODE) \
-  (DECL_NON_COMMON_CHECK (NODE)->decl_non_common.vindex)
+  (FUNCTION_DECL_CHECK (NODE)->function_decl.vindex)
 
 /* In FUNCTION_DECL, holds the decl for the return value.  */
 #define DECL_RESULT(NODE) (FUNCTION_DECL_CHECK (NODE)->decl_non_common.result)
@@ -2485,7 +2484,7 @@ extern void decl_fini_priority_insert (t
 /* In a FUNCTION_DECL, the saved representation of the body of the
    entire function.  */
 #define DECL_SAVED_TREE(NODE) \
-  (FUNCTION_DECL_CHECK (NODE)->decl_non_common.saved_tree)
+  (FUNCTION_DECL_CHECK (NODE)->function_decl.saved_tree)
 
 /* Nonzero in a FUNCTION_DECL means this function should be treated
    as if it were a malloc, meaning it returns a pointer that is
Index: tree-core.h
===================================================================
--- tree-core.h	(revision 211838)
+++ tree-core.h	(working copy)
@@ -1484,14 +1484,10 @@ struct GTY(()) tree_var_decl {
 
 struct GTY(()) tree_decl_non_common {
   struct tree_decl_with_vis common;
-  /* C++ uses this in namespaces.  */
-  tree saved_tree;
   /* C++ uses this in templates.  */
   tree arguments;
   /* Almost all FE's use this.  */
   tree result;
-  /* C++ uses this in namespaces and function_decls.  */
-  tree vindex;
 };
 
 /* FUNCTION_DECL inherits from DECL_NON_COMMON because of the use of the
@@ -1511,6 +1507,11 @@ struct GTY(()) tree_function_decl {
   tree function_specific_target;	/* target options */
   tree function_specific_optimization;	/* optimization options */
 
+  /* Generic function body.  */
+  tree saved_tree;
+  /* Index within a virtual table.  */
+  tree vindex;
+
   /* In a FUNCTION_DECL for which DECL_BUILT_IN holds, this is
      DECL_FUNCTION_CODE.  Otherwise unused.
      ???  The bitfield needs to be able to hold all target function
Index: tree-streamer-out.c
===================================================================
--- tree-streamer-out.c	(revision 211838)
+++ tree-streamer-out.c	(working copy)
@@ -638,7 +638,6 @@ write_ts_decl_non_common_tree_pointers (
 {
   if (TREE_CODE (expr) == TYPE_DECL)
     stream_write_tree (ob, DECL_ORIGINAL_TYPE (expr), ref_p);
-  stream_write_tree (ob, DECL_VINDEX (expr), ref_p);
 }
 
 
@@ -682,6 +681,7 @@ static void
 write_ts_function_decl_tree_pointers (struct output_block *ob, tree expr,
 				      bool ref_p)
 {
+  stream_write_tree (ob, DECL_VINDEX (expr), ref_p);
   /* DECL_STRUCT_FUNCTION is handled by lto_output_function.  FIXME lto,
      maybe it should be handled here?  */
   stream_write_tree (ob, DECL_FUNCTION_PERSONALITY (expr), ref_p);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Move DECL_VINDEX and DECL_SAVED_TREE into function_decl
  2014-06-23 20:25 Move DECL_VINDEX and DECL_SAVED_TREE into function_decl Jan Hubicka
@ 2014-06-24 14:53 ` Jason Merrill
  2014-06-24 18:18   ` Jan Hubicka
  2014-07-10  9:50 ` Thomas Schwinge
  1 sibling, 1 reply; 8+ messages in thread
From: Jason Merrill @ 2014-06-24 14:53 UTC (permalink / raw)
  To: Jan Hubicka, gcc-patches, rguenther

On 06/23/2014 04:25 PM, Jan Hubicka wrote:
> 	* class.c (check_methods, create_vtable_ptr, determine_key_method,
> 	add_vcall_offset_vtbl_entries_1): Guard VINDEX checks by FUNCTION_DECL check.

These changes are unnecessary: TYPE_METHODS is a list of functions.

The rest of the patch is OK.

Jason

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Move DECL_VINDEX and DECL_SAVED_TREE into function_decl
  2014-06-24 14:53 ` Jason Merrill
@ 2014-06-24 18:18   ` Jan Hubicka
  2014-06-24 20:50     ` Jason Merrill
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Hubicka @ 2014-06-24 18:18 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Jan Hubicka, gcc-patches, rguenther

> On 06/23/2014 04:25 PM, Jan Hubicka wrote:
> >	* class.c (check_methods, create_vtable_ptr, determine_key_method,
> >	add_vcall_offset_vtbl_entries_1): Guard VINDEX checks by FUNCTION_DECL check.
> 
> These changes are unnecessary: TYPE_METHODS is a list of functions.

I just double checked and there are template decls in the list, too. Those
always have VINDEX NULL, but with my change they naturally ICEs when you query
it.  I am re-testing the patch with the checks added back and intend to commit.

Honza
> 
> The rest of the patch is OK.
> 
> Jason

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Move DECL_VINDEX and DECL_SAVED_TREE into function_decl
  2014-06-24 18:18   ` Jan Hubicka
@ 2014-06-24 20:50     ` Jason Merrill
  2014-06-25  2:26       ` Jan Hubicka
  0 siblings, 1 reply; 8+ messages in thread
From: Jason Merrill @ 2014-06-24 20:50 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches, rguenther

On 06/24/2014 02:18 PM, Jan Hubicka wrote:
>> On 06/23/2014 04:25 PM, Jan Hubicka wrote:
>>> 	* class.c (check_methods, create_vtable_ptr, determine_key_method,
>>> 	add_vcall_offset_vtbl_entries_1): Guard VINDEX checks by FUNCTION_DECL check.
>>
>> These changes are unnecessary: TYPE_METHODS is a list of functions.
>
> I just double checked and there are template decls in the list, too. Those
> always have VINDEX NULL, but with my change they naturally ICEs when you query
> it.  I am re-testing the patch with the checks added back and intend to commit.

Ah, of course.  OK.

Jason


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Move DECL_VINDEX and DECL_SAVED_TREE into function_decl
  2014-06-24 20:50     ` Jason Merrill
@ 2014-06-25  2:26       ` Jan Hubicka
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Hubicka @ 2014-06-25  2:26 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Jan Hubicka, gcc-patches, rguenther

> On 06/24/2014 02:18 PM, Jan Hubicka wrote:
> >>On 06/23/2014 04:25 PM, Jan Hubicka wrote:
> >>>	* class.c (check_methods, create_vtable_ptr, determine_key_method,
> >>>	add_vcall_offset_vtbl_entries_1): Guard VINDEX checks by FUNCTION_DECL check.
> >>
> >>These changes are unnecessary: TYPE_METHODS is a list of functions.
> >
> >I just double checked and there are template decls in the list, too. Those
> >always have VINDEX NULL, but with my change they naturally ICEs when you query
> >it.  I am re-testing the patch with the checks added back and intend to commit.
> 
> Ah, of course.  OK.
Thanks a lot!

Honza

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Move DECL_VINDEX and DECL_SAVED_TREE into function_decl
  2014-06-23 20:25 Move DECL_VINDEX and DECL_SAVED_TREE into function_decl Jan Hubicka
  2014-06-24 14:53 ` Jason Merrill
@ 2014-07-10  9:50 ` Thomas Schwinge
  2014-07-10 11:36   ` Richard Biener
  2014-07-10 11:58   ` Jan Hubicka
  1 sibling, 2 replies; 8+ messages in thread
From: Thomas Schwinge @ 2014-07-10  9:50 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches, rguenther, jason

[-- Attachment #1: Type: text/plain, Size: 2145 bytes --]

Hi!

On Mon, 23 Jun 2014 22:25:41 +0200, Jan Hubicka <hubicka@ucw.cz> wrote:
> this patch makes DECL_VINDEX and DECL_SAVED_TREE to be FUNCTION_DECL only.

> Bootstrapped/regtested x86_64-linux, OK?

... without --enable-checking=fold.  ;-P

> 	* class.c (check_methods, create_vtable_ptr, determine_key_method,
> 	add_vcall_offset_vtbl_entries_1): Guard VINDEX checks by FUNCTION_DECL check.
> 	* cp-tree.h (lang_decl_ns): Add ns_using and ns_users.
> 	(DECL_NAMESPACE_USING, DECL_NAMESPACE_USERS): Use lang_decl_ns.
> 	(DECL_NAMESPACE_ASSOCIATIONS): Use DECL_INITIAL.
> 	(DECL_TEMPLATE_INSTANTIATIONS): Use DECL_SIZE_UNIT.
> 	* tree.c (find_decls_types_r): Do not check DECL_VINDEX for TYPE_DECL.
> 	* tree.h (DECL_VINDEX, DECL_SAVED_TREE): Restrict to DECL_FUNCTION.
> 	* tree-core.h (tree_decl_non_common): Move saved_tree and vindex...
> 	(tree_function_decl): ... here.
> 	* tree-streamer-out.c (write_ts_decl_non_common_tree_pointers): Move
> 	streaming of vindex to ...
> 	(write_ts_function_decl_tree_pointers): ... here.
> 
> 	* tree-streamer-in.c (lto_input_ts_decl_non_common_tree_pointers):
> 	Do not stream DECL_VINDEX.
> 	(lto_input_ts_function_decl_tree_pointers): Stream it here.
> 
> 	* lto.c (mentions_vars_p_decl_non_common): Move DECL_VINDEX check to ..
> 	(mentions_vars_p_function): ... here.
> 	(compare_tree_sccs_1): Update VINDEX checks.
> 	(lto_fixup_prevailing_decls): Likewise.

I'm seeing ICEs: »tree check: expected function_decl, have type_decl in
fold_checksum_tree, at fold-const.c:14861«.  Is the following the correct
fix, or should this be done differently?

--- gcc/fold-const.c
+++ gcc/fold-const.c
@@ -14858,7 +14858,8 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx,
 
       if (CODE_CONTAINS_STRUCT (TREE_CODE (expr), TS_DECL_NON_COMMON))
 	{
-	  fold_checksum_tree (DECL_VINDEX (expr), ctx, ht);
+	  if (TREE_CODE (expr) == FUNCTION_DECL)
+	    fold_checksum_tree (DECL_VINDEX (expr), ctx, ht);
 	  fold_checksum_tree (DECL_RESULT_FLD (expr), ctx, ht);
 	  fold_checksum_tree (DECL_ARGUMENT_FLD (expr), ctx, ht);
 	}


Grüße,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 472 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Move DECL_VINDEX and DECL_SAVED_TREE into function_decl
  2014-07-10  9:50 ` Thomas Schwinge
@ 2014-07-10 11:36   ` Richard Biener
  2014-07-10 11:58   ` Jan Hubicka
  1 sibling, 0 replies; 8+ messages in thread
From: Richard Biener @ 2014-07-10 11:36 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: Jan Hubicka, GCC Patches, Richard Biener, Jason Merrill

On Thu, Jul 10, 2014 at 11:50 AM, Thomas Schwinge
<thomas@codesourcery.com> wrote:
> Hi!
>
> On Mon, 23 Jun 2014 22:25:41 +0200, Jan Hubicka <hubicka@ucw.cz> wrote:
>> this patch makes DECL_VINDEX and DECL_SAVED_TREE to be FUNCTION_DECL only.
>
>> Bootstrapped/regtested x86_64-linux, OK?
>
> ... without --enable-checking=fold.  ;-P
>
>>       * class.c (check_methods, create_vtable_ptr, determine_key_method,
>>       add_vcall_offset_vtbl_entries_1): Guard VINDEX checks by FUNCTION_DECL check.
>>       * cp-tree.h (lang_decl_ns): Add ns_using and ns_users.
>>       (DECL_NAMESPACE_USING, DECL_NAMESPACE_USERS): Use lang_decl_ns.
>>       (DECL_NAMESPACE_ASSOCIATIONS): Use DECL_INITIAL.
>>       (DECL_TEMPLATE_INSTANTIATIONS): Use DECL_SIZE_UNIT.
>>       * tree.c (find_decls_types_r): Do not check DECL_VINDEX for TYPE_DECL.
>>       * tree.h (DECL_VINDEX, DECL_SAVED_TREE): Restrict to DECL_FUNCTION.
>>       * tree-core.h (tree_decl_non_common): Move saved_tree and vindex...
>>       (tree_function_decl): ... here.
>>       * tree-streamer-out.c (write_ts_decl_non_common_tree_pointers): Move
>>       streaming of vindex to ...
>>       (write_ts_function_decl_tree_pointers): ... here.
>>
>>       * tree-streamer-in.c (lto_input_ts_decl_non_common_tree_pointers):
>>       Do not stream DECL_VINDEX.
>>       (lto_input_ts_function_decl_tree_pointers): Stream it here.
>>
>>       * lto.c (mentions_vars_p_decl_non_common): Move DECL_VINDEX check to ..
>>       (mentions_vars_p_function): ... here.
>>       (compare_tree_sccs_1): Update VINDEX checks.
>>       (lto_fixup_prevailing_decls): Likewise.
>
> I'm seeing ICEs: »tree check: expected function_decl, have type_decl in
> fold_checksum_tree, at fold-const.c:14861«.  Is the following the correct
> fix, or should this be done differently?
>
> --- gcc/fold-const.c
> +++ gcc/fold-const.c
> @@ -14858,7 +14858,8 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx,
>
>        if (CODE_CONTAINS_STRUCT (TREE_CODE (expr), TS_DECL_NON_COMMON))
>         {
> -         fold_checksum_tree (DECL_VINDEX (expr), ctx, ht);
> +         if (TREE_CODE (expr) == FUNCTION_DECL)
> +           fold_checksum_tree (DECL_VINDEX (expr), ctx, ht);
>           fold_checksum_tree (DECL_RESULT_FLD (expr), ctx, ht);
>           fold_checksum_tree (DECL_ARGUMENT_FLD (expr), ctx, ht);
>         }
>

Looks good to me.

Richard.

> Grüße,
>  Thomas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Move DECL_VINDEX and DECL_SAVED_TREE into function_decl
  2014-07-10  9:50 ` Thomas Schwinge
  2014-07-10 11:36   ` Richard Biener
@ 2014-07-10 11:58   ` Jan Hubicka
  1 sibling, 0 replies; 8+ messages in thread
From: Jan Hubicka @ 2014-07-10 11:58 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: Jan Hubicka, gcc-patches, rguenther, jason

> I'm seeing ICEs: »tree check: expected function_decl, have type_decl in
> fold_checksum_tree, at fold-const.c:14861«.  Is the following the correct
> fix, or should this be done differently?

No, it seems fine to me.  I added it to my local patch, thanks!
Honza
> 
> --- gcc/fold-const.c
> +++ gcc/fold-const.c
> @@ -14858,7 +14858,8 @@ fold_checksum_tree (const_tree expr, struct md5_ctx *ctx,
>  
>        if (CODE_CONTAINS_STRUCT (TREE_CODE (expr), TS_DECL_NON_COMMON))
>  	{
> -	  fold_checksum_tree (DECL_VINDEX (expr), ctx, ht);
> +	  if (TREE_CODE (expr) == FUNCTION_DECL)
> +	    fold_checksum_tree (DECL_VINDEX (expr), ctx, ht);
>  	  fold_checksum_tree (DECL_RESULT_FLD (expr), ctx, ht);
>  	  fold_checksum_tree (DECL_ARGUMENT_FLD (expr), ctx, ht);
>  	}
> 
> 
> Grüße,
>  Thomas


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-07-10 11:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-23 20:25 Move DECL_VINDEX and DECL_SAVED_TREE into function_decl Jan Hubicka
2014-06-24 14:53 ` Jason Merrill
2014-06-24 18:18   ` Jan Hubicka
2014-06-24 20:50     ` Jason Merrill
2014-06-25  2:26       ` Jan Hubicka
2014-07-10  9:50 ` Thomas Schwinge
2014-07-10 11:36   ` Richard Biener
2014-07-10 11:58   ` Jan Hubicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).