re PR debug/43084 (ICE -fipa-struct-reorg -g (VTA))
authorJakub Jelinek <jakub@redhat.com>
Fri, 19 Feb 2010 18:30:22 +0000 (19:30 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 19 Feb 2010 18:30:22 +0000 (19:30 +0100)
PR debug/43084
* ipa-struct-reorg.c (add_access_to_acc_sites): For debug stmts don't
populate vars array.
(create_new_general_access): For debug stmts just reset value.
(get_stmt_accesses): For accesses within debug stmts just record them
using add_access_to_acc_sites instead of preventing the peeling or
counting them as accesses.

* gcc.dg/pr43084.c: New test.

From-SVN: r156904

gcc/ChangeLog
gcc/ipa-struct-reorg.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr43084.c [new file with mode: 0644]

index 6423c36..850880a 100644 (file)
@@ -1,5 +1,13 @@
 2010-02-19  Jakub Jelinek  <jakub@redhat.com>
 
+       PR debug/43084
+       * ipa-struct-reorg.c (add_access_to_acc_sites): For debug stmts don't
+       populate vars array.
+       (create_new_general_access): For debug stmts just reset value.
+       (get_stmt_accesses): For accesses within debug stmts just record them
+       using add_access_to_acc_sites instead of preventing the peeling or
+       counting them as accesses.
+
        PR middle-end/42233
        * dojump.c (do_jump) <case TRUTH_NOT_EXPR>: Invert priority.
 
index bef303e..66b3ab4 100644 (file)
@@ -1,5 +1,5 @@
 /* Struct-reorg optimization.
-   Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
    Contributed by Olga Golovanevsky <olga@il.ibm.com>
    (Initial version of this code was developed
    by Caroline Tice and Mostafa Hagog.)
@@ -497,13 +497,16 @@ add_access_to_acc_sites (gimple stmt, tree var, htab_t accs)
 
        acc = (struct access_site *) xmalloc (sizeof (struct access_site));
        acc->stmt = stmt;
-       acc->vars = VEC_alloc (tree, heap, 10);
+       if (!is_gimple_debug (stmt))
+        acc->vars = VEC_alloc (tree, heap, 10);
+       else
+        acc->vars = NULL;
        slot = htab_find_slot_with_hash (accs, stmt,
                                        htab_hash_pointer (stmt), INSERT);
        *slot = acc;
-
      }
-   VEC_safe_push (tree, heap, acc->vars, var);
+   if (!is_gimple_debug (stmt))
+     VEC_safe_push (tree, heap, acc->vars, var);
 }
 
 /* This function adds NEW_DECL to function
@@ -1383,6 +1386,13 @@ create_new_general_access (struct access_site *acc, d_str str)
       create_new_stmts_for_cond_expr (stmt);
       break;
 
+    case GIMPLE_DEBUG:
+      /* It is very hard to maintain usable debug info after struct peeling,
+        for now just reset all debug stmts referencing objects that have
+        been peeled.  */
+      gimple_debug_bind_reset_value (stmt);
+      break;
+
     default:
       create_new_stmts_for_general_acc (acc, str);
     }
@@ -2494,6 +2504,15 @@ get_stmt_accesses (tree *tp, int *walk_subtrees, void *data)
 
        if (i != VEC_length (structure, structures))
          {
+           if (is_gimple_debug (stmt))
+             {
+               d_str str;
+
+               str = VEC_index (structure, structures, i);
+               add_access_to_acc_sites (stmt, NULL, str->accs);
+               *walk_subtrees = 0;
+               break;
+             }
            if (dump_file)
              {
                fprintf (dump_file, "\nThe type ");
@@ -2525,6 +2544,13 @@ get_stmt_accesses (tree *tp, int *walk_subtrees, void *data)
                struct field_entry * field =
                  find_field_in_struct (str, field_decl);
 
+               if (is_gimple_debug (stmt))
+                 {
+                   add_access_to_acc_sites (stmt, NULL, str->accs);
+                   *walk_subtrees = 0;
+                   break;
+                 }
+
                if (field)
                  {
                    struct field_access_site *acc = make_field_acc_node ();
index ff44628..14b2ea4 100644 (file)
@@ -1,3 +1,8 @@
+2010-02-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR debug/43084
+       * gcc.dg/pr43084.c: New test.
+
 2010-02-19  Richard Guenther  <rguenther@suse.de>
 
        PR tree-optimization/42916
diff --git a/gcc/testsuite/gcc.dg/pr43084.c b/gcc/testsuite/gcc.dg/pr43084.c
new file mode 100644 (file)
index 0000000..a590fa2
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR debug/43084 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fipa-struct-reorg -fwhole-program -fipa-type-escape -fcompare-debug" } */
+
+struct S
+{
+  int a;
+};
+
+int
+main ()
+{
+  struct S s;
+  struct S *p = &s;
+  return p->a;
+}