aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2020-04-16 19:21:02 +0200
committerMartin Jambor <mjambor@suse.cz>2020-04-16 19:21:02 +0200
commit7123347c8b44571811c4b58506b06fb09969bccb (patch)
treeddf5d23a57ce231aef99ac668163fa8a8baddcde /gcc/cgraph.c
parent26bebf576ddcdcfb596f07e8c2896f17c48516e7 (diff)
downloadgcc-7123347c8b44571811c4b58506b06fb09969bccb.zip
gcc-7123347c8b44571811c4b58506b06fb09969bccb.tar.gz
gcc-7123347c8b44571811c4b58506b06fb09969bccb.tar.bz2
ipa: Make call redirection detect already adjusted calls (PR 93621)
PR 93621 testcase makes redirect_call_stmt_to_callee wrongly assume that a call statement needs redirecting but then rightly fails an assert ensuring the call statement parameters have not already been adjusted because they were already created adjusted as part of thunk expansion. The test fails because the decl in the call call statement is different than the decl of the callee, because the latter was created in save_inline_function_body. This patch adds a way to link these two and detect the situation in redirect_call_stmt_to_callee. 2020-04-16 Martin Jambor <mjambor@suse.cz> PR ipa/93621 * ipa-inline.h (ipa_saved_clone_sources): Declare. * ipa-inline-transform.c (ipa_saved_clone_sources): New variable. (save_inline_function_body): Link the new body holder with the previous one. * cgraph.c: Include ipa-inline.h. (cgraph_edge::redirect_call_stmt_to_callee): Try to find the decl from the statement in ipa_saved_clone_sources. * cgraphunit.c: Include ipa-inline.h. (expand_all_functions): Free ipa_saved_clone_sources. testsuite/ * g++.dg/ipa/pr93621.C: New test.
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r--gcc/cgraph.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index ecb234d..72d7cb5 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -63,6 +63,7 @@ along with GCC; see the file COPYING3. If not see
#include "attribs.h"
#include "selftest.h"
#include "tree-into-ssa.h"
+#include "ipa-inline.h"
/* FIXME: Only for PROP_loops, but cgraph shouldn't have to know about this. */
#include "tree-pass.h"
@@ -1470,6 +1471,16 @@ cgraph_edge::redirect_call_stmt_to_callee (cgraph_edge *e)
|| decl == e->callee->decl)
return e->call_stmt;
+ if (decl && ipa_saved_clone_sources)
+ {
+ tree *p = ipa_saved_clone_sources->get (e->callee);
+ if (p && decl == *p)
+ {
+ gimple_call_set_fndecl (e->call_stmt, e->callee->decl);
+ return e->call_stmt;
+ }
+ }
+
if (flag_checking && decl)
{
cgraph_node *node = cgraph_node::get (decl);