2015-09-16 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Sep 2015 14:27:52 +0000 (14:27 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 16 Sep 2015 14:27:52 +0000 (14:27 +0000)
PR middle-end/67253
* cfgexpand.c (expand_gimple_stmt_1): Do not clobber
location of possibly shared trees.

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

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

gcc/ChangeLog
gcc/cfgexpand.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr67253.c [new file with mode: 0644]

index 2ec6aef..e09c84c 100644 (file)
@@ -1,5 +1,11 @@
 2015-09-16  Richard Biener  <rguenther@suse.de>
 
+       PR middle-end/67253
+       * cfgexpand.c (expand_gimple_stmt_1): Do not clobber
+       location of possibly shared trees.
+
+2015-09-16  Richard Biener  <rguenther@suse.de>
+
        PR middle-end/67271
        * fold-const.c (native_encode_expr): Bail out on bogus offsets.
 
index d567a87..3036e67 100644 (file)
@@ -3587,7 +3587,9 @@ expand_gimple_stmt_1 (gimple stmt)
            tree rhs = gimple_assign_rhs1 (assign_stmt);
            gcc_assert (get_gimple_rhs_class (gimple_expr_code (stmt))
                        == GIMPLE_SINGLE_RHS);
-           if (gimple_has_location (stmt) && CAN_HAVE_LOCATION_P (rhs))
+           if (gimple_has_location (stmt) && CAN_HAVE_LOCATION_P (rhs)
+               /* Do not put locations on possibly shared trees.  */
+               && !is_gimple_min_invariant (rhs))
              SET_EXPR_LOCATION (rhs, gimple_location (stmt));
            if (TREE_CLOBBER_P (rhs))
              /* This is a clobber to mark the going out of scope for
index 87bcebf..b54f0d1 100644 (file)
@@ -1,5 +1,10 @@
 2015-09-16  Richard Biener  <rguenther@suse.de>
 
+       PR middle-end/67253
+       * gcc.dg/torture/pr67253.c: New testcase.
+
+2015-09-16  Richard Biener  <rguenther@suse.de>
+
        PR middle-end/67271
        * gcc.dg/pr67271.c: New testcase.
 
diff --git a/gcc/testsuite/gcc.dg/torture/pr67253.c b/gcc/testsuite/gcc.dg/torture/pr67253.c
new file mode 100644 (file)
index 0000000..711106e
--- /dev/null
@@ -0,0 +1,62 @@
+/* { dg-do run } */
+
+int *a, b, c, **d = &a, e, f, **h, i, j, k, l, m, *n, o, **q, r, s;
+
+void fn1 (int p) { }
+
+void
+fn3 ()
+{
+  for (; j; j++)
+    for (; k; k++)
+      l++;
+  f++;
+}
+
+static int
+fn4 (char p1, int *p2)
+{
+  for (; m < 1;)
+    {
+      fn1 (q == &p2);
+      for (; o; o++)
+       ;
+      n = p2;
+      return 0;
+    }
+  for (;;)
+    {
+      for (; s; s++)
+       b = r;
+      *d = 0;
+    }
+}
+
+static int *fn2 (char, int, int *);
+
+static int
+fn5 ()
+{
+  int *g = &c;
+  fn3 ();
+  fn2 (0, 0, g);
+  return e;
+}
+
+static int *
+fn2 (char p1, int p2, int *p3)
+{
+  fn4 (0, p3);
+  fn1 (&p3 == h);
+  for (; i;)
+    fn5 ();
+  fn4 (0, p3);
+  return *d;
+}
+
+int
+main ()
+{
+  fn5 ();
+  return 0;
+}