]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-core.h: Document use of deprecated_flag in SSA_NAME.
authorRichard Biener <rguenther@suse.de>
Wed, 29 Aug 2018 14:12:25 +0000 (14:12 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 29 Aug 2018 14:12:25 +0000 (14:12 +0000)
2018-08-29  Richard Biener  <rguenther@suse.de>

* tree-core.h: Document use of deprecated_flag in SSA_NAME.
* tree.h (SSA_NAME_POINTS_TO_READONLY_MEMORY): Define.
* tree-into-ssa.c (pass_build_ssa::execute): Initialize
function parameters SSA_NAME_POINTS_TO_READONLY_MEMORY from fnspec.
* tree-ssa-sccvn.c (const_parms, init_const_parms): Remove.
(vn_reference_lookup_3): Remove use of const_parms.
(free_rpo_vn): Do not free const_parms.
(do_rpo_vn): Do not call init_const_parms.
* tree-ssa-alias.c (refs_may_alias_p_1): Honor
SSA_NAME_POINTS_TO_READONLY_MEMORY.
(call_may_clobber_ref_p_1): Likewise.

From-SVN: r263958

gcc/ChangeLog
gcc/tree-core.h
gcc/tree-into-ssa.c
gcc/tree-ssa-alias.c
gcc/tree-ssa-sccvn.c
gcc/tree.h

index a8a9b2df206d66a2e34b0b1ba907abfe4c1b5ef4..02a7b94d1f210847e1ea5229edbe5eca022ac0ec 100644 (file)
@@ -1,3 +1,17 @@
+2018-08-29  Richard Biener  <rguenther@suse.de>
+
+       * tree-core.h: Document use of deprecated_flag in SSA_NAME.
+       * tree.h (SSA_NAME_POINTS_TO_READONLY_MEMORY): Define.
+       * tree-into-ssa.c (pass_build_ssa::execute): Initialize
+       function parameters SSA_NAME_POINTS_TO_READONLY_MEMORY from fnspec.
+       * tree-ssa-sccvn.c (const_parms, init_const_parms): Remove.
+       (vn_reference_lookup_3): Remove use of const_parms.
+       (free_rpo_vn): Do not free const_parms.
+       (do_rpo_vn): Do not call init_const_parms.
+       * tree-ssa-alias.c (refs_may_alias_p_1): Honor
+       SSA_NAME_POINTS_TO_READONLY_MEMORY.
+       (call_may_clobber_ref_p_1): Likewise.
+
 2018-08-29  Alexander Monakov  <amonakov@ispras.ru>
 
        PR other/86726
index f98cfefef94cff7427a5e744c3bab2c8bff4ddb3..dee27f89dec8ebff3bceba5efe5d262f05223760 100644 (file)
@@ -1238,6 +1238,9 @@ struct GTY(()) tree_base {
        IDENTIFIER_TRANSPARENT_ALIAS in
            IDENTIFIER_NODE
 
+       SSA_NAME_POINTS_TO_READONLY_MEMORY in
+          SSA_NAME
+
    visited:
 
        TREE_VISITED in
index f4af33c1303a9153d8a1ee0d7bd58ddf954d86a5..cdae75d1aae5363dac4d9987c999802959f23f7e 100644 (file)
@@ -2490,6 +2490,28 @@ pass_build_ssa::execute (function *fun)
        SET_SSA_NAME_VAR_OR_IDENTIFIER (name, DECL_NAME (decl));
     }
 
+  /* Initialize SSA_NAME_POINTS_TO_READONLY_MEMORY.  */
+  tree fnspec = lookup_attribute ("fn spec",
+                                 TYPE_ATTRIBUTES (TREE_TYPE (fun->decl)));
+  if (fnspec)
+    {
+      fnspec = TREE_VALUE (TREE_VALUE (fnspec));
+      unsigned i = 1;
+      for (tree arg = DECL_ARGUMENTS (cfun->decl);
+          arg; arg = DECL_CHAIN (arg), ++i)
+       {
+         if (i >= (unsigned) TREE_STRING_LENGTH (fnspec))
+           break;
+         if (TREE_STRING_POINTER (fnspec)[i]  == 'R'
+             || TREE_STRING_POINTER (fnspec)[i] == 'r')
+           {
+             tree name = ssa_default_def (fun, arg);
+             if (name)
+               SSA_NAME_POINTS_TO_READONLY_MEMORY (name) = 1;
+           }
+       }
+    }
+
   return 0;
 }
 
index e6e21e8773c1cc0986796a2781f7c52674791b83..6efe4c3a4a799b127a3c54958c871b1334f25baf 100644 (file)
@@ -1483,6 +1483,16 @@ refs_may_alias_p_1 (ao_ref *ref1, ao_ref *ref2, bool tbaa_p)
                                 ao_ref_alias_set (ref2)))
     return false;
 
+  /* If the reference is based on a pointer that points to memory
+     that may not be written to then the other reference cannot possibly
+     clobber it.  */
+  if ((TREE_CODE (TREE_OPERAND (base2, 0)) == SSA_NAME
+       && SSA_NAME_POINTS_TO_READONLY_MEMORY (TREE_OPERAND (base2, 0)))
+      || (ind1_p
+         && TREE_CODE (TREE_OPERAND (base1, 0)) == SSA_NAME
+         && SSA_NAME_POINTS_TO_READONLY_MEMORY (TREE_OPERAND (base1, 0))))
+    return false;
+
   /* Dispatch to the pointer-vs-decl or pointer-vs-pointer disambiguators.  */
   if (var1_p && ind2_p)
     return indirect_ref_may_alias_decl_p (ref2->ref, base2,
@@ -1991,6 +2001,14 @@ call_may_clobber_ref_p_1 (gcall *call, ao_ref *ref)
          || !is_global_var (base)))
     return false;
 
+  /* If the reference is based on a pointer that points to memory
+     that may not be written to then the call cannot possibly clobber it.  */
+  if ((TREE_CODE (base) == MEM_REF
+       || TREE_CODE (base) == TARGET_MEM_REF)
+      && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME
+      && SSA_NAME_POINTS_TO_READONLY_MEMORY (TREE_OPERAND (base, 0)))
+    return false;
+
   callee = gimple_call_fndecl (call);
 
   /* Handle those builtin functions explicitly that do not act as
index 04b3808feff42f863acfeb7cd2a55358b2a9ad0a..e3b9f1c7dbc233e2ae612e282e6fd22c243e2081 100644 (file)
@@ -133,7 +133,6 @@ along with GCC; see the file COPYING3.  If not see
 static tree *last_vuse_ptr;
 static vn_lookup_kind vn_walk_kind;
 static vn_lookup_kind default_vn_walk_kind;
-bitmap const_parms;
 
 /* vn_nary_op hashtable helpers.  */
 
@@ -1863,18 +1862,6 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_,
   bool lhs_ref_ok = false;
   poly_int64 copy_size;
 
-  /* If the reference is based on a parameter that was determined as
-     pointing to readonly memory it doesn't change.  */
-  if (TREE_CODE (base) == MEM_REF
-      && TREE_CODE (TREE_OPERAND (base, 0)) == SSA_NAME
-      && SSA_NAME_IS_DEFAULT_DEF (TREE_OPERAND (base, 0))
-      && bitmap_bit_p (const_parms,
-                      SSA_NAME_VERSION (TREE_OPERAND (base, 0))))
-    {
-      *disambiguate_only = true;
-      return NULL;
-    }
-
   /* First try to disambiguate after value-replacing in the definitions LHS.  */
   if (is_gimple_assign (def_stmt))
     {
@@ -4514,37 +4501,6 @@ set_hashtable_value_ids (void)
     set_value_id_for_result (vr->result, &vr->value_id);
 }
 
-
-/* Allocate and initialize CONST_PARAMS, a bitmap of parameter default defs
-   we know point to readonly memory.  */
-
-static void
-init_const_parms ()
-{
-  /* Collect pointers we know point to readonly memory.  */
-  const_parms = BITMAP_ALLOC (NULL);
-  tree fnspec = lookup_attribute ("fn spec",
-                                 TYPE_ATTRIBUTES (TREE_TYPE (cfun->decl)));
-  if (fnspec)
-    {
-      fnspec = TREE_VALUE (TREE_VALUE (fnspec));
-      unsigned i = 1;
-      for (tree arg = DECL_ARGUMENTS (cfun->decl);
-          arg; arg = DECL_CHAIN (arg), ++i)
-       {
-         if (i >= (unsigned) TREE_STRING_LENGTH (fnspec))
-           break;
-         if (TREE_STRING_POINTER (fnspec)[i]  == 'R'
-             || TREE_STRING_POINTER (fnspec)[i] == 'r')
-           {
-             tree name = ssa_default_def (cfun, arg);
-             if (name)
-               bitmap_set_bit (const_parms, SSA_NAME_VERSION (name));
-           }
-       }
-    }
-}
-
 /* Return the maximum value id we have ever seen.  */
 
 unsigned int
@@ -5606,8 +5562,6 @@ free_rpo_vn (void)
   obstack_free (&vn_tables_obstack, NULL);
   obstack_free (&vn_tables_insert_obstack, NULL);
 
-  BITMAP_FREE (const_parms);
-
   vn_ssa_aux_iterator_type it;
   vn_ssa_aux_t info;
   FOR_EACH_HASH_TABLE_ELEMENT (*vn_ssa_aux_hash, info, vn_ssa_aux_t, it)
@@ -6326,7 +6280,6 @@ do_rpo_vn (function *fn, edge entry, bitmap exit_bbs,
   unsigned region_size = (((unsigned HOST_WIDE_INT)n * num_ssa_names)
                          / (n_basic_blocks_for_fn (fn) - NUM_FIXED_BLOCKS));
   VN_TOP = create_tmp_var_raw (void_type_node, "vn_top");
-  init_const_parms ();
 
   vn_ssa_aux_hash = new hash_table <vn_ssa_aux_hasher> (region_size * 2);
   gcc_obstack_init (&vn_ssa_aux_obstack);
index 562a88b8aff3048f0d6f427935c850735813861c..4f415b7a220f92410334b2bba67fc11f2f94a21a 100644 (file)
@@ -1743,6 +1743,13 @@ extern tree maybe_wrap_with_location (tree, location_t);
 #define SSA_NAME_IS_DEFAULT_DEF(NODE) \
     SSA_NAME_CHECK (NODE)->base.default_def_flag
 
+/* Nonzero if this SSA_NAME is known to point to memory that may not
+   be written to.  This is set for default defs of function parameters
+   that have a corresponding r or R specification in the functions
+   fn spec attribute.  This is used by alias analysis.  */
+#define SSA_NAME_POINTS_TO_READONLY_MEMORY(NODE) \
+    SSA_NAME_CHECK (NODE)->base.deprecated_flag
+
 /* Attributes for SSA_NAMEs for pointer-type variables.  */
 #define SSA_NAME_PTR_INFO(N) \
    SSA_NAME_CHECK (N)->ssa_name.info.ptr_info