Patchwork Stream TYPE_FINAL_P and DECL_FINAL_P to LTO

login
register
mail settings
Submitter Jan Hubicka
Date Aug. 25, 2013, 3:23 p.m.
Message ID <20130825152329.GB29339@kam.mff.cuni.cz>
Download mbox | patch
Permalink /patch/269707/
State New
Headers show

Comments

Jan Hubicka - Aug. 25, 2013, 3:23 p.m.
Hi,
this patch adds code to stream DECL_FINAL_P/TYPE_FINAL_P into LTO so we can
use it after the ipa-devirt code at LTO time is merged in.
(http://gcc.gnu.org/ml/gcc-patches/2013-08/msg01007.html)

Bootstrapped/regtested x86_64-linux, OK?

Honza

	* lto-streamer-out.c (hash_tree): Add streaming of DECL_FINAL_P
	and TYPE_FINAL_P
	* lto/lto.c (compare_tree_sccs_1): Add TYPE_FINAL_P and DECL_FINAL_P
	* tree-streamer-out.c (pack_ts_decl_with_vis_value_fields):
	Add DECL_FINAL_P.
	(pack_ts_type_common_value_fields): Add TYPE_FINAL_P.
	* tree-streamer-in.c (unpack_ts_decl_with_vis_value_fields):
	Add DECL_FINAL_P.
	(unpack_ts_type_common_value_fields): Add TYPE_FINAL_P.
Richard Guenther - Aug. 27, 2013, 11:33 a.m.
On Sun, Aug 25, 2013 at 5:23 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
> Hi,
> this patch adds code to stream DECL_FINAL_P/TYPE_FINAL_P into LTO so we can
> use it after the ipa-devirt code at LTO time is merged in.
> (http://gcc.gnu.org/ml/gcc-patches/2013-08/msg01007.html)
>
> Bootstrapped/regtested x86_64-linux, OK?
>
> Honza
>
>         * lto-streamer-out.c (hash_tree): Add streaming of DECL_FINAL_P
>         and TYPE_FINAL_P
>         * lto/lto.c (compare_tree_sccs_1): Add TYPE_FINAL_P and DECL_FINAL_P
>         * tree-streamer-out.c (pack_ts_decl_with_vis_value_fields):
>         Add DECL_FINAL_P.
>         (pack_ts_type_common_value_fields): Add TYPE_FINAL_P.
>         * tree-streamer-in.c (unpack_ts_decl_with_vis_value_fields):
>         Add DECL_FINAL_P.
>         (unpack_ts_type_common_value_fields): Add TYPE_FINAL_P.
>
> Index: lto-streamer-out.c
> ===================================================================
> --- lto-streamer-out.c  (revision 201974)
> +++ lto-streamer-out.c  (working copy)
> @@ -798,6 +798,9 @@ hash_tree (struct streamer_tree_cache_d
>                                             v);
>           v = iterative_hash_host_wide_int (DECL_TLS_MODEL (t), v);
>         }
> +      if (TREE_CODE (t) == FUNCTION_DECL)
> +       v = iterative_hash_host_wide_int (DECL_FINAL_P (t),
> +                                         v);
>        if (VAR_OR_FUNCTION_DECL_P (t))
>         v = iterative_hash_host_wide_int (DECL_INIT_PRIORITY (t), v);
>      }
> @@ -838,7 +841,10 @@ hash_tree (struct streamer_tree_cache_d
>                                         | (TYPE_USER_ALIGN (t) << 5)
>                                         | (TYPE_READONLY (t) << 6), v);
>        if (RECORD_OR_UNION_TYPE_P (t))
> -       v = iterative_hash_host_wide_int (TYPE_TRANSPARENT_AGGR (t), v);
> +       {
> +         v = iterative_hash_host_wide_int (TYPE_TRANSPARENT_AGGR (t), v);
> +         v = iterative_hash_host_wide_int (TYPE_FINAL_P (t), v);

please use | (TYPE_FINAL_P (t) << 1) to speed this up like in other cases.

Otherwise ok.

Thanks,
Richard.

> +       }
>        else if (code == ARRAY_TYPE)
>         v = iterative_hash_host_wide_int (TYPE_NONALIASED_COMPONENT (t), v);
>        v = iterative_hash_host_wide_int (TYPE_PRECISION (t), v);
> Index: lto/lto.c
> ===================================================================
> --- lto/lto.c   (revision 201974)
> +++ lto/lto.c   (working copy)
> @@ -1892,6 +1892,7 @@ compare_tree_sccs_1 (tree t1, tree t2, t
>        compare_values (DECL_DISREGARD_INLINE_LIMITS);
>        compare_values (DECL_PURE_P);
>        compare_values (DECL_LOOPING_CONST_OR_PURE_P);
> +      compare_values (DECL_FINAL_P);
>        if (DECL_BUILT_IN_CLASS (t1) != NOT_BUILT_IN)
>         compare_values (DECL_FUNCTION_CODE);
>        if (DECL_STATIC_DESTRUCTOR (t1))
> @@ -1905,7 +1906,10 @@ compare_tree_sccs_1 (tree t1, tree t2, t
>        compare_values (TYPE_NO_FORCE_BLK);
>        compare_values (TYPE_NEEDS_CONSTRUCTING);
>        if (RECORD_OR_UNION_TYPE_P (t1))
> -       compare_values (TYPE_TRANSPARENT_AGGR);
> +       {
> +         compare_values (TYPE_TRANSPARENT_AGGR);
> +         compare_values (TYPE_FINAL_P);
> +       }
>        else if (code == ARRAY_TYPE)
>         compare_values (TYPE_NONALIASED_COMPONENT);
>        compare_values (TYPE_PACKED);
> Index: tree-streamer-out.c
> ===================================================================
> --- tree-streamer-out.c (revision 201974)
> +++ tree-streamer-out.c (working copy)
> @@ -242,6 +242,8 @@ pack_ts_decl_with_vis_value_fields (stru
>        bp_pack_value (bp, DECL_TLS_MODEL (expr),  3);
>      }
>
> +  if (TREE_CODE (expr) == FUNCTION_DECL)
> +    bp_pack_value (bp, DECL_FINAL_P (expr), 1);
>    if (VAR_OR_FUNCTION_DECL_P (expr))
>      bp_pack_var_len_unsigned (bp, DECL_INIT_PRIORITY (expr));
>  }
> @@ -293,7 +295,10 @@ pack_ts_type_common_value_fields (struct
>    bp_pack_value (bp, TYPE_NO_FORCE_BLK (expr), 1);
>    bp_pack_value (bp, TYPE_NEEDS_CONSTRUCTING (expr), 1);
>    if (RECORD_OR_UNION_TYPE_P (expr))
> -    bp_pack_value (bp, TYPE_TRANSPARENT_AGGR (expr), 1);
> +    {
> +      bp_pack_value (bp, TYPE_TRANSPARENT_AGGR (expr), 1);
> +      bp_pack_value (bp, TYPE_FINAL_P (expr), 1);
> +    }
>    else if (TREE_CODE (expr) == ARRAY_TYPE)
>      bp_pack_value (bp, TYPE_NONALIASED_COMPONENT (expr), 1);
>    bp_pack_value (bp, TYPE_PACKED (expr), 1);
> Index: tree-streamer-in.c
> ===================================================================
> --- tree-streamer-in.c  (revision 201974)
> +++ tree-streamer-in.c  (working copy)
> @@ -275,6 +275,8 @@ unpack_ts_decl_with_vis_value_fields (st
>        DECL_TLS_MODEL (expr) = (enum tls_model) bp_unpack_value (bp,  3);
>      }
>
> +  if (TREE_CODE (expr) == FUNCTION_DECL)
> +    DECL_FINAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
>    if (VAR_OR_FUNCTION_DECL_P (expr))
>      {
>        priority_type p;
> @@ -346,7 +348,10 @@ unpack_ts_type_common_value_fields (stru
>    TYPE_NO_FORCE_BLK (expr) = (unsigned) bp_unpack_value (bp, 1);
>    TYPE_NEEDS_CONSTRUCTING (expr) = (unsigned) bp_unpack_value (bp, 1);
>    if (RECORD_OR_UNION_TYPE_P (expr))
> -    TYPE_TRANSPARENT_AGGR (expr) = (unsigned) bp_unpack_value (bp, 1);
> +    {
> +      TYPE_TRANSPARENT_AGGR (expr) = (unsigned) bp_unpack_value (bp, 1);
> +      TYPE_FINAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
> +    }
>    else if (TREE_CODE (expr) == ARRAY_TYPE)
>      TYPE_NONALIASED_COMPONENT (expr) = (unsigned) bp_unpack_value (bp, 1);
>    TYPE_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1);
Jan Hubicka - Aug. 27, 2013, 12:02 p.m.
> > +         v = iterative_hash_host_wide_int (TYPE_TRANSPARENT_AGGR (t), v);
> > +         v = iterative_hash_host_wide_int (TYPE_FINAL_P (t), v);
> 
> please use | (TYPE_FINAL_P (t) << 1) to speed this up like in other cases.

Thank you, I missed that TYPE_TRANSPARENT_AGGR is also flag.
I will update the patch also adding the cxx_constructor/cxx_destructor flags
that landed mainline in meantime and commit. (those go basically whenever
DECL_FINAL_P goes)

Honza

Patch

Index: lto-streamer-out.c
===================================================================
--- lto-streamer-out.c	(revision 201974)
+++ lto-streamer-out.c	(working copy)
@@ -798,6 +798,9 @@  hash_tree (struct streamer_tree_cache_d
 					    v);
 	  v = iterative_hash_host_wide_int (DECL_TLS_MODEL (t), v);
 	}
+      if (TREE_CODE (t) == FUNCTION_DECL)
+	v = iterative_hash_host_wide_int (DECL_FINAL_P (t),
+					  v);
       if (VAR_OR_FUNCTION_DECL_P (t))
 	v = iterative_hash_host_wide_int (DECL_INIT_PRIORITY (t), v);
     }
@@ -838,7 +841,10 @@  hash_tree (struct streamer_tree_cache_d
 					| (TYPE_USER_ALIGN (t) << 5)
 					| (TYPE_READONLY (t) << 6), v);
       if (RECORD_OR_UNION_TYPE_P (t))
-	v = iterative_hash_host_wide_int (TYPE_TRANSPARENT_AGGR (t), v);
+	{
+	  v = iterative_hash_host_wide_int (TYPE_TRANSPARENT_AGGR (t), v);
+	  v = iterative_hash_host_wide_int (TYPE_FINAL_P (t), v);
+	}
       else if (code == ARRAY_TYPE)
 	v = iterative_hash_host_wide_int (TYPE_NONALIASED_COMPONENT (t), v);
       v = iterative_hash_host_wide_int (TYPE_PRECISION (t), v);
Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 201974)
+++ lto/lto.c	(working copy)
@@ -1892,6 +1892,7 @@  compare_tree_sccs_1 (tree t1, tree t2, t
       compare_values (DECL_DISREGARD_INLINE_LIMITS);
       compare_values (DECL_PURE_P);
       compare_values (DECL_LOOPING_CONST_OR_PURE_P);
+      compare_values (DECL_FINAL_P);
       if (DECL_BUILT_IN_CLASS (t1) != NOT_BUILT_IN)
 	compare_values (DECL_FUNCTION_CODE);
       if (DECL_STATIC_DESTRUCTOR (t1))
@@ -1905,7 +1906,10 @@  compare_tree_sccs_1 (tree t1, tree t2, t
       compare_values (TYPE_NO_FORCE_BLK);
       compare_values (TYPE_NEEDS_CONSTRUCTING);
       if (RECORD_OR_UNION_TYPE_P (t1))
-	compare_values (TYPE_TRANSPARENT_AGGR);
+	{
+	  compare_values (TYPE_TRANSPARENT_AGGR);
+	  compare_values (TYPE_FINAL_P);
+	}
       else if (code == ARRAY_TYPE)
 	compare_values (TYPE_NONALIASED_COMPONENT);
       compare_values (TYPE_PACKED);
Index: tree-streamer-out.c
===================================================================
--- tree-streamer-out.c	(revision 201974)
+++ tree-streamer-out.c	(working copy)
@@ -242,6 +242,8 @@  pack_ts_decl_with_vis_value_fields (stru
       bp_pack_value (bp, DECL_TLS_MODEL (expr),  3);
     }
 
+  if (TREE_CODE (expr) == FUNCTION_DECL)
+    bp_pack_value (bp, DECL_FINAL_P (expr), 1);
   if (VAR_OR_FUNCTION_DECL_P (expr))
     bp_pack_var_len_unsigned (bp, DECL_INIT_PRIORITY (expr));
 }
@@ -293,7 +295,10 @@  pack_ts_type_common_value_fields (struct
   bp_pack_value (bp, TYPE_NO_FORCE_BLK (expr), 1);
   bp_pack_value (bp, TYPE_NEEDS_CONSTRUCTING (expr), 1);
   if (RECORD_OR_UNION_TYPE_P (expr))
-    bp_pack_value (bp, TYPE_TRANSPARENT_AGGR (expr), 1);
+    {
+      bp_pack_value (bp, TYPE_TRANSPARENT_AGGR (expr), 1);
+      bp_pack_value (bp, TYPE_FINAL_P (expr), 1);
+    }
   else if (TREE_CODE (expr) == ARRAY_TYPE)
     bp_pack_value (bp, TYPE_NONALIASED_COMPONENT (expr), 1);
   bp_pack_value (bp, TYPE_PACKED (expr), 1);
Index: tree-streamer-in.c
===================================================================
--- tree-streamer-in.c	(revision 201974)
+++ tree-streamer-in.c	(working copy)
@@ -275,6 +275,8 @@  unpack_ts_decl_with_vis_value_fields (st
       DECL_TLS_MODEL (expr) = (enum tls_model) bp_unpack_value (bp,  3);
     }
 
+  if (TREE_CODE (expr) == FUNCTION_DECL)
+    DECL_FINAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
   if (VAR_OR_FUNCTION_DECL_P (expr))
     {
       priority_type p;
@@ -346,7 +348,10 @@  unpack_ts_type_common_value_fields (stru
   TYPE_NO_FORCE_BLK (expr) = (unsigned) bp_unpack_value (bp, 1);
   TYPE_NEEDS_CONSTRUCTING (expr) = (unsigned) bp_unpack_value (bp, 1);
   if (RECORD_OR_UNION_TYPE_P (expr))
-    TYPE_TRANSPARENT_AGGR (expr) = (unsigned) bp_unpack_value (bp, 1);
+    {
+      TYPE_TRANSPARENT_AGGR (expr) = (unsigned) bp_unpack_value (bp, 1);
+      TYPE_FINAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
+    }
   else if (TREE_CODE (expr) == ARRAY_TYPE)
     TYPE_NONALIASED_COMPONENT (expr) = (unsigned) bp_unpack_value (bp, 1);
   TYPE_PACKED (expr) = (unsigned) bp_unpack_value (bp, 1);