aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2020-11-29 16:27:35 +0100
committerJan Hubicka <jh@suse.cz>2020-11-29 16:27:35 +0100
commit3350e59f2985469b2472e4d9a6d387337da4519b (patch)
tree18dd9648cfcb5d38c93364cb1b2526ded9db7699 /gcc
parentf59be8dfbd85a7f8face7340950503750a8bfddb (diff)
downloadgcc-3350e59f2985469b2472e4d9a6d387337da4519b.zip
gcc-3350e59f2985469b2472e4d9a6d387337da4519b.tar.gz
gcc-3350e59f2985469b2472e4d9a6d387337da4519b.tar.bz2
Detect unused parameters in ipa-modref
* ipa-modref.c (modref_lattice::merge): Do nothing if F is EAF_UNUSED. (analyze_parms): Detect unused params. (modref_merge_call_site_flags): Merge correct EAF_UNUSED.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ipa-modref.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c
index d1d4ba7..5ba8ff0 100644
--- a/gcc/ipa-modref.c
+++ b/gcc/ipa-modref.c
@@ -1437,6 +1437,8 @@ modref_lattice::add_escape_point (gcall *call, int arg, int min_flags,
bool
modref_lattice::merge (int f)
{
+ if (f & EAF_UNUSED)
+ return false;
if ((flags & f) != flags)
{
flags &= f;
@@ -1825,8 +1827,26 @@ analyze_parms (modref_summary *summary, modref_summary_lto *summary_lto,
parm = TREE_CHAIN (parm))
{
tree name = ssa_default_def (cfun, parm);
- if (!name)
- continue;
+ if (!name || has_zero_uses (name))
+ {
+ /* We do not track non-SSA parameters,
+ but we want to track unused gimple_regs. */
+ if (!is_gimple_reg (parm))
+ continue;
+ if (summary)
+ {
+ if (parm_index >= summary->arg_flags.length ())
+ summary->arg_flags.safe_grow_cleared (count, true);
+ summary->arg_flags[parm_index] = EAF_UNUSED;
+ }
+ else if (summary_lto)
+ {
+ if (parm_index >= summary_lto->arg_flags.length ())
+ summary_lto->arg_flags.safe_grow_cleared (count, true);
+ summary_lto->arg_flags[parm_index] = EAF_UNUSED;
+ }
+ continue;
+ }
analyze_ssa_name_flags (name, lattice, 0, ipa);
int flags = lattice[SSA_NAME_VERSION (name)].flags;
@@ -3636,7 +3656,8 @@ modref_merge_call_site_flags (escape_summary *sum,
}
flags |= ee->min_flags;
flags_lto |= ee->min_flags;
- if (cur_summary && ee->parm_index < cur_summary->arg_flags.length ())
+ if (!(flags & EAF_UNUSED)
+ && cur_summary && ee->parm_index < cur_summary->arg_flags.length ())
{
int f = cur_summary->arg_flags[ee->parm_index];
if ((f & flags) != f)
@@ -3648,7 +3669,8 @@ modref_merge_call_site_flags (escape_summary *sum,
changed = true;
}
}
- if (cur_summary_lto
+ if (!(flags_lto & EAF_UNUSED)
+ && cur_summary_lto
&& ee->parm_index < cur_summary_lto->arg_flags.length ())
{
int f = cur_summary_lto->arg_flags[ee->parm_index];