OSDN Git Service

Uniquization of constants at the Tree level
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 28 Apr 2010 19:11:50 +0000 (19:11 +0000)
committerMasaki Muranaka <monaka@monami-software.com>
Sun, 23 May 2010 05:36:52 +0000 (14:36 +0900)
* tree.h (DECL_IN_CONSTANT_POOL): New macro
(tree_decl_with_vis): Add in_constant_pool bit, move shadowed_for_var_p
bit to the end.
(tree_output_constant_def): Declare.
* gimplify.c (gimplify_init_constructor): When using block copy,
uniquize the constant constructor on the RHS.
* lto-streamer-in.c (unpack_ts_decl_with_vis_value_fields): Deal
with DECL_IN_CONSTANT_POOL flag.
* lto-streamer-out.c (pack_ts_decl_with_vis_value_fields): Likewise.
* varasm.c (make_decl_rtl): Deal with variables belonging to the
global constant pool.
(assemble_variable): Deal with symbols belonging to the tree constant
pool.
(get_constant_section): Add ALIGN parameter and simplify.
(build_constant_desc): Build a VAR_DECL and attach it to the symbol.
(assemble_constant_contents): Use the expression of the VAR_DECL.
(output_constant_def_contents): Use the alignment of the VAR_DECL.
(tree_output_constant_def): New global function.
(mark_constant): Use the expression of the VAR_DECL.
(place_block_symbol): Use the alignment of the VAR_DECL and the size
of its expression.
(output_object_block): Likewise and assemble the expression.
ada/
* gcc-interface/trans.c (gnat_gimplify_expr) <ADDR_EXPR>: Uniquize
constant constructors before taking their address.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158838 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/trans.c
gcc/testsuite/ChangeLog
gcc/tree.h

index 3bb1c74..a5d3493 100644 (file)
@@ -1,5 +1,31 @@
 2010-04-28  Eric Botcazou  <ebotcazou@adacore.com>
 
 2010-04-28  Eric Botcazou  <ebotcazou@adacore.com>
 
+       Uniquization of constants at the Tree level
+       * tree.h (DECL_IN_CONSTANT_POOL): New macro
+       (tree_decl_with_vis): Add in_constant_pool bit, move shadowed_for_var_p
+       bit to the end.
+       (tree_output_constant_def): Declare.
+       * gimplify.c (gimplify_init_constructor): When using block copy,
+       uniquize the constant constructor on the RHS.
+       * lto-streamer-in.c (unpack_ts_decl_with_vis_value_fields): Deal
+       with DECL_IN_CONSTANT_POOL flag.
+       * lto-streamer-out.c (pack_ts_decl_with_vis_value_fields): Likewise.
+       * varasm.c (make_decl_rtl): Deal with variables belonging to the
+       global constant pool.
+       (assemble_variable): Deal with symbols belonging to the tree constant
+       pool.
+       (get_constant_section): Add ALIGN parameter and simplify.
+       (build_constant_desc): Build a VAR_DECL and attach it to the symbol.
+       (assemble_constant_contents): Use the expression of the VAR_DECL.
+       (output_constant_def_contents): Use the alignment of the VAR_DECL.
+       (tree_output_constant_def): New global function.
+       (mark_constant): Use the expression of the VAR_DECL.
+       (place_block_symbol): Use the alignment of the VAR_DECL and the size
+       of its expression.
+       (output_object_block): Likewise and assemble the expression.
+
+2010-04-28  Eric Botcazou  <ebotcazou@adacore.com>
+
        * lto-streamer.c [LTO_STREAMER_DEBUG] (tree_htab, tree_hash_entry,
        hash_tree, eq_tree): New tree hash table.
        (lto_streamer_init) [LTO_STREAMER_DEBUG]: Initialize it.
        * lto-streamer.c [LTO_STREAMER_DEBUG] (tree_htab, tree_hash_entry,
        hash_tree, eq_tree): New tree hash table.
        (lto_streamer_init) [LTO_STREAMER_DEBUG]: Initialize it.
index c5dac66..6303c39 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/trans.c (gnat_gimplify_expr) <ADDR_EXPR>: Uniquize
+       constant constructors before taking their address.
+
 2010-04-25  Eric Botcazou  <ebotcazou@adacore.com>
 
        * exp_dbug.ads: Fix outdated description.  Mention link between XVS
 2010-04-25  Eric Botcazou  <ebotcazou@adacore.com>
 
        * exp_dbug.ads: Fix outdated description.  Mention link between XVS
index 2e35a1f..25521a9 100644 (file)
@@ -6043,16 +6043,8 @@ gnat_gimplify_expr (tree *expr_p, gimple_seq *pre_p,
             the reference is in an elaboration procedure.  */
          if (TREE_CONSTANT (op))
            {
             the reference is in an elaboration procedure.  */
          if (TREE_CONSTANT (op))
            {
-             tree new_var = create_tmp_var_raw (TREE_TYPE (op), "C");
-             TREE_ADDRESSABLE (new_var) = 1;
-             gimple_add_tmp_var (new_var);
-
-             TREE_READONLY (new_var) = 1;
-             TREE_STATIC (new_var) = 1;
-             DECL_INITIAL (new_var) = op;
-
-             TREE_OPERAND (expr, 0) = new_var;
-             recompute_tree_invariant_for_addr_expr (expr);
+             tree addr = build_fold_addr_expr (tree_output_constant_def (op));
+             *expr_p = fold_convert (TREE_TYPE (expr), addr);
            }
 
          /* Otherwise explicitly create the local temporary.  That's required
            }
 
          /* Otherwise explicitly create the local temporary.  That's required
index 753b90d..7062381 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-28  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.dg/const-uniq-1.c: New test.
+       * gcc.dg/lto/const-uniq_[01].c: Likewise.
+
 2010-04-28  Xinliang David Li  <davidxl@google.com>
 
        * gcc.dg/uninit-pred-2_b.c: New test.
 2010-04-28  Xinliang David Li  <davidxl@google.com>
 
        * gcc.dg/uninit-pred-2_b.c: New test.
index 6954e5a..99bf29b 100644 (file)
@@ -2963,6 +2963,11 @@ struct GTY(()) tree_parm_decl {
 #define DECL_IN_TEXT_SECTION(NODE) \
   (VAR_DECL_CHECK (NODE)->decl_with_vis.in_text_section)
 
 #define DECL_IN_TEXT_SECTION(NODE) \
   (VAR_DECL_CHECK (NODE)->decl_with_vis.in_text_section)
 
+/* In a VAR_DECL that's static,
+   nonzero if it belongs to the global constant pool.  */
+#define DECL_IN_CONSTANT_POOL(NODE) \
+  (VAR_DECL_CHECK (NODE)->decl_with_vis.in_constant_pool)
+
 /* Nonzero for a given ..._DECL node means that this node should be
    put in .common, if possible.  If a DECL_INITIAL is given, and it
    is not error_mark_node, then the decl cannot be put in .common.  */
 /* Nonzero for a given ..._DECL node means that this node should be
    put in .common, if possible.  If a DECL_INITIAL is given, and it
    is not error_mark_node, then the decl cannot be put in .common.  */
@@ -3102,9 +3107,8 @@ struct GTY(()) tree_decl_with_vis {
  unsigned thread_local : 1;
  unsigned common_flag : 1;
  unsigned in_text_section : 1;
  unsigned thread_local : 1;
  unsigned common_flag : 1;
  unsigned in_text_section : 1;
+ unsigned in_constant_pool : 1;
  unsigned dllimport_flag : 1;
  unsigned dllimport_flag : 1;
- /* Used by C++.  Might become a generic decl flag.  */
- unsigned shadowed_for_var_p : 1;
  /* Don't belong to VAR_DECL exclusively.  */
  unsigned weak_flag : 1;
 
  /* Don't belong to VAR_DECL exclusively.  */
  unsigned weak_flag : 1;
 
@@ -3117,7 +3121,9 @@ struct GTY(()) tree_decl_with_vis {
 
  /* Belong to FUNCTION_DECL exclusively.  */
  unsigned init_priority_p : 1;
 
  /* Belong to FUNCTION_DECL exclusively.  */
  unsigned init_priority_p : 1;
- /* 15 unused bits. */
+ /* Used by C++ only.  Might become a generic decl flag.  */
+ unsigned shadowed_for_var_p : 1;
+ /* 14 unused bits. */
 };
 
 extern tree decl_debug_expr_lookup (tree);
 };
 
 extern tree decl_debug_expr_lookup (tree);
@@ -5184,6 +5190,7 @@ extern void internal_reference_types (void);
 extern unsigned int update_alignment_for_field (record_layout_info, tree,
                                                 unsigned int);
 /* varasm.c */
 extern unsigned int update_alignment_for_field (record_layout_info, tree,
                                                 unsigned int);
 /* varasm.c */
+extern tree tree_output_constant_def (tree);
 extern void make_decl_rtl (tree);
 extern rtx make_decl_rtl_for_debug (tree);
 extern void make_decl_one_only (tree, tree);
 extern void make_decl_rtl (tree);
 extern rtx make_decl_rtl_for_debug (tree);
 extern void make_decl_one_only (tree, tree);