]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2019-05-22 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 22 May 2019 11:52:19 +0000 (11:52 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 22 May 2019 11:52:19 +0000 (11:52 +0000)
* alias.c (ao_ref_from_mem): Move stack-slot sharing
rewrite ...
* emit-rtl.c (set_mem_attributes_minus_bitpos): ... here.

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

gcc/ChangeLog
gcc/alias.c
gcc/emit-rtl.c

index d31ac86bdff8332bf247b3b476c7b60106e33199..c043e9b83d83eb6bea0aef7518a940f08491ebfe 100644 (file)
@@ -1,3 +1,9 @@
+2019-05-22  Richard Biener  <rguenther@suse.de>
+
+       * alias.c (ao_ref_from_mem): Move stack-slot sharing
+       rewrite ...
+       * emit-rtl.c (set_mem_attributes_minus_bitpos): ... here.
+
 2019-05-22  Martin Liska  <mliska@suse.cz>
 
        PR lto/90500
index b64e3ea264d6d9a917ba3558ce252f34ff61d3b6..d3cc07c721663ad2edd9bd5cc0a633b337e8a827 100644 (file)
@@ -307,18 +307,6 @@ ao_ref_from_mem (ao_ref *ref, const_rtx mem)
            && TREE_CODE (TMR_BASE (base)) == SSA_NAME)))
     return false;
 
-  /* If this is a reference based on a partitioned decl replace the
-     base with a MEM_REF of the pointer representative we
-     created during stack slot partitioning.  */
-  if (VAR_P (base)
-      && ! is_global_var (base)
-      && cfun->gimple_df->decls_to_pointers != NULL)
-    {
-      tree *namep = cfun->gimple_df->decls_to_pointers->get (base);
-      if (namep)
-       ref->base = build_simple_mem_ref (*namep);
-    }
-
   ref->ref_alias_set = MEM_ALIAS_SET (mem);
 
   /* If MEM_OFFSET or MEM_SIZE are unknown what we got from MEM_EXPR
index 15dffa58a2ee1f7d10df49185788c64847dc9c3d..58286f797c4d46dceb7dd01535b278f924f3fb73 100644 (file)
@@ -61,6 +61,9 @@ along with GCC; see the file COPYING3.  If not see
 #include "opts.h"
 #include "predict.h"
 #include "rtx-vector-builder.h"
+#include "gimple.h"
+#include "gimple-ssa.h"
+#include "gimplify.h"
 
 struct target_rtl default_target_rtl;
 #if SWITCHABLE_TARGET
@@ -2128,6 +2131,27 @@ set_mem_attributes_minus_bitpos (rtx ref, tree t, int objectp,
          apply_bitpos = bitpos;
        }
 
+      /* If this is a reference based on a partitioned decl replace the
+        base with a MEM_REF of the pointer representative we created
+        during stack slot partitioning.  */
+      if (attrs.expr
+         && VAR_P (base)
+         && ! is_global_var (base)
+         && cfun->gimple_df->decls_to_pointers != NULL)
+       {
+         tree *namep = cfun->gimple_df->decls_to_pointers->get (base);
+         if (namep)
+           {
+             attrs.expr = unshare_expr (attrs.expr);
+             tree *orig_base = &attrs.expr;
+             while (handled_component_p (*orig_base))
+               orig_base = &TREE_OPERAND (*orig_base, 0);
+             tree aptrt = reference_alias_ptr_type (*orig_base);
+             *orig_base = build2 (MEM_REF, TREE_TYPE (*orig_base), *namep,
+                                  build_int_cst (aptrt, 0));
+           }
+       }
+
       /* Compute the alignment.  */
       unsigned int obj_align;
       unsigned HOST_WIDE_INT obj_bitpos;