diff options
author | Martin Jambor <mjambor@suse.cz> | 2013-05-02 16:03:02 +0200 |
---|---|---|
committer | Martin Jambor <jamborm@gcc.gnu.org> | 2013-05-02 16:03:02 +0200 |
commit | 7b920a9ac3fa4a0c8b281ba13f1e689e2c7da4ad (patch) | |
tree | 8027a27b3fb600becf052caf7dc0a3248112257e /gcc | |
parent | 2c41c19d5dfc3de0c0b149dc0846c08422c5dded (diff) | |
download | gcc-7b920a9ac3fa4a0c8b281ba13f1e689e2c7da4ad.zip gcc-7b920a9ac3fa4a0c8b281ba13f1e689e2c7da4ad.tar.gz gcc-7b920a9ac3fa4a0c8b281ba13f1e689e2c7da4ad.tar.bz2 |
re PR middle-end/56988 (ipa-cp incorrectly propagates a field of an aggregate)
2013-05-02 Martin Jambor <mjambor@suse.cz>
PR middle-end/56988
* ipa-prop.h (ipa_agg_replacement_value): New flag by_ref.
* ipa-cp.c (ipa_get_indirect_edge_target_1): Also check that by_ref
flags match.
(find_aggregate_values_for_callers_subset): Fill in the by_ref flag of
ipa_agg_replacement_value structures.
(known_aggs_to_agg_replacement_list): Likewise.
* ipa-prop.c (write_agg_replacement_chain): Stream by_ref flag.
(read_agg_replacement_chain): Likewise.
(ipcp_transform_function): Also check that by_ref flags match.
testsuite/
* gcc.dg/ipa/pr56988.c: New test.
From-SVN: r198540
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 13 | ||||
-rw-r--r-- | gcc/ipa-cp.c | 8 | ||||
-rw-r--r-- | gcc/ipa-prop.c | 11 | ||||
-rw-r--r-- | gcc/ipa-prop.h | 2 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/ipa/pr56988.c | 38 |
6 files changed, 74 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cf3c3e3..5a3d466 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2013-05-02 Martin Jambor <mjambor@suse.cz> + + PR middle-end/56988 + * ipa-prop.h (ipa_agg_replacement_value): New flag by_ref. + * ipa-cp.c (ipa_get_indirect_edge_target_1): Also check that by_ref + flags match. + (find_aggregate_values_for_callers_subset): Fill in the by_ref flag of + ipa_agg_replacement_value structures. + (known_aggs_to_agg_replacement_list): Likewise. + * ipa-prop.c (write_agg_replacement_chain): Stream by_ref flag. + (read_agg_replacement_chain): Likewise. + (ipcp_transform_function): Also check that by_ref flags match. + 2013-05-02 Richard Biener <rguenther@suse.de> * graphds.h (struct graph): Add obstack member. diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 48521cf..f16bd1a 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -1494,7 +1494,8 @@ ipa_get_indirect_edge_target_1 (struct cgraph_edge *ie, while (agg_reps) { if (agg_reps->index == param_index - && agg_reps->offset == ie->indirect_info->offset) + && agg_reps->offset == ie->indirect_info->offset + && agg_reps->by_ref == ie->indirect_info->by_ref) { t = agg_reps->value; break; @@ -3028,11 +3029,12 @@ find_aggregate_values_for_callers_subset (struct cgraph_node *node, struct cgraph_edge *cs; vec<ipa_agg_jf_item_t> inter = vNULL; struct ipa_agg_jf_item *item; + struct ipcp_param_lattices *plats = ipa_get_parm_lattices (dest_info, i); int j; /* Among other things, the following check should deal with all by_ref mismatches. */ - if (ipa_get_parm_lattices (dest_info, i)->aggs_bottom) + if (plats->aggs_bottom) continue; FOR_EACH_VEC_ELT (callers, j, cs) @@ -3054,6 +3056,7 @@ find_aggregate_values_for_callers_subset (struct cgraph_node *node, v->index = i; v->offset = item->offset; v->value = item->value; + v->by_ref = plats->aggs_by_ref; v->next = res; res = v; } @@ -3083,6 +3086,7 @@ known_aggs_to_agg_replacement_list (vec<ipa_agg_jump_function_t> known_aggs) v->index = i; v->offset = item->offset; v->value = item->value; + v->by_ref = aggjf->by_ref; v->next = res; res = v; } diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index 8d1363a..b98f9ad 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -3712,9 +3712,15 @@ write_agg_replacement_chain (struct output_block *ob, struct cgraph_node *node) for (av = aggvals; av; av = av->next) { + struct bitpack_d bp; + streamer_write_uhwi (ob, av->offset); streamer_write_uhwi (ob, av->index); stream_write_tree (ob, av->value, true); + + bp = bitpack_create (ob->main_stream); + bp_pack_value (&bp, av->by_ref, 1); + streamer_write_bitpack (&bp); } } @@ -3732,11 +3738,14 @@ read_agg_replacement_chain (struct lto_input_block *ib, for (i = 0; i <count; i++) { struct ipa_agg_replacement_value *av; + struct bitpack_d bp; av = ggc_alloc_ipa_agg_replacement_value (); av->offset = streamer_read_uhwi (ib); av->index = streamer_read_uhwi (ib); av->value = stream_read_tree (ib, data_in); + bp = streamer_read_bitpack (ib); + av->by_ref = bp_unpack_value (&bp, 1); av->next = aggvals; aggvals = av; } @@ -3955,7 +3964,7 @@ ipcp_transform_function (struct cgraph_node *node) if (v->index == index && v->offset == offset) break; - if (!v) + if (!v || v->by_ref != by_ref) continue; gcc_checking_assert (is_gimple_ip_invariant (v->value)); diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h index 5bc99be..e75826f 100644 --- a/gcc/ipa-prop.h +++ b/gcc/ipa-prop.h @@ -386,6 +386,8 @@ struct GTY(()) ipa_agg_replacement_value tree value; /* The paramter index. */ int index; + /* Whether the value was passed by reference. */ + bool by_ref; }; typedef struct ipa_agg_replacement_value *ipa_agg_replacement_value_p; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4c7a5b3..1f345ff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-05-02 Martin Jambor <mjambor@suse.cz> + + PR middle-end/56988 + * gcc.dg/ipa/pr56988.c: New test. + 2013-05-02 Ian Bolton <ian.bolton@arm.com> * gcc.target/aarch64/bics_1.c: New test. diff --git a/gcc/testsuite/gcc.dg/ipa/pr56988.c b/gcc/testsuite/gcc.dg/ipa/pr56988.c new file mode 100644 index 0000000..ab20159 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr56988.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ +/* { dg-add-options bind_pic_locally } */ + +struct S +{ + int a, b, c; +}; + +volatile int g; + +static void __attribute__ ((noinline, noclone)) +bar (struct S **p) +{ + g = 5; +}; + +static void __attribute__ ((noinline)) +foo (struct S *p) +{ + int i = p->a; + if (i != 1) + __builtin_abort (); + bar (&p); +} + +int +main (int argc, char *argv[]) +{ + struct S s; + s.a = 1; + s.b = 64; + s.c = 32; + foo (&s); + + return 0; +} + |