From: Richard Biener Date: Tue, 16 Feb 2021 11:42:26 +0000 (+0100) Subject: tree-optimization/38474 - improve PTA varinfo sorting X-Git-Tag: upstream/12.2.0~9700 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f16a1678156035bbe73b217fbce4d9c27d1d559;p=platform%2Fupstream%2Fgcc.git 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 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. --- diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index d6b2661..529ec3a 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -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)