From bec6320858ac191ce070cb789fc55792a73084da Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Wed, 10 Sep 2014 13:34:09 +0200 Subject: [PATCH] re PR middle-end/61654 (ICE in release_function_body, at cgraph.c:1699) 2014-09-10 Martin Jambor PR ipa/61654 * cgraphclones.c (duplicate_thunk_for_node): Copy arguments of the new decl properly. Analyze the new thunk if it is expanded. gcc/testsuite/ * g++.dg/ipa/pr61654.C: New test. From-SVN: r215122 --- gcc/ChangeLog | 6 +++++ gcc/cgraphclones.c | 21 ++++++++++++++++ gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/g++.dg/ipa/pr61654.C | 40 ++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ipa/pr61654.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index aab2439f2e1..3c919063c9f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-09-10 Martin Jambor + + PR ipa/61654 + * cgraphclones.c (duplicate_thunk_for_node): Copy arguments of the + new decl properly. Analyze the new thunk if it is expanded. + 2014-09-10 Andreas Schwab * coretypes.h (struct _dont_use_rtx_insn_here_, rtx_insn) diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c index eb044184fe1..2a17de5d552 100644 --- a/gcc/cgraphclones.c +++ b/gcc/cgraphclones.c @@ -334,6 +334,22 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node) node->clone.args_to_skip, false); } + + tree *link = &DECL_ARGUMENTS (new_decl); + int i = 0; + for (tree pd = DECL_ARGUMENTS (thunk->decl); pd; pd = DECL_CHAIN (pd), i++) + { + if (!node->clone.args_to_skip + || !bitmap_bit_p (node->clone.args_to_skip, i)) + { + tree nd = copy_node (pd); + DECL_CONTEXT (nd) = new_decl; + *link = nd; + link = &DECL_CHAIN (nd); + } + } + *link = NULL_TREE; + gcc_checking_assert (!DECL_STRUCT_FUNCTION (new_decl)); gcc_checking_assert (!DECL_INITIAL (new_decl)); gcc_checking_assert (!DECL_RESULT (new_decl)); @@ -357,6 +373,11 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node) symtab->call_edge_duplication_hooks (thunk->callees, e); if (!new_thunk->expand_thunk (false, false)) new_thunk->analyzed = true; + else + { + new_thunk->thunk.thunk_p = false; + new_thunk->analyze (); + } symtab->call_cgraph_duplication_hooks (thunk, new_thunk); return new_thunk; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b6b96fddcde..e4fc660c1a7 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-09-10 Martin Jambor + + PR ipa/61654 + * g++.dg/ipa/pr61654.C: New test. + 2014-09-10 Jakub Jelinek * c-c++-common/ubsan/attrib-3.c: New test. diff --git a/gcc/testsuite/g++.dg/ipa/pr61654.C b/gcc/testsuite/g++.dg/ipa/pr61654.C new file mode 100644 index 00000000000..d07e4586bdb --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr61654.C @@ -0,0 +1,40 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +/* The bug only presented itself on a 32 bit i386 but in theory it might also + pop up elsewhere and we do not want to put -m32 options to testcase + options. */ + +struct A +{ + virtual int a (int, int = 0) = 0; + void b (); + void c (); + int d; +}; + +struct B : virtual A +{ + int a (int, int); + int e; +}; + +int f; + +void +A::b () +{ + a (0); +} + +void +A::c () +{ + a (f); +} + +int +B::a (int, int) +{ + return e; +} -- 2.30.2