aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2015-04-13 16:13:06 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2015-04-13 14:13:06 +0000
commit95d81ba561d69d63c65ac00c059555ce33d6e77a (patch)
tree74982fec36d08d32de9a64445a9832adb8ee9bf9 /gcc
parent9586973b6089e2a7782b83bd7457170ed7082ad4 (diff)
downloadgcc-95d81ba561d69d63c65ac00c059555ce33d6e77a.zip
gcc-95d81ba561d69d63c65ac00c059555ce33d6e77a.tar.gz
gcc-95d81ba561d69d63c65ac00c059555ce33d6e77a.tar.bz2
ipa-profie.c (ipa_profile): Check number of parameters and possible polymorphic call targets before...
* ipa-profie.c (ipa_profile): Check number of parameters and possible polymorphic call targets before devirtualizing. From-SVN: r222053
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/ipa-profile.c30
2 files changed, 36 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e846816..9dcdea6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2015-04-12 Jan Hubicka <hubicka@ucw.cz>
+
+ * ipa-profie.c (ipa_profile): Check number of parameters
+ and possible polymorphic call targets before
+ devirtualizing.
+
2015-04-13 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.md (*bmi2_umul<mode><dwi>3_1): Merge from
diff --git a/gcc/ipa-profile.c b/gcc/ipa-profile.c
index 0929877..e9f937f 100644
--- a/gcc/ipa-profile.c
+++ b/gcc/ipa-profile.c
@@ -524,6 +524,7 @@ ipa_profile (void)
gcov_type overall_time = 0, cutoff = 0, cumulated = 0, overall_size = 0;
struct cgraph_node *n,*n2;
int nindirect = 0, ncommon = 0, nunknown = 0, nuseless = 0, nconverted = 0;
+ int nmismatch = 0, nimpossible = 0;
bool node_map_initialized = false;
if (dump_file)
@@ -651,6 +652,31 @@ ipa_profile (void)
"Not speculating: target is overwritable "
"and can be discarded.\n");
}
+ else if (ipa_node_params_sum && ipa_edge_args_vector
+ && !IPA_NODE_REF (n2)->descriptors.is_empty ()
+ && ipa_get_param_count (IPA_NODE_REF (n2))
+ != ipa_get_cs_argument_count (IPA_EDGE_REF (e))
+ && (ipa_get_param_count (IPA_NODE_REF (n2))
+ >= ipa_get_cs_argument_count (IPA_EDGE_REF (e))
+ || !stdarg_p (TREE_TYPE (n2->decl))))
+ {
+ nmismatch++;
+ if (dump_file)
+ fprintf (dump_file,
+ "Not speculating: "
+ "parameter count mistmatch\n");
+ }
+ else if (e->indirect_info->polymorphic
+ && !opt_for_fn (n->decl, flag_devirtualize)
+ && !possible_polymorphic_call_target_p (e, n2))
+ {
+ nimpossible++;
+ if (dump_file)
+ fprintf (dump_file,
+ "Not speculating: "
+ "function is not in the polymorphic "
+ "call target list\n");
+ }
else
{
/* Target may be overwritable, but profile says that
@@ -693,11 +719,15 @@ ipa_profile (void)
"%i indirect calls trained.\n"
"%i (%3.2f%%) have common target.\n"
"%i (%3.2f%%) targets was not found.\n"
+ "%i (%3.2f%%) targets had parameter count mismatch.\n"
+ "%i (%3.2f%%) targets was not in polymorphic call target list.\n"
"%i (%3.2f%%) speculations seems useless.\n"
"%i (%3.2f%%) speculations produced.\n",
nindirect,
ncommon, ncommon * 100.0 / nindirect,
nunknown, nunknown * 100.0 / nindirect,
+ nmismatch, nmismatch * 100.0 / nindirect,
+ nimpossible, nimpossible * 100.0 / nindirect,
nuseless, nuseless * 100.0 / nindirect,
nconverted, nconverted * 100.0 / nindirect);