tree-optimization/38474 - improve PTA varinfo sorting

This improves a previous heuristic to sort address-taken variables
first (because those appear in points-to bitmaps) by tracking which
variables appear in ADDRESSOF constraints (there's also
graph->address_taken but that's computed only later).

This shaves off 30s worth of compile-time for the full testcase in
PR38474 (which then still takes 965s to compile at -O2).

2021-02-16  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/38474
	* tree-ssa-structalias.c (variable_info::address_taken): New.
	(new_var_info): Initialize address_taken.
	(process_constraint): Set address_taken.
	(solve_constraints): Use the new address_taken flag rather
	than is_reg_var for sorting variables.
	(dump_constraint): Dump the variable number if the name
	is just NULL.
This commit is contained in:
Richard Biener 2021-02-16 12:42:26 +01:00
parent 1531f39268
commit 3f16a16781
1 changed files with 18 additions and 7 deletions

View File

@ -280,6 +280,9 @@ struct variable_info
/* True if this represents a IPA function info. */
unsigned int is_fn_info : 1;
/* True if this appears as RHS in a ADDRESSOF constraint. */
unsigned int address_taken : 1;
/* ??? Store somewhere better. */
unsigned short ruid;
@ -393,6 +396,7 @@ new_var_info (tree t, const char *name, bool add_id)
ret->is_global_var = (t == NULL_TREE);
ret->is_ipa_escape_point = false;
ret->is_fn_info = false;
ret->address_taken = false;
if (t && DECL_P (t))
ret->is_global_var = (is_global_var (t)
/* We have to treat even local register variables
@ -674,7 +678,10 @@ dump_constraint (FILE *file, constraint_t c)
fprintf (file, "&");
else if (c->lhs.type == DEREF)
fprintf (file, "*");
fprintf (file, "%s", get_varinfo (c->lhs.var)->name);
if (dump_file)
fprintf (file, "%s", get_varinfo (c->lhs.var)->name);
else
fprintf (file, "V%d", c->lhs.var);
if (c->lhs.offset == UNKNOWN_OFFSET)
fprintf (file, " + UNKNOWN");
else if (c->lhs.offset != 0)
@ -684,7 +691,10 @@ dump_constraint (FILE *file, constraint_t c)
fprintf (file, "&");
else if (c->rhs.type == DEREF)
fprintf (file, "*");
fprintf (file, "%s", get_varinfo (c->rhs.var)->name);
if (dump_file)
fprintf (file, "%s", get_varinfo (c->rhs.var)->name);
else
fprintf (file, "V%d", c->rhs.var);
if (c->rhs.offset == UNKNOWN_OFFSET)
fprintf (file, " + UNKNOWN");
else if (c->rhs.offset != 0)
@ -3101,6 +3111,8 @@ process_constraint (constraint_t t)
else
{
gcc_assert (rhs.type != ADDRESSOF || rhs.offset == 0);
if (rhs.type == ADDRESSOF)
get_varinfo (get_varinfo (rhs.var)->head)->address_taken = true;
constraints.safe_push (t);
}
}
@ -7288,15 +7300,14 @@ solve_constraints (void)
unsigned int *map = XNEWVEC (unsigned int, varmap.length ());
for (unsigned i = 0; i < integer_id + 1; ++i)
map[i] = i;
/* Start with non-register vars (as possibly address-taken), followed
by register vars as conservative set of vars never appearing in
the points-to solution bitmaps. */
/* Start with address-taken vars, followed by not address-taken vars
to move vars never appearing in the points-to solution bitmaps last. */
unsigned j = integer_id + 1;
for (unsigned i = integer_id + 1; i < varmap.length (); ++i)
if (! varmap[i]->is_reg_var)
if (varmap[varmap[i]->head]->address_taken)
map[i] = j++;
for (unsigned i = integer_id + 1; i < varmap.length (); ++i)
if (varmap[i]->is_reg_var)
if (! varmap[varmap[i]->head]->address_taken)
map[i] = j++;
/* Shuffle varmap according to map. */
for (unsigned i = integer_id + 1; i < varmap.length (); ++i)