]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: [multiple changes]
authorRichard Biener <rguenther@suse.de>
Tue, 25 Feb 2014 10:47:21 +0000 (10:47 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 25 Feb 2014 10:47:21 +0000 (10:47 +0000)
2014-02-25  Richard Biener  <rguenther@suse.de>

Backport from mainline
2014-02-21  Richard Biener  <rguenther@suse.de>

PR middle-end/60291
* tree-ssa-live.c (mark_all_vars_used_1): Do not walk
DECL_INITIAL for globals not in the current function context.

2014-02-20  Richard Biener  <rguenther@suse.de>

PR middle-end/60221
* tree-eh.c (execute_cleanup_eh_1): Also cleanup empty EH
regions at -O0.

2014-02-14  Richard Biener  <rguenther@suse.de>

PR tree-optimization/60183
* tree-ssa-phiprop.c (propagate_with_phi): Avoid speculating
loads.
(tree_ssa_phiprop): Calculate and free post-dominators.

* gcc.dg/torture/pr60183.c: New testcase.

From-SVN: r208118

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr60183.c [new file with mode: 0644]
gcc/tree-eh.c
gcc/tree-ssa-live.c
gcc/tree-ssa-phiprop.c

index 188455bdd07363ee36b7f0da2bce369ff1a1a09e..1bf6021ac1a238059797c379dbf2462cfe9f39e8 100644 (file)
@@ -1,3 +1,25 @@
+2014-02-25  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2014-02-21  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/60291
+       * tree-ssa-live.c (mark_all_vars_used_1): Do not walk
+       DECL_INITIAL for globals not in the current function context.
+
+       2014-02-20  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/60221
+       * tree-eh.c (execute_cleanup_eh_1): Also cleanup empty EH
+       regions at -O0.
+
+       2014-02-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60183
+       * tree-ssa-phiprop.c (propagate_with_phi): Avoid speculating
+       loads.
+       (tree_ssa_phiprop): Calculate and free post-dominators.
+
 2014-02-25  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        PR target/55426
index 87c93a2b5b7765b8a440db034089b561e09e6e9c..9560421d0c6d2fb01376f3078d19f9e603688814 100644 (file)
@@ -1,3 +1,11 @@
+2014-02-25  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2014-02-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/60183
+       * gcc.dg/torture/pr60183.c: New testcase.
+
 2014-02-24  Fabien ChĂȘne  <fabien@gcc.gnu.org>
 
         PR c++/37140
diff --git a/gcc/testsuite/gcc.dg/torture/pr60183.c b/gcc/testsuite/gcc.dg/torture/pr60183.c
new file mode 100644 (file)
index 0000000..d37b4b8
--- /dev/null
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+
+/* Large so an out-of-bound read will crash.  */
+unsigned char c[0x30001] = { 1 };
+int j = 2;
+
+static void
+foo (unsigned long *x, unsigned char *y)
+{
+  int i;
+  unsigned long w = x[0];
+  for (i = 0; i < j; i++)
+    {
+      w += *y;
+      y += 0x10000;
+      w += *y;
+      y += 0x10000;
+    }
+  x[1] = w;
+}
+
+__attribute__ ((noinline, noclone)) void
+bar (unsigned long *x)
+{
+  foo (x, c);
+}
+
+int
+main ()
+{
+  unsigned long a[2] = { 0, -1UL };
+  asm volatile (""::"r" (c):"memory");
+  c[0] = 0;
+  bar (a);
+  if (a[1] != 0)
+    __builtin_abort ();
+  return 0;
+}
index 4393e8a0e309d13907737400433a9bc35d58e7f1..87fea6d07cfbd39c0a8ebc6dbefeb57a2dfeeb38 100644 (file)
@@ -4322,11 +4322,12 @@ execute_cleanup_eh_1 (void)
   remove_unreachable_handlers ();
 
   /* Watch out for the region tree vanishing due to all unreachable.  */
-  if (cfun->eh->region_tree && optimize)
+  if (cfun->eh->region_tree)
     {
       bool changed = false;
 
-      changed |= unsplit_all_eh ();
+      if (optimize)
+       changed |= unsplit_all_eh ();
       changed |= cleanup_all_empty_eh ();
 
       if (changed)
index a72e9d5a6b6336ccf2db968eb1cb113f83f2d1dc..8456d7a0982b295f90d29e16049f1d148dbf07d8 100644 (file)
@@ -394,7 +394,8 @@ mark_all_vars_used_1 (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED)
     {
       /* When a global var becomes used for the first time also walk its
          initializer (non global ones don't have any).  */
-      if (set_is_used (t) && is_global_var (t))
+      if (set_is_used (t) && is_global_var (t)
+         && DECL_CONTEXT (t) == current_function_decl)
        mark_all_vars_used (&DECL_INITIAL (t));
     }
   /* remove_unused_scope_block_p requires information about labels
index 4da18148782d30da48bb72c3e899a77665f1b619..36b47d7f0d58770c78ae3f27d7adc4170930c97f 100644 (file)
@@ -307,6 +307,12 @@ propagate_with_phi (basic_block bb, gimple phi, struct phiprop_d *phivn,
       gimple def_stmt;
       tree vuse;
 
+      /* Only replace loads in blocks that post-dominate the PHI node.  That
+         makes sure we don't end up speculating loads.  */
+      if (!dominated_by_p (CDI_POST_DOMINATORS,
+                          bb, gimple_bb (use_stmt)))
+       continue;
+         
       /* Check whether this is a load of *ptr.  */
       if (!(is_gimple_assign (use_stmt)
            && TREE_CODE (gimple_assign_lhs (use_stmt)) == SSA_NAME
@@ -378,6 +384,7 @@ tree_ssa_phiprop (void)
   size_t n;
 
   calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (CDI_POST_DOMINATORS);
 
   n = num_ssa_names;
   phivn = XCNEWVEC (struct phiprop_d, n);
@@ -395,6 +402,8 @@ tree_ssa_phiprop (void)
   bbs.release ();
   free (phivn);
 
+  free_dominance_info (CDI_POST_DOMINATORS);
+
   return 0;
 }