From 8bda7ce8ec8b5c61b03082d76b5ce33b14a7288a Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Wed, 18 Dec 2019 17:08:09 +0100 Subject: [PATCH] IPA-CP: Remove bogus static keyword (PR 92971) 2019-12-18 Martin Jambor PR ipa/92971 * ipa-cp.c (cgraph_edge_brings_all_agg_vals_for_node): Fix definition of values, release memory on exit. testsuite/ * gcc.dg/ipa/ipcp-agg-12.c: New test. From-SVN: r279525 --- gcc/ChangeLog | 6 +++ gcc/ipa-cp.c | 4 +- gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/ipa/ipcp-agg-12.c | 53 ++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/ipa/ipcp-agg-12.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 198aa78fd17..51e45a82e48 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-12-18 Martin Jambor + + PR ipa/92971 + * ipa-cp.c (cgraph_edge_brings_all_agg_vals_for_node): Fix + definition of values, release memory on exit. + 2019-12-17 Jan Hubicka Martin Jambor diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 1a80ccbde2d..243b064ee2c 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -5117,7 +5117,6 @@ cgraph_edge_brings_all_agg_vals_for_node (struct cgraph_edge *cs, for (i = 0; i < count; i++) { - static vec values = vNULL; class ipcp_param_lattices *plats; bool interesting = false; for (struct ipa_agg_replacement_value *av = aggval; av; av = av->next) @@ -5133,7 +5132,7 @@ cgraph_edge_brings_all_agg_vals_for_node (struct cgraph_edge *cs, if (plats->aggs_bottom) return false; - values = intersect_aggregates_with_edge (cs, i, values); + vec values = intersect_aggregates_with_edge (cs, i, vNULL); if (!values.exists ()) return false; @@ -5157,6 +5156,7 @@ cgraph_edge_brings_all_agg_vals_for_node (struct cgraph_edge *cs, return false; } } + values.release (); } return true; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bcdfaa89c90..df1299dc9bf 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-12-18 Martin Jambor + + PR ipa/92971 + * gcc.dg/ipa/ipcp-agg-12.c: New test. + 2019-12-17 Jan Hubicka Martin Jambor diff --git a/gcc/testsuite/gcc.dg/ipa/ipcp-agg-12.c b/gcc/testsuite/gcc.dg/ipa/ipcp-agg-12.c new file mode 100644 index 00000000000..5c57913803e --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/ipcp-agg-12.c @@ -0,0 +1,53 @@ +/* { dg-do compile } */ +/* { dg-options "-O3 -fno-ipa-sra -fdump-ipa-cp-details --param=ipa-cp-eval-threshold=2" } */ + +struct S +{ + int a, b, c; +}; + +int __attribute__((noinline)) foo (int i, struct S s); +int __attribute__((noinline)) bar (int i, struct S s); +int __attribute__((noinline)) baz (int i, struct S s); + + +int __attribute__((noinline)) +bar (int i, struct S s) +{ + return baz (i, s); +} + +int __attribute__((noinline)) +baz (int i, struct S s) +{ + return foo (i, s); +} + +int __attribute__((noinline)) +foo (int i, struct S s) +{ + if (i == 2) + return 0; + else + return s.b * s.b + bar (i - 1, s); +} + +volatile int g; + +void entry (void) +{ + struct S s; + s.b = 4; + g = bar (g, s); +} + + +void entry2 (void) +{ + struct S s; + s.b = 6; + g = baz (g, s); +} + + +/* { dg-final { scan-ipa-dump-times "adding an extra caller" 2 "cp" } } */ -- 2.30.2