From 3781ab4b677b950454a473182579f8d25fc6d5e3 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Wed, 28 Oct 2015 15:09:12 +0000 Subject: [PATCH] Improve alias dump info 2015-10-28 Tom de Vries * tree-ssa-structalias.c (new_var_info, make_heapvar) (make_constraint_from_restrict, make_constraint_from_global_restrict) (create_function_info_for, create_variable_info_for_1) (create_variable_info_for): Add and handle add_id parameter. (get_call_vi, new_scalar_tmp_constraint_exp, handle_rhs_call) (init_base_vars): Add extra argument to calls to new_var_info. (get_vi_for_tree): Add extra argument to call to create_variable_info_for. (process_constraint, do_deref, process_all_all_constraints): Add extra argument to calls to new_scalar_tmp_constraint_exp. (handle_lhs_call, find_func_aliases_for_builtin_call): Add extra argument to calls to make_heapvar. (make_restrict_var_constraints): Add extra argument to call to make_constraint_from_global_restrict. (intra_create_variable_infos): Add extra argument to call to create_variable_info_for_1. (ipa_pta_execute): Add extra argument to call to create_function_info_for. * gcc.dg/tree-ssa/pta-callused.c: Update to scan for CALLUSED(id). From-SVN: r229489 --- gcc/ChangeLog | 21 ++++ gcc/testsuite/ChangeLog | 4 + gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c | 2 +- gcc/tree-ssa-structalias.c | 112 ++++++++++--------- 4 files changed, 88 insertions(+), 51 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 42cf7e28f5a..440d84354c7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,24 @@ +2015-10-28 Tom de Vries + + * tree-ssa-structalias.c (new_var_info, make_heapvar) + (make_constraint_from_restrict, make_constraint_from_global_restrict) + (create_function_info_for, create_variable_info_for_1) + (create_variable_info_for): Add and handle add_id parameter. + (get_call_vi, new_scalar_tmp_constraint_exp, handle_rhs_call) + (init_base_vars): Add extra argument to calls to new_var_info. + (get_vi_for_tree): Add extra argument to call to + create_variable_info_for. + (process_constraint, do_deref, process_all_all_constraints): Add extra + argument to calls to new_scalar_tmp_constraint_exp. + (handle_lhs_call, find_func_aliases_for_builtin_call): Add extra + argument to calls to make_heapvar. + (make_restrict_var_constraints): Add extra argument to call to + make_constraint_from_global_restrict. + (intra_create_variable_infos): Add extra argument to call to + create_variable_info_for_1. + (ipa_pta_execute): Add extra argument to call to + create_function_info_for. + 2015-10-28 Ramana Radhakrishnan * config/aarch64/aarch64.md (call, call_value, sibcall): Handle noplt. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eb99e44516d..b28a986107d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2015-10-28 Tom de Vries + + * gcc.dg/tree-ssa/pta-callused.c: Update to scan for CALLUSED(id). + 2015-10-28 Richard Biener PR ipa/67600 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c b/gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c index 59408fa0671..b9a57d8d135 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pta-callused.c @@ -22,5 +22,5 @@ int bar (int b) return *foo (&q); } -/* { dg-final { scan-tree-dump "CALLUSED = { ESCAPED NONLOCAL f.* i q }" "alias" } } */ +/* { dg-final { scan-tree-dump "CALLUSED\\(\[0-9\]+\\) = { ESCAPED NONLOCAL f.* i q }" "alias" } } */ diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 52b0813ba58..711b5a0059d 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -220,7 +220,7 @@ static bitmap_obstack oldpta_obstack; /* Used for per-solver-iteration bitmaps. */ static bitmap_obstack iteration_obstack; -static unsigned int create_variable_info_for (tree, const char *); +static unsigned int create_variable_info_for (tree, const char *, bool); typedef struct constraint_graph *constraint_graph_t; static void unify_nodes (constraint_graph_t, unsigned int, unsigned int, bool); @@ -361,11 +361,18 @@ enum { nothing_id = 1, anything_id = 2, string_id = 3, to the vector of variable info structures. */ static varinfo_t -new_var_info (tree t, const char *name) +new_var_info (tree t, const char *name, bool add_id) { unsigned index = varmap.length (); varinfo_t ret = variable_info_pool.allocate (); + if (dump_file && add_id) + { + char *tempname = xasprintf ("%s(%d)", name, index); + name = ggc_strdup (tempname); + free (tempname); + } + ret->id = index; ret->name = name; ret->decl = t; @@ -416,13 +423,13 @@ get_call_vi (gcall *call) if (existed) return *slot_p; - vi = new_var_info (NULL_TREE, "CALLUSED"); + vi = new_var_info (NULL_TREE, "CALLUSED", true); vi->offset = 0; vi->size = 1; vi->fullsize = 2; vi->is_full_var = true; - vi2 = new_var_info (NULL_TREE, "CALLCLOBBERED"); + vi2 = new_var_info (NULL_TREE, "CALLCLOBBERED", true); vi2->offset = 1; vi2->size = 1; vi2->fullsize = 2; @@ -2884,7 +2891,10 @@ get_vi_for_tree (tree t) { varinfo_t *slot = vi_for_tree->get (t); if (slot == NULL) - return get_varinfo (create_variable_info_for (t, alias_get_name (t))); + { + unsigned int id = create_variable_info_for (t, alias_get_name (t), false); + return get_varinfo (id); + } return *slot; } @@ -2892,12 +2902,12 @@ get_vi_for_tree (tree t) /* Get a scalar constraint expression for a new temporary variable. */ static struct constraint_expr -new_scalar_tmp_constraint_exp (const char *name) +new_scalar_tmp_constraint_exp (const char *name, bool add_id) { struct constraint_expr tmp; varinfo_t vi; - vi = new_var_info (NULL_TREE, name); + vi = new_var_info (NULL_TREE, name, add_id); vi->offset = 0; vi->size = -1; vi->fullsize = -1; @@ -3003,7 +3013,7 @@ process_constraint (constraint_t t) { /* Split into tmp = *rhs, *lhs = tmp */ struct constraint_expr tmplhs; - tmplhs = new_scalar_tmp_constraint_exp ("doubledereftmp"); + tmplhs = new_scalar_tmp_constraint_exp ("doubledereftmp", true); process_constraint (new_constraint (tmplhs, rhs)); process_constraint (new_constraint (lhs, tmplhs)); } @@ -3011,7 +3021,7 @@ process_constraint (constraint_t t) { /* Split into tmp = &rhs, *lhs = tmp */ struct constraint_expr tmplhs; - tmplhs = new_scalar_tmp_constraint_exp ("derefaddrtmp"); + tmplhs = new_scalar_tmp_constraint_exp ("derefaddrtmp", true); process_constraint (new_constraint (tmplhs, rhs)); process_constraint (new_constraint (lhs, tmplhs)); } @@ -3315,7 +3325,7 @@ do_deref (vec *constraints) else if (c->type == DEREF) { struct constraint_expr tmplhs; - tmplhs = new_scalar_tmp_constraint_exp ("dereftmp"); + tmplhs = new_scalar_tmp_constraint_exp ("dereftmp", true); process_constraint (new_constraint (tmplhs, *c)); c->var = tmplhs.var; } @@ -3573,7 +3583,7 @@ process_all_all_constraints (vec lhsc, else { struct constraint_expr tmp; - tmp = new_scalar_tmp_constraint_exp ("allalltmp"); + tmp = new_scalar_tmp_constraint_exp ("allalltmp", true); FOR_EACH_VEC_ELT (rhsc, i, rhsp) process_constraint (new_constraint (tmp, *rhsp)); FOR_EACH_VEC_ELT (lhsc, i, lhsp) @@ -3758,7 +3768,7 @@ build_fake_var_decl (tree type) Return the created variable. */ static varinfo_t -make_heapvar (const char *name) +make_heapvar (const char *name, bool add_id) { varinfo_t vi; tree heapvar; @@ -3766,7 +3776,7 @@ make_heapvar (const char *name) heapvar = build_fake_var_decl (ptr_type_node); DECL_EXTERNAL (heapvar) = 1; - vi = new_var_info (heapvar, name); + vi = new_var_info (heapvar, name, add_id); vi->is_artificial_var = true; vi->is_heap_var = true; vi->is_unknown_size_var = true; @@ -3784,9 +3794,9 @@ make_heapvar (const char *name) for tracking restrict pointers. */ static varinfo_t -make_constraint_from_restrict (varinfo_t lhs, const char *name) +make_constraint_from_restrict (varinfo_t lhs, const char *name, bool add_id) { - varinfo_t vi = make_heapvar (name); + varinfo_t vi = make_heapvar (name, add_id); vi->is_restrict_var = 1; vi->is_global_var = 1; vi->may_have_pointers = 1; @@ -3800,9 +3810,10 @@ make_constraint_from_restrict (varinfo_t lhs, const char *name) point to global memory. */ static varinfo_t -make_constraint_from_global_restrict (varinfo_t lhs, const char *name) +make_constraint_from_global_restrict (varinfo_t lhs, const char *name, + bool add_id) { - varinfo_t vi = make_constraint_from_restrict (lhs, name); + varinfo_t vi = make_constraint_from_restrict (lhs, name, add_id); make_copy_constraint (vi, nonlocal_id); return vi; } @@ -3882,7 +3893,7 @@ handle_rhs_call (gcall *stmt, vec *results) varinfo_t uses = get_call_use_vi (stmt); if (!(flags & EAF_DIRECT)) { - varinfo_t tem = new_var_info (NULL_TREE, "callarg"); + varinfo_t tem = new_var_info (NULL_TREE, "callarg", true); make_constraint_to (tem->id, arg); make_transitive_closure_constraints (tem); make_copy_constraint (uses, tem->id); @@ -3896,7 +3907,7 @@ handle_rhs_call (gcall *stmt, vec *results) struct constraint_expr lhs, rhs; varinfo_t uses = get_call_use_vi (stmt); varinfo_t clobbers = get_call_clobber_vi (stmt); - varinfo_t tem = new_var_info (NULL_TREE, "callarg"); + varinfo_t tem = new_var_info (NULL_TREE, "callarg", true); make_constraint_to (tem->id, arg); if (!(flags & EAF_DIRECT)) make_transitive_closure_constraints (tem); @@ -3996,7 +4007,7 @@ handle_lhs_call (gcall *stmt, tree lhs, int flags, vec rhsc, varinfo_t vi; struct constraint_expr tmpc; rhsc.create (0); - vi = make_heapvar ("HEAP"); + vi = make_heapvar ("HEAP", true); /* We are marking allocated storage local, we deal with it becoming global by escaping and setting of vars_contains_escaped_heap. */ DECL_EXTERNAL (vi->decl) = 0; @@ -4247,7 +4258,7 @@ find_func_aliases_for_builtin_call (struct function *fn, gcall *t) tree ptrptr = gimple_call_arg (t, 0); get_constraint_for (ptrptr, &lhsc); do_deref (&lhsc); - varinfo_t vi = make_heapvar ("HEAP"); + varinfo_t vi = make_heapvar ("HEAP", true); /* We are marking allocated storage local, we deal with it becoming global by escaping and setting of vars_contains_escaped_heap. */ DECL_EXTERNAL (vi->decl) = 0; @@ -5414,7 +5425,7 @@ count_num_arguments (tree decl, bool *is_varargs) of the variable we've created for the function. */ static varinfo_t -create_function_info_for (tree decl, const char *name) +create_function_info_for (tree decl, const char *name, bool add_id) { struct function *fn = DECL_STRUCT_FUNCTION (decl); varinfo_t vi, prev_vi; @@ -5425,7 +5436,7 @@ create_function_info_for (tree decl, const char *name) /* Create the variable info. */ - vi = new_var_info (decl, name); + vi = new_var_info (decl, name, add_id); vi->offset = 0; vi->size = 1; vi->fullsize = fi_parm_base + num_args; @@ -5448,7 +5459,7 @@ create_function_info_for (tree decl, const char *name) newname = ggc_strdup (tempname); free (tempname); - clobbervi = new_var_info (NULL, newname); + clobbervi = new_var_info (NULL, newname, false); clobbervi->offset = fi_clobbers; clobbervi->size = 1; clobbervi->fullsize = vi->fullsize; @@ -5462,7 +5473,7 @@ create_function_info_for (tree decl, const char *name) newname = ggc_strdup (tempname); free (tempname); - usevi = new_var_info (NULL, newname); + usevi = new_var_info (NULL, newname, false); usevi->offset = fi_uses; usevi->size = 1; usevi->fullsize = vi->fullsize; @@ -5484,7 +5495,7 @@ create_function_info_for (tree decl, const char *name) newname = ggc_strdup (tempname); free (tempname); - chainvi = new_var_info (fn->static_chain_decl, newname); + chainvi = new_var_info (fn->static_chain_decl, newname, false); chainvi->offset = fi_static_chain; chainvi->size = 1; chainvi->fullsize = vi->fullsize; @@ -5512,7 +5523,7 @@ create_function_info_for (tree decl, const char *name) newname = ggc_strdup (tempname); free (tempname); - resultvi = new_var_info (resultdecl, newname); + resultvi = new_var_info (resultdecl, newname, false); resultvi->offset = fi_result; resultvi->size = 1; resultvi->fullsize = vi->fullsize; @@ -5542,7 +5553,7 @@ create_function_info_for (tree decl, const char *name) newname = ggc_strdup (tempname); free (tempname); - argvi = new_var_info (argdecl, newname); + argvi = new_var_info (argdecl, newname, false); argvi->offset = fi_parm_base + i; argvi->size = 1; argvi->is_full_var = true; @@ -5574,7 +5585,7 @@ create_function_info_for (tree decl, const char *name) /* We need sth that can be pointed to for va_start. */ decl = build_fake_var_decl (ptr_type_node); - argvi = new_var_info (decl, newname); + argvi = new_var_info (decl, newname, false); argvi->offset = fi_parm_base + num_args; argvi->size = ~0; argvi->is_full_var = true; @@ -5613,7 +5624,7 @@ check_for_overlaps (vec fieldstack) of DECL. */ static varinfo_t -create_variable_info_for_1 (tree decl, const char *name) +create_variable_info_for_1 (tree decl, const char *name, bool add_id) { varinfo_t vi, newvi; tree decl_type = TREE_TYPE (decl); @@ -5625,7 +5636,7 @@ create_variable_info_for_1 (tree decl, const char *name) if (!declsize || !tree_fits_uhwi_p (declsize)) { - vi = new_var_info (decl, name); + vi = new_var_info (decl, name, add_id); vi->offset = 0; vi->size = ~0; vi->fullsize = ~0; @@ -5680,7 +5691,7 @@ create_variable_info_for_1 (tree decl, const char *name) if (fieldstack.length () == 0 || fieldstack.length () > MAX_FIELDS_FOR_FIELD_SENSITIVE) { - vi = new_var_info (decl, name); + vi = new_var_info (decl, name, add_id); vi->offset = 0; vi->may_have_pointers = true; vi->fullsize = tree_to_uhwi (declsize); @@ -5693,7 +5704,7 @@ create_variable_info_for_1 (tree decl, const char *name) return vi; } - vi = new_var_info (decl, name); + vi = new_var_info (decl, name, add_id); vi->fullsize = tree_to_uhwi (declsize); if (fieldstack.length () == 1) vi->is_full_var = true; @@ -5728,7 +5739,7 @@ create_variable_info_for_1 (tree decl, const char *name) newvi->only_restrict_pointers = fo->only_restrict_pointers; if (i + 1 < fieldstack.length ()) { - varinfo_t tem = new_var_info (decl, name); + varinfo_t tem = new_var_info (decl, name, false); newvi->next = tem->id; tem->head = vi->id; } @@ -5738,9 +5749,9 @@ create_variable_info_for_1 (tree decl, const char *name) } static unsigned int -create_variable_info_for (tree decl, const char *name) +create_variable_info_for (tree decl, const char *name, bool add_id) { - varinfo_t vi = create_variable_info_for_1 (decl, name); + varinfo_t vi = create_variable_info_for_1 (decl, name, add_id); unsigned int id = vi->id; insert_vi_for_tree (decl, vi); @@ -5761,7 +5772,8 @@ create_variable_info_for (tree decl, const char *name) || vi->only_restrict_pointers) { varinfo_t rvi - = make_constraint_from_global_restrict (vi, "GLOBAL_RESTRICT"); + = make_constraint_from_global_restrict (vi, "GLOBAL_RESTRICT", + true); /* ??? For now exclude reads from globals as restrict sources if those are not (indirectly) from incoming parameters. */ rvi->is_restrict_var = false; @@ -5855,7 +5867,7 @@ make_restrict_var_constraints (varinfo_t vi) if (vi->may_have_pointers) { if (vi->only_restrict_pointers) - make_constraint_from_global_restrict (vi, "GLOBAL_RESTRICT"); + make_constraint_from_global_restrict (vi, "GLOBAL_RESTRICT", true); else make_copy_constraint (vi, nonlocal_id); } @@ -5882,7 +5894,7 @@ intra_create_variable_infos (struct function *fn) varinfo_t p = lookup_vi_for_tree (t); if (p == NULL) { - p = create_variable_info_for_1 (t, alias_get_name (t)); + p = create_variable_info_for_1 (t, alias_get_name (t), false); insert_vi_for_tree (t, p); } @@ -5895,7 +5907,7 @@ intra_create_variable_infos (struct function *fn) varinfo_t vi; tree heapvar = build_fake_var_decl (TREE_TYPE (TREE_TYPE (t))); DECL_EXTERNAL (heapvar) = 1; - vi = create_variable_info_for_1 (heapvar, "PARM_NOALIAS"); + vi = create_variable_info_for_1 (heapvar, "PARM_NOALIAS", true); vi->is_restrict_var = 1; insert_vi_for_tree (heapvar, vi); make_constraint_from (p, vi->id); @@ -5904,13 +5916,13 @@ intra_create_variable_infos (struct function *fn) } if (restrict_pointer_p) - make_constraint_from_global_restrict (p, "PARM_RESTRICT"); + make_constraint_from_global_restrict (p, "PARM_RESTRICT", true); else { for (; p; p = vi_next (p)) { if (p->only_restrict_pointers) - make_constraint_from_global_restrict (p, "PARM_RESTRICT"); + make_constraint_from_global_restrict (p, "PARM_RESTRICT", true); else if (p->may_have_pointers) make_constraint_from (p, nonlocal_id); } @@ -6512,7 +6524,7 @@ init_base_vars (void) /* Create the NULL variable, used to represent that a variable points to NULL. */ - var_nothing = new_var_info (NULL_TREE, "NULL"); + var_nothing = new_var_info (NULL_TREE, "NULL", false); gcc_assert (var_nothing->id == nothing_id); var_nothing->is_artificial_var = 1; var_nothing->offset = 0; @@ -6524,7 +6536,7 @@ init_base_vars (void) /* Create the ANYTHING variable, used to represent that a variable points to some unknown piece of memory. */ - var_anything = new_var_info (NULL_TREE, "ANYTHING"); + var_anything = new_var_info (NULL_TREE, "ANYTHING", false); gcc_assert (var_anything->id == anything_id); var_anything->is_artificial_var = 1; var_anything->size = ~0; @@ -6550,7 +6562,7 @@ init_base_vars (void) /* Create the STRING variable, used to represent that a variable points to a string literal. String literals don't contain pointers so STRING doesn't point to anything. */ - var_string = new_var_info (NULL_TREE, "STRING"); + var_string = new_var_info (NULL_TREE, "STRING", false); gcc_assert (var_string->id == string_id); var_string->is_artificial_var = 1; var_string->offset = 0; @@ -6561,7 +6573,7 @@ init_base_vars (void) /* Create the ESCAPED variable, used to represent the set of escaped memory. */ - var_escaped = new_var_info (NULL_TREE, "ESCAPED"); + var_escaped = new_var_info (NULL_TREE, "ESCAPED", false); gcc_assert (var_escaped->id == escaped_id); var_escaped->is_artificial_var = 1; var_escaped->offset = 0; @@ -6571,7 +6583,7 @@ init_base_vars (void) /* Create the NONLOCAL variable, used to represent the set of nonlocal memory. */ - var_nonlocal = new_var_info (NULL_TREE, "NONLOCAL"); + var_nonlocal = new_var_info (NULL_TREE, "NONLOCAL", false); gcc_assert (var_nonlocal->id == nonlocal_id); var_nonlocal->is_artificial_var = 1; var_nonlocal->offset = 0; @@ -6625,7 +6637,7 @@ init_base_vars (void) /* Create the STOREDANYTHING variable, used to represent the set of variables stored to *ANYTHING. */ - var_storedanything = new_var_info (NULL_TREE, "STOREDANYTHING"); + var_storedanything = new_var_info (NULL_TREE, "STOREDANYTHING", false); gcc_assert (var_storedanything->id == storedanything_id); var_storedanything->is_artificial_var = 1; var_storedanything->offset = 0; @@ -6635,7 +6647,7 @@ init_base_vars (void) /* Create the INTEGER variable, used to represent that a variable points to what an INTEGER "points to". */ - var_integer = new_var_info (NULL_TREE, "INTEGER"); + var_integer = new_var_info (NULL_TREE, "INTEGER", false); gcc_assert (var_integer->id == integer_id); var_integer->is_artificial_var = 1; var_integer->size = ~0; @@ -7301,7 +7313,7 @@ ipa_pta_execute (void) gcc_assert (!node->clone_of); vi = create_function_info_for (node->decl, - alias_get_name (node->decl)); + alias_get_name (node->decl), false); node->call_for_symbol_thunks_and_aliases (associate_varinfo_to_alias, vi, true); } -- 2.30.2