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.
This commit is contained in:
parent
f59be8dfbd
commit
3350e59f29
1 changed files with 26 additions and 4 deletions
|
@ -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];
|
||||
|
|
Loading…
Add table
Reference in a new issue