OSDN Git Service

gcc/ChangeLog:
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Oct 2012 19:36:47 +0000 (19:36 +0000)
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 29 Oct 2012 19:36:47 +0000 (19:36 +0000)
PR debug/54693
* tree-ssa-threadedge.c (thread_around_empty_block): Copy
debug temps from predecessor before threading.
gcc/testsuite/ChangeLog:
PR debug/54693
* gcc.dg/guality/pr54693.c: New.

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/guality/pr54693.c [new file with mode: 0644]
gcc/tree-ssa-threadedge.c

index 8422ca0..491128e 100644 (file)
@@ -1,5 +1,11 @@
 2012-10-29  Alexandre Oliva <aoliva@redhat.com>
 
+       PR debug/54693
+       * tree-ssa-threadedge.c (thread_around_empty_block): Copy
+       debug temps from predecessor before threading.
+
+2012-10-29  Alexandre Oliva <aoliva@redhat.com>
+
        PR debug/54551
        PR debug/54693
        * valtrack.c (dead_debug_global_find): Accept NULL dtemp.
index 0c0124d..c6899df 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-29  Alexandre Oliva <aoliva@redhat.com>
+
+       PR debug/54693
+       * gcc.dg/guality/pr54693.c: New.
+
 2012-10-29  Marc Glisse  <marc.glisse@inria.fr>
 
        PR middle-end/55027
diff --git a/gcc/testsuite/gcc.dg/guality/pr54693.c b/gcc/testsuite/gcc.dg/guality/pr54693.c
new file mode 100644 (file)
index 0000000..adc2dfd
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR debug/54693 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+__attribute__((noinline, noclone)) void
+foo (char *str, char c)
+{
+  asm volatile ("" : : "r" (str), "r" (c) : "memory");
+  *str = c;
+}
+
+int
+main ()
+{
+  int i;
+  char c;
+  char arr[11];
+
+  for (i = 0; i < 10; i++)
+    {
+      c = 0x30 + i;
+      foo (&arr[i], c); /* { dg-final { gdb-test 22 "i" "c - 48" } } */
+    }
+
+  __builtin_printf ("arr = %s\n", arr);
+  return 0;
+}
+
index ddaa7d1..f43a564 100644 (file)
@@ -637,6 +637,24 @@ thread_around_empty_block (edge taken_edge,
   if (!single_pred_p (bb))
     return NULL;
 
+  /* Before threading, copy DEBUG stmts from the predecessor, so that
+     we don't lose the bindings as we redirect the edges.  */
+  if (MAY_HAVE_DEBUG_STMTS)
+    {
+      gsi = gsi_after_labels (bb);
+      for (gimple_stmt_iterator si = gsi_last_bb (taken_edge->src);
+          !gsi_end_p (si); gsi_prev (&si))
+       {
+         stmt = gsi_stmt (si);
+         if (!is_gimple_debug (stmt))
+           continue;
+
+         stmt = gimple_copy (stmt);
+         /* ??? Should we drop the location of the copy?  */
+         gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
+       }
+    }
+
   /* This block must have more than one successor.  */
   if (single_succ_p (bb))
     return NULL;