aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2013-12-17 11:26:59 +0100
committerJan Hubicka <hubicka@gcc.gnu.org>2013-12-17 10:26:59 +0000
commit61dd6a2e33c0811de2ade0363fc664221392b9fc (patch)
tree4d856e80811b852c42ef9f8f19bba037088ea175 /gcc
parent2477c234e2d89f875e19d4b6d112b7c321b46a55 (diff)
downloadgcc-61dd6a2e33c0811de2ade0363fc664221392b9fc.zip
gcc-61dd6a2e33c0811de2ade0363fc664221392b9fc.tar.gz
gcc-61dd6a2e33c0811de2ade0363fc664221392b9fc.tar.bz2
devirt-13.C: Update template.
* g++.dg/ipa/devirt-13.C: Update template. * ipa-utils.h (possible_polymorphic_call_targets): Determine context of the call. * gimple-fold.c (gimple_fold_call): Use ipa-devirt to devirtualize. From-SVN: r206042
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/gimple-fold.c30
-rw-r--r--gcc/ipa-utils.h9
-rw-r--r--gcc/testsuite/ChangeLog4
4 files changed, 30 insertions, 19 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 639ec9bf..7da6fc4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-17 Jan Hubicka <hubicka@ucw.cz>
+
+ * ipa-utils.h (possible_polymorphic_call_targets): Determine context of
+ the call.
+ * gimple-fold.c (gimple_fold_call): Use ipa-devirt to devirtualize.
+
2013-12-17 Jakub Jelinek <jakub@redhat.com>
* expr.c (convert_modes): For SUBREG_PROMOTED_VAR_P use SUBREG_REG (x)
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 1705394..767c869 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -1153,26 +1153,20 @@ gimple_fold_call (gimple_stmt_iterator *gsi, bool inplace)
gimple_call_set_fn (stmt, OBJ_TYPE_REF_EXPR (callee));
changed = true;
}
- else if (virtual_method_call_p (callee))
+ else if (flag_devirtualize && virtual_method_call_p (callee))
{
- tree obj = OBJ_TYPE_REF_OBJECT (callee);
- tree binfo = gimple_extract_devirt_binfo_from_cst
- (obj, obj_type_ref_class (callee));
- if (binfo)
+ bool final;
+ vec <cgraph_node *>targets
+ = possible_polymorphic_call_targets (callee, &final);
+ if (final && targets.length () <= 1)
{
- HOST_WIDE_INT token
- = TREE_INT_CST_LOW (OBJ_TYPE_REF_TOKEN (callee));
- tree fndecl = gimple_get_virt_method_for_binfo (token, binfo);
- if (fndecl)
- {
-#ifdef ENABLE_CHECKING
- gcc_assert (possible_polymorphic_call_target_p
- (callee, cgraph_get_node (fndecl)));
-
-#endif
- gimple_call_set_fndecl (stmt, fndecl);
- changed = true;
- }
+ tree fndecl;
+ if (targets.length () == 1)
+ fndecl = targets[0]->decl;
+ else
+ fndecl = builtin_decl_implicit (BUILT_IN_UNREACHABLE);
+ gimple_call_set_fndecl (stmt, fndecl);
+ changed = true;
}
}
}
diff --git a/gcc/ipa-utils.h b/gcc/ipa-utils.h
index b527425..480b752 100644
--- a/gcc/ipa-utils.h
+++ b/gcc/ipa-utils.h
@@ -121,10 +121,17 @@ possible_polymorphic_call_targets (tree call,
bool *final = NULL,
void **cache_token = NULL)
{
+ tree otr_type;
+ HOST_WIDE_INT otr_token;
+ ipa_polymorphic_call_context context;
+
+ get_polymorphic_call_info (current_function_decl,
+ call,
+ &otr_type, &otr_token, &context);
return possible_polymorphic_call_targets (obj_type_ref_class (call),
tree_to_uhwi
(OBJ_TYPE_REF_TOKEN (call)),
- ipa_dummy_polymorphic_call_context,
+ context,
final, cache_token);
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 671a8b5f..ec35aea 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2013-12-17 Jan Hubicka <hubicka@ucw.cz>
+
+ * g++.dg/ipa/devirt-13.C: Update template.
+
2013-12-16 Janus Weil <janus@gcc.gnu.org>
PR fortran/54949