* [PATCH] Fix PR67253
@ 2015-09-16 14:33 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2015-09-16 14:33 UTC (permalink / raw)
To: gcc-patches
Bootstrapped / tested on x86_64-unknown-linux-gnu, applied.
Richard.
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.
* gcc.dg/torture/pr67253.c: New testcase.
Index: gcc/cfgexpand.c
===================================================================
--- gcc/cfgexpand.c (revision 227779)
+++ gcc/cfgexpand.c (working copy)
@@ -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: gcc/testsuite/gcc.dg/torture/pr67253.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr67253.c (revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr67253.c (working copy)
@@ -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;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-09-16 14:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-16 14:33 [PATCH] Fix PR67253 Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).