From 183d6db2a841e44e7556769b14e2a2ff083cc89b Mon Sep 17 00:00:00 2001 From: Jakub Jelinek <jakub@redhat.com> Date: Thu, 16 Feb 2012 08:25:58 +0100 Subject: [PATCH] re PR middle-end/51929 (ICE: verify_cgraph_node failed with -O2 -fno-guess-branch-probability -fipa-cp-clone) PR middle-end/51929 * cgraphunit.c (verify_edge_corresponds_to_fndecl): If node is a same_body_alias, also test whether e->callee isn't a former or current clone of the decl this is a same body alias of. * g++.dg/ipa/pr51929.C: New test. From-SVN: r184301 --- gcc/ChangeLog | 5 +++++ gcc/cgraphunit.c | 12 ++++++++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ipa/pr51929.C | 32 ++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/g++.dg/ipa/pr51929.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f539ec2487b6..d4722a3d9cd1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2012-02-16 Jakub Jelinek <jakub@redhat.com> + PR middle-end/51929 + * cgraphunit.c (verify_edge_corresponds_to_fndecl): If node is + a same_body_alias, also test whether e->callee isn't a former + or current clone of the decl this is a same body alias of. + PR translation/52264 * cgraphunit.c (verify_cgraph_node): Fix a typo. diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 99b82b2665a8..516f187fedd5 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -471,11 +471,17 @@ verify_edge_corresponds_to_fndecl (struct cgraph_edge *e, tree decl) return false; node = cgraph_function_or_thunk_node (node, NULL); - if ((e->callee->former_clone_of != node->decl) + if ((e->callee->former_clone_of != node->decl + && (!node->same_body_alias + || e->callee->former_clone_of != node->thunk.alias)) /* IPA-CP sometimes redirect edge to clone and then back to the former - function. This ping-pong has to go, eventaully. */ + function. This ping-pong has to go, eventually. */ && (node != cgraph_function_or_thunk_node (e->callee, NULL)) - && !clone_of_p (node, e->callee)) + && !clone_of_p (node, e->callee) + /* If decl is a same body alias of some other decl, allow e->callee to be + a clone of a clone of that other decl too. */ + && (!node->same_body_alias + || !clone_of_p (cgraph_get_node (node->thunk.alias), e->callee))) return true; else return false; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cba5c940c3c5..2ab580399264 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-02-16 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/51929 + * g++.dg/ipa/pr51929.C: New test. + 2012-02-15 Michael Meissner <meissner@linux.vnet.ibm.com> PR target/52199 diff --git a/gcc/testsuite/g++.dg/ipa/pr51929.C b/gcc/testsuite/g++.dg/ipa/pr51929.C new file mode 100644 index 000000000000..cfc3df212a1d --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr51929.C @@ -0,0 +1,32 @@ +// PR middle-end/51929 +// { dg-do compile } +// { dg-options "-O -fno-guess-branch-probability -fipa-cp -fipa-cp-clone --param=max-inline-insns-single=25" } + +struct A +{ + A (A, unsigned); + A (const char *); + ~A () { a1 (a4 ()); } + void a1 (int); + unsigned a2 (); + char *a3 (); + int a4 (); +}; + +template <typename T> +struct B +{ + A b; + B (A x, int y = 1) : b (x.a3 (), x.a2 ()) { if (y & 1) b.a2 (); } +}; + +extern template struct B <char>; +A a1 ("foo"), a2 ("bar"); +B<char> b1 (a1), b2 (a2, 8); + +void +foo () +{ + A a3 ("baz"); + B<char> b3 (a1), b4 (a3); +} -- GitLab