diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6423c3644ca..850880ad37f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2010-02-19 Jakub Jelinek + 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) : Invert priority. diff --git a/gcc/ipa-struct-reorg.c b/gcc/ipa-struct-reorg.c index bef303e288d..66b3ab40d23 100644 --- a/gcc/ipa-struct-reorg.c +++ b/gcc/ipa-struct-reorg.c @@ -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 (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 (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ff44628f4c1..14b2ea426f3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-02-19 Jakub Jelinek + + PR debug/43084 + * gcc.dg/pr43084.c: New test. + 2010-02-19 Richard Guenther PR tree-optimization/42916 diff --git a/gcc/testsuite/gcc.dg/pr43084.c b/gcc/testsuite/gcc.dg/pr43084.c new file mode 100644 index 00000000000..a590fa272cb --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr43084.c @@ -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; +}