public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Move DECL_RESULT into function_decl
@ 2014-07-15 14:59 Jan Hubicka
  2014-07-15 15:23 ` Jason Merrill
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Hubicka @ 2014-07-15 14:59 UTC (permalink / raw)
  To: gcc-patches, rguenther, jason

Hi,
this patch continues by moving DECL_RESULT into FUNCTION_DECL. tree_decl_non_common
becomes empty, but I decided to get rid of it in an followup patch - it needs more
changes and doing it all at once would be bit convoluted.

Bootstrappred/regtested x86_64-linux, OK?

Honza

	* tree-core.h (tree_decl_non_common): Remove result.
	(tree_function_decl): Add it here.
	* tree.h (DECL_RESULT_FLD): Remove.
	(DECL_RESULT): Update.
	(DECL_ORIGINAL_TYPE): Update
	* print-tree.c (print_node): Update.
	* tree-browser.c (browse_tree): Likewise.
	* fold-const.c (fold_checksum_tree): Update.
	* tree-streamer-in.c (lto_input_ts_decl_non_common_tree_pointers): Remove.
	(streamer_read_tree_body): Update.
	* tree-streamer-out.c (write_ts_decl_non_common_tree_pointers): Remove.
	(streamer_write_tree_body): Remove.

	* lto.c (mentions_vars_p_decl_non_common): Update for DECL_RESULT being
	moved to FUNCTION_DECL.
	(mentions_vars_p_function): Likewise.
	(lto_fixup_prevailing_decls): Likewise.

	* objc-act.h (INSTANCE_METHOD_OR_CLASS_METHOD_DECL_CHECK): Use
	attributes pointer.
	PROPERTY_DECL_CHECK): Use size_unit.

	* c-ada-spec.c (dump_ada_template): Use DECL_RESULT
	(tree_function_decl): Add it here.
	* tree.h (DECL_RESULT_FLD): Remove.
	(DECL_RESULT): Update.
	(DECL_ORIGINAL_TYPE): Use DECL_INITIAL instead of DECL_RESULT.
	* print-tree.c (print_node): Update.
	* tree-browser.c (browse_tree): Likewise.
	* fold-const.c (fold_checksum_tree): Update.
	* tree-streamer-in.c (lto_input_ts_decl_non_common_tree_pointers): Remove.
	(streamer_read_tree_body): Update.
	* tree-streamer-out.c (write_ts_decl_non_common_tree_pointers): Remove.
	(streamer_write_tree_body): Remove.

	* lto.c (mentions_vars_p_decl_non_common): Update for DECL_RESULT being
	moved to FUNCTION_DECL.
	(mentions_vars_p_function): Likewise.
	(lto_fixup_prevailing_decls): Likewise.

	* objc-act.h (INSTANCE_METHOD_OR_CLASS_METHOD_DECL_CHECK): Use
	attributes pointer.
	PROPERTY_DECL_CHECK): Use size_unit.

	* c-ada-spec.c (dump_ada_template): Use DECL_RESULT
Index: tree.h
===================================================================
--- tree.h	(revision 212549)
+++ tree.h	(working copy)
@@ -2464,11 +2464,6 @@ extern void decl_fini_priority_insert (t
 #define DECL_NONALIASED(NODE) \
   (VAR_DECL_CHECK (NODE)->base.nothrow_flag)
 
-/* This field is used to reference anything in decl.result and is meant only
-   for use by the garbage collector.  */
-#define DECL_RESULT_FLD(NODE) \
-  (DECL_NON_COMMON_CHECK (NODE)->decl_non_common.result)
-
 /* The DECL_VINDEX is used for FUNCTION_DECLS in two different ways.
    Before the struct containing the FUNCTION_DECL is laid out,
    DECL_VINDEX may point to a FUNCTION_DECL in a base class which
@@ -2480,7 +2475,7 @@ extern void decl_fini_priority_insert (t
   (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)
+#define DECL_RESULT(NODE) (FUNCTION_DECL_CHECK (NODE)->function_decl.result)
 
 /* In a FUNCTION_DECL, nonzero if the function cannot be inlined.  */
 #define DECL_UNINLINABLE(NODE) \
@@ -2666,7 +2661,7 @@ extern vec<tree, va_gc> **decl_debug_arg
 
 /* For a TYPE_DECL, holds the "original" type.  (TREE_TYPE has the copy.) */
 #define DECL_ORIGINAL_TYPE(NODE) \
-  (TYPE_DECL_CHECK (NODE)->decl_non_common.result)
+  (TYPE_DECL_CHECK (NODE)->type_decl.original)
 
 /* In a TYPE_DECL nonzero means the detail info about this type is not dumped
    into stabs.  Instead it will generate cross reference ('x') of names.
Index: tree-streamer-in.c
===================================================================
--- tree-streamer-in.c	(revision 212549)
+++ tree-streamer-in.c	(working copy)
@@ -713,17 +713,6 @@ lto_input_ts_decl_common_tree_pointers (
       if (dexpr)
 	SET_DECL_DEBUG_EXPR (expr, dexpr);
     }
-}
-
-
-/* Read all pointer fields in the TS_DECL_NON_COMMON structure of
-   EXPR from input block IB.  DATA_IN contains tables and descriptors for the
-   file being read.  */
-
-static void
-lto_input_ts_decl_non_common_tree_pointers (struct lto_input_block *ib,
-					    struct data_in *data_in, tree expr)
-{
   if (TREE_CODE (expr) == TYPE_DECL)
     DECL_ORIGINAL_TYPE (expr) = stream_read_tree (ib, data_in);
 }
@@ -1032,9 +1021,6 @@ streamer_read_tree_body (struct lto_inpu
   if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
     lto_input_ts_decl_common_tree_pointers (ib, data_in, expr);
 
-  if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
-    lto_input_ts_decl_non_common_tree_pointers (ib, data_in, expr);
-
   if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
     lto_input_ts_decl_with_vis_tree_pointers (ib, data_in, expr);
 
Index: c-family/c-ada-spec.c
===================================================================
--- c-family/c-ada-spec.c	(revision 212549)
+++ c-family/c-ada-spec.c	(working copy)
@@ -1722,7 +1722,7 @@ dump_ada_template (pretty_printer *buffe
   /* DECL_VINDEX is DECL_TEMPLATE_INSTANTIATIONS in this context.  */
   tree inst = DECL_VINDEX (t);
   /* DECL_RESULT_FLD is DECL_TEMPLATE_RESULT in this context.  */
-  tree result = DECL_RESULT_FLD (t);
+  tree result = DECL_RESULT (t);
   int num_inst = 0;
 
   /* Don't look at template declarations declaring something coming from
Index: tree-browser.c
===================================================================
--- tree-browser.c	(revision 212549)
+++ tree-browser.c	(working copy)
@@ -351,14 +351,14 @@ browse_tree (tree begin)
 	  break;
 
 	case TB_RESULT:
-	  if (head && DECL_P (head))
-	    TB_SET_HEAD (DECL_RESULT_FLD (head));
+	  if (head && TREE_CODE (head) == FUNCTION_DECL)
+	    TB_SET_HEAD (DECL_RESULT (head));
 	  else
 	    TB_WF;
 	  break;
 
 	case TB_ARGUMENTS:
-	  if (head && DECL_P (head))
+	  if (head && TREE_CODE (head) == FUNCTION_DECL)
 	    TB_SET_HEAD (DECL_ARGUMENTS (head));
 	  else
 	    TB_WF;
Index: print-tree.c
===================================================================
--- print-tree.c	(revision 212549)
+++ print-tree.c	(working copy)
@@ -512,10 +512,6 @@ print_node (FILE *file, const char *pref
 	  print_node_brief (file, "abstract_origin",
 			    DECL_ABSTRACT_ORIGIN (node), indent + 4);
 	}
-      if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
-	{
-	  print_node (file, "result", DECL_RESULT_FLD (node), indent + 4);
-	}
 
       lang_hooks.print_decl (file, node, indent);
 
@@ -542,6 +538,7 @@ print_node (FILE *file, const char *pref
 	  print_node (file, "arguments", DECL_ARGUMENTS (node), indent + 4);
 	  indent_to (file, indent + 4);
 	  dump_addr (file, "struct-function ", DECL_STRUCT_FUNCTION (node));
+	  print_node (file, "result", DECL_RESULT (node), indent + 4);
 	}
 
       if ((code == VAR_DECL || code == PARM_DECL)
Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 212549)
+++ lto/lto.c	(working copy)
@@ -775,11 +775,10 @@ mentions_vars_p_decl_non_common (tree t)
 {
   if (mentions_vars_p_decl_with_vis (t))
     return true;
-  CHECK_NO_VAR (DECL_RESULT_FLD (t));
   return false;
 }
 
-/* Check presence of pointers to decls in fields of a decl_non_common T.  */
+/* Check presence of pointers to decls in fields of a decl_function T.  */
 
 static bool
 mentions_vars_p_function (tree t)
@@ -787,6 +786,7 @@ mentions_vars_p_function (tree t)
   if (mentions_vars_p_decl_non_common (t))
     return true;
   CHECK_NO_VAR (DECL_ARGUMENTS (t));
+  CHECK_NO_VAR (DECL_RESULT (t));
   CHECK_NO_VAR (DECL_VINDEX (t));
   CHECK_VAR (DECL_FUNCTION_PERSONALITY (t));
   return false;
@@ -934,6 +934,7 @@ mentions_vars_p (tree t)
       return mentions_vars_p_decl_with_vis (t);
 
     case TYPE_DECL:
+      CHECK_NO_VAR (DECL_ORIGINAL_TYPE (t));
       return mentions_vars_p_decl_non_common (t);
 
     case FUNCTION_DECL:
@@ -2709,13 +2710,10 @@ lto_fixup_prevailing_decls (tree t)
 	{
 	  LTO_NO_PREVAIL (t->decl_with_vis.assembler_name);
 	}
-      if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
-	{
-	  LTO_NO_PREVAIL (DECL_RESULT_FLD (t));
-	}
       if (CODE_CONTAINS_STRUCT (code, TS_FUNCTION_DECL))
 	{
 	  LTO_NO_PREVAIL (DECL_ARGUMENTS (t));
+	  LTO_NO_PREVAIL (DECL_RESULT (t));
 	  LTO_SET_PREVAIL (DECL_FUNCTION_PERSONALITY (t));
 	  LTO_NO_PREVAIL (DECL_VINDEX (t));
 	}
Index: tree-streamer-out.c
===================================================================
--- tree-streamer-out.c	(revision 212549)
+++ tree-streamer-out.c	(working copy)
@@ -625,17 +625,6 @@ write_ts_decl_common_tree_pointers (stru
 
   if (TREE_CODE (expr) == VAR_DECL)
     stream_write_tree (ob, DECL_DEBUG_EXPR (expr), ref_p);
-}
-
-
-/* Write all pointer fields in the TS_DECL_NON_COMMON structure of
-   EXPR to output block OB.  If REF_P is true, write a reference to EXPR's
-   pointer fields.  */
-
-static void
-write_ts_decl_non_common_tree_pointers (struct output_block *ob, tree expr,
-				        bool ref_p)
-{
   if (TREE_CODE (expr) == TYPE_DECL)
     stream_write_tree (ob, DECL_ORIGINAL_TYPE (expr), ref_p);
 }
@@ -915,9 +904,6 @@ streamer_write_tree_body (struct output_
   if (CODE_CONTAINS_STRUCT (code, TS_DECL_COMMON))
     write_ts_decl_common_tree_pointers (ob, expr, ref_p);
 
-  if (CODE_CONTAINS_STRUCT (code, TS_DECL_NON_COMMON))
-    write_ts_decl_non_common_tree_pointers (ob, expr, ref_p);
-
   if (CODE_CONTAINS_STRUCT (code, TS_DECL_WITH_VIS))
     write_ts_decl_with_vis_tree_pointers (ob, expr, ref_p);
 
Index: lto-streamer-out.c
===================================================================
--- lto-streamer-out.c	(revision 212549)
+++ lto-streamer-out.c	(working copy)
@@ -139,6 +139,9 @@ tree_is_indexable (tree t)
      definition.  */
   if (TREE_CODE (t) == PARM_DECL || TREE_CODE (t) == RESULT_DECL)
     return variably_modified_type_p (TREE_TYPE (DECL_CONTEXT (t)), NULL_TREE);
+  /* IMPORTED_DECL is put into BLOCK and thus it never can be shared.  */
+  else if (TREE_CODE (t) == IMPORTED_DECL)
+    return false;
   else if (((TREE_CODE (t) == VAR_DECL && !TREE_STATIC (t))
 	    || TREE_CODE (t) == TYPE_DECL
 	    || TREE_CODE (t) == CONST_DECL
Index: fold-const.c
===================================================================
--- fold-const.c	(revision 212549)
+++ fold-const.c	(working copy)
@@ -14857,12 +14857,11 @@ fold_checksum_tree (const_tree expr, str
 	  fold_checksum_tree (DECL_ATTRIBUTES (expr), ctx, ht);
 	}
 
-      if (CODE_CONTAINS_STRUCT (TREE_CODE (expr), TS_DECL_NON_COMMON))
+      if (TREE_CODE (expr) == FUNCTION_DECL)
 	{
-	  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);
+	  fold_checksum_tree (DECL_VINDEX (expr), ctx, ht);
+	  fold_checksum_tree (DECL_RESULT (expr), ctx, ht);
+	  fold_checksum_tree (DECL_ARGUMENT (expr), ctx, ht);
 	}
       break;
     case tcc_type:
Index: objc/objc-act.h
===================================================================
--- objc/objc-act.h	(revision 212549)
+++ objc/objc-act.h	(working copy)
@@ -50,7 +50,7 @@ void objc_common_init_ts (void);
 #define METHOD_SEL_ARGS(DECL) \
   (INSTANCE_METHOD_OR_CLASS_METHOD_DECL_CHECK (DECL)->decl_common.size)
 #define METHOD_ADD_ARGS(DECL) \
-  (INSTANCE_METHOD_OR_CLASS_METHOD_DECL_CHECK (DECL)->decl_non_common.result)
+  (INSTANCE_METHOD_OR_CLASS_METHOD_DECL_CHECK (DECL)->decl_common.attributes)
 #define METHOD_ADD_ARGS_ELLIPSIS_P(DECL) \
   (INSTANCE_METHOD_OR_CLASS_METHOD_DECL_CHECK (DECL)->decl_common.lang_flag_0)
 #define METHOD_DEFINITION(DECL) \
@@ -85,7 +85,7 @@ void objc_common_init_ts (void);
 
 /* PROPERTY_SETTER_NAME is the identifier of the setter method.  */
 #define PROPERTY_SETTER_NAME(DECL) \
-   (PROPERTY_DECL_CHECK (DECL)->decl_non_common.result)
+   (PROPERTY_DECL_CHECK (DECL)->decl_common.size_unit)
 
 /* PROPERTY_READONLY can be 0 or 1.  */
 #define PROPERTY_READONLY(DECL) \
Index: tree-core.h
===================================================================
--- tree-core.h	(revision 212549)
+++ tree-core.h	(working copy)
@@ -1494,8 +1494,6 @@ struct GTY(()) tree_var_decl {
 
 struct GTY(()) tree_decl_non_common {
   struct tree_decl_with_vis common;
-  /* Almost all FE's use this.  */
-  tree result;
 };
 
 /* FUNCTION_DECL inherits from DECL_NON_COMMON because of the use of the
@@ -1510,6 +1508,8 @@ struct GTY(()) tree_function_decl {
 
   /* Arguments of the function.  */
   tree arguments;
+  /* Return value.  */
+  tree result;
   /* The personality function. Used for stack unwinding. */
   tree personality;
 
@@ -1563,7 +1563,7 @@ struct GTY(()) tree_translation_unit_dec
 
 struct GTY(()) tree_type_decl {
   struct tree_decl_non_common common;
-
+  tree original;
 };
 
 struct GTY ((chain_next ("%h.next"), chain_prev ("%h.prev"))) tree_statement_list_node

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

* Re: Move DECL_RESULT into function_decl
  2014-07-15 14:59 Move DECL_RESULT into function_decl Jan Hubicka
@ 2014-07-15 15:23 ` Jason Merrill
  2014-07-15 15:35   ` Jan Hubicka
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Merrill @ 2014-07-15 15:23 UTC (permalink / raw)
  To: Jan Hubicka, gcc-patches, rguenther

On 07/15/2014 10:19 AM, Jan Hubicka wrote:
> @@ -1722,7 +1722,7 @@ dump_ada_template (pretty_printer *buffe
>     /* DECL_VINDEX is DECL_TEMPLATE_INSTANTIATIONS in this context.  */
>     tree inst = DECL_VINDEX (t);
>     /* DECL_RESULT_FLD is DECL_TEMPLATE_RESULT in this context.  */
> -  tree result = DECL_RESULT_FLD (t);
> +  tree result = DECL_RESULT (t);

This looks like it was broken by your last patch, judging from the 
comments: DECL_VINDEX no longer corresponds to 
DECL_TEMPLATE_INSTANTIATIONS, and DECL_RESULT no longer corresponds to 
DECL_TEMPLATE_RESULT.

Jason

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

* Re: Move DECL_RESULT into function_decl
  2014-07-15 15:23 ` Jason Merrill
@ 2014-07-15 15:35   ` Jan Hubicka
  2014-07-15 18:38     ` Jason Merrill
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Hubicka @ 2014-07-15 15:35 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Jan Hubicka, gcc-patches, rguenther

> On 07/15/2014 10:19 AM, Jan Hubicka wrote:
> >@@ -1722,7 +1722,7 @@ dump_ada_template (pretty_printer *buffe
> >    /* DECL_VINDEX is DECL_TEMPLATE_INSTANTIATIONS in this context.  */
> >    tree inst = DECL_VINDEX (t);
> >    /* DECL_RESULT_FLD is DECL_TEMPLATE_RESULT in this context.  */
> >-  tree result = DECL_RESULT_FLD (t);
> >+  tree result = DECL_RESULT (t);
> 
> This looks like it was broken by your last patch, judging from the
> comments: DECL_VINDEX no longer corresponds to
> DECL_TEMPLATE_INSTANTIATIONS, and DECL_RESULT no longer corresponds
> to DECL_TEMPLATE_RESULT.

Yep, you are right. I was looking into this, too.  I think dump_ada_template
should be mvoed into C++ FE somehow because it deals with C++ trees.
What would be most appropriate way to do so?

Honza
> 
> Jason

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

* Re: Move DECL_RESULT into function_decl
  2014-07-15 15:35   ` Jan Hubicka
@ 2014-07-15 18:38     ` Jason Merrill
  2014-07-16 11:02       ` Jan Hubicka
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Merrill @ 2014-07-15 18:38 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches, rguenther

On 07/15/2014 11:29 AM, Jan Hubicka wrote:
> Yep, you are right. I was looking into this, too.  I think dump_ada_template
> should be moved into C++ FE somehow because it deals with C++ trees.
> What would be most appropriate way to do so?

I suppose we could pass a pointer to it into dump_ada_specs like we do 
for cpp_check.

Jason

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

* Re: Move DECL_RESULT into function_decl
  2014-07-15 18:38     ` Jason Merrill
@ 2014-07-16 11:02       ` Jan Hubicka
  0 siblings, 0 replies; 5+ messages in thread
From: Jan Hubicka @ 2014-07-16 11:02 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Jan Hubicka, gcc-patches, rguenther

> On 07/15/2014 11:29 AM, Jan Hubicka wrote:
> >Yep, you are right. I was looking into this, too.  I think dump_ada_template
> >should be moved into C++ FE somehow because it deals with C++ trees.
> >What would be most appropriate way to do so?
> 
> I suppose we could pass a pointer to it into dump_ada_specs like we
> do for cpp_check.

That sounds good.  I will prepare patch and then prepare updated version of the RESULT_DECL
patch - I reused DECL_ATTIBUTES of INSTANCE_METHOD and CLASS_METHOD. It seems to mostly work
except for -Wuninitialized where we access these by accident.  It is not hard to avoid this,
but I think it may be better to turn those into custom decl structures - I plan to get rid of
the ATTIBUTES pointer incrementally too by on-side hash that allows faster attribute
lookups. I also plan to move DECL_SIZE/DECL_SIZE_UNIT into separate datastructure as discussed
with Richard on IRC yesterday.
Basically we can have size descriptors containing size, size unit and mode that are off-tree
with pointers from both types and decls.  This way we will avoid duplicating this info all
the time.

I sadly do not know how to turn Obj-C tree nodes into custom layout because
there are no prior cases in Obj-C FE and there is obj-c++/c/objc/c++ code
sharing that makes this a bit twisty.  Any help would be welcome.

Honza
> 
> Jason

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

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

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-15 14:59 Move DECL_RESULT into function_decl Jan Hubicka
2014-07-15 15:23 ` Jason Merrill
2014-07-15 15:35   ` Jan Hubicka
2014-07-15 18:38     ` Jason Merrill
2014-07-16 11:02       ` 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).