On Fri, 14 Oct 2011, Richard Guenther wrote: > > This follows up Michas testcase where we fail to handle the > conservatively propagated restrict tags properly. The following > patch simplifies handling of restrict in the oracle and thus > only excludes NONLOCAL (as designed), but not ESCAPED from > conflict checking. > > Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
So, after some regressions caused by this patch and some more thinking (about more possible issues) I concluded that we can simplify things even more by not making restrict vars point to NONLOCAL, but only to their tag (but marking that as global and able to have a points-to set). This way the special-casing of NONLOCAL vs. restrict can go away, and with it all its possible problems. Restrict is now similar to malloc () memory that escapes. Hopefully this one is without regressions ;) Bootstrap and regtest running on x86_64-unknown-linux-gnu. It seems we can remove DECL_IS_RESTRICTED_P again, as well as the internal is_restrict_var flag. I'll do that if the patch tests ok (the is_restrict_var flag removal immediately, the DECL_IS_RESTRICTED_P removal as followup as it touches Fortran). Thanks, Richard. 2011-10-17 Richard Guenther <rguent...@suse.de> * tree-ssa-alias.h (struct pt_solution): Remove vars_contains_restrict member. (pt_solutions_same_restrict_base): Remove. (pt_solution_set): Adjust. * tree-ssa-alias.c (ptr_deref_may_alias_decl_p): Remove vars_contains_restrict handling. (dump_points_to_solution): Likewise. (ptr_derefs_may_alias_p): Do not call pt_solutions_same_restrict_base. * tree-ssa-structalias.c (make_constraint_from_restrict): Make the tag global. (create_variable_info_for): Do not make restrict vars point to NONLOCAL. (intra_create_variable_infos): Likewise. (find_what_var_points_to): Remove vars_contains_restrict handling. (pt_solution_set): Adjust. (pt_solution_ior_into): Likewise. (pt_solutions_same_restrict_base): Remove. * cfgexpand.c (update_alias_info_with_stack_vars): Adjust. * gimple-pretty-print.c (pp_points_to_solution): Likewise. Index: gcc/tree-ssa-alias.c =================================================================== --- gcc/tree-ssa-alias.c (revision 180077) +++ gcc/tree-ssa-alias.c (working copy) @@ -219,13 +219,6 @@ ptr_deref_may_alias_decl_p (tree ptr, tr if (!pi) return true; - /* If the decl can be used as a restrict tag and we have a restrict - pointer and that pointers points-to set doesn't contain this decl - then they can't alias. */ - if (DECL_RESTRICTED_P (decl) - && pi->pt.vars_contains_restrict) - return bitmap_bit_p (pi->pt.vars, DECL_PT_UID (decl)); - return pt_solution_includes (&pi->pt, decl); } @@ -316,11 +309,6 @@ ptr_derefs_may_alias_p (tree ptr1, tree if (!pi1 || !pi2) return true; - /* If both pointers are restrict-qualified try to disambiguate - with restrict information. */ - if (!pt_solutions_same_restrict_base (&pi1->pt, &pi2->pt)) - return false; - /* ??? This does not use TBAA to prune decls from the intersection that not both pointers may access. */ return pt_solutions_intersect (&pi1->pt, &pi2->pt); @@ -426,8 +414,6 @@ dump_points_to_solution (FILE *file, str dump_decl_set (file, pt->vars); if (pt->vars_contains_global) fprintf (file, " (includes global vars)"); - if (pt->vars_contains_restrict) - fprintf (file, " (includes restrict tags)"); } } Index: gcc/tree-ssa-alias.h =================================================================== --- gcc/tree-ssa-alias.h (revision 180077) +++ gcc/tree-ssa-alias.h (working copy) @@ -54,8 +54,6 @@ struct GTY(()) pt_solution /* Nonzero if the pt_vars bitmap includes a global variable. */ unsigned int vars_contains_global : 1; - /* Nonzero if the pt_vars bitmap includes a restrict tag variable. */ - unsigned int vars_contains_restrict : 1; /* Set of variables that this pointer may point to. */ bitmap vars; @@ -130,10 +128,8 @@ extern bool pt_solution_singleton_p (str extern bool pt_solution_includes_global (struct pt_solution *); extern bool pt_solution_includes (struct pt_solution *, const_tree); extern bool pt_solutions_intersect (struct pt_solution *, struct pt_solution *); -extern bool pt_solutions_same_restrict_base (struct pt_solution *, - struct pt_solution *); extern void pt_solution_reset (struct pt_solution *); -extern void pt_solution_set (struct pt_solution *, bitmap, bool, bool); +extern void pt_solution_set (struct pt_solution *, bitmap, bool); extern void pt_solution_set_var (struct pt_solution *, tree); extern void dump_pta_stats (FILE *); Index: gcc/tree-ssa-structalias.c =================================================================== --- gcc/tree-ssa-structalias.c (revision 180077) +++ gcc/tree-ssa-structalias.c (working copy) @@ -3661,12 +3661,11 @@ make_constraint_from_heapvar (varinfo_t static void make_constraint_from_restrict (varinfo_t lhs, const char *name) { - varinfo_t vi; - vi = make_constraint_from_heapvar (lhs, name); + varinfo_t vi = make_heapvar (name); vi->is_restrict_var = 1; - vi->is_global_var = 0; - vi->is_special_var = 1; - vi->may_have_pointers = 0; + vi->is_global_var = 1; + vi->may_have_pointers = 1; + make_constraint_from (lhs, vi->id); } /* In IPA mode there are varinfos for different aspects of reach @@ -5504,13 +5503,18 @@ create_variable_info_for (tree decl, con if ((POINTER_TYPE_P (TREE_TYPE (decl)) && TYPE_RESTRICT (TREE_TYPE (decl))) || vi->only_restrict_pointers) - make_constraint_from_restrict (vi, "GLOBAL_RESTRICT"); + { + make_constraint_from_restrict (vi, "GLOBAL_RESTRICT"); + continue; + } /* In non-IPA mode the initializer from nonlocal is all we need. */ if (!in_ipa_mode || DECL_HARD_REGISTER (decl)) make_copy_constraint (vi, nonlocal_id); + /* In IPA mode parse the initializer and generate proper constraints + for it. */ else { struct varpool_node *vnode = varpool_get_node (decl); @@ -5595,7 +5599,7 @@ intra_create_variable_infos (void) passed-by-reference argument. */ for (t = DECL_ARGUMENTS (current_function_decl); t; t = DECL_CHAIN (t)) { - varinfo_t p; + varinfo_t p = get_vi_for_tree (t); /* For restrict qualified pointers to objects passed by reference build a real representative for the pointed-to object. @@ -5610,7 +5614,7 @@ intra_create_variable_infos (void) DECL_EXTERNAL (heapvar) = 1; vi = create_variable_info_for_1 (heapvar, "PARM_NOALIAS"); insert_vi_for_tree (heapvar, vi); - lhsc.var = get_vi_for_tree (t)->id; + lhsc.var = p->id; lhsc.type = SCALAR; lhsc.offset = 0; rhsc.var = vi->id; @@ -5623,21 +5627,25 @@ intra_create_variable_infos (void) { if (vi->only_restrict_pointers) make_constraint_from_restrict (vi, "GLOBAL_RESTRICT"); - make_copy_constraint (vi, nonlocal_id); + else + make_copy_constraint (vi, nonlocal_id); } continue; } - for (p = get_vi_for_tree (t); p; p = p->next) - { - if (p->may_have_pointers) - make_constraint_from (p, nonlocal_id); - if (p->only_restrict_pointers) - make_constraint_from_restrict (p, "PARM_RESTRICT"); - } if (POINTER_TYPE_P (TREE_TYPE (t)) && TYPE_RESTRICT (TREE_TYPE (t))) - make_constraint_from_restrict (get_vi_for_tree (t), "PARM_RESTRICT"); + make_constraint_from_restrict (p, "PARM_RESTRICT"); + else + { + for (; p; p = p->next) + { + if (p->only_restrict_pointers) + make_constraint_from_restrict (p, "PARM_RESTRICT"); + else if (p->may_have_pointers) + make_constraint_from (p, nonlocal_id); + } + } } /* Add a constraint for a result decl that is passed by reference. */ @@ -5813,15 +5821,11 @@ find_what_var_points_to (varinfo_t orig_ || vi->id == integer_id) pt->anything = 1; } - if (vi->is_restrict_var) - pt->vars_contains_restrict = true; } /* Instead of doing extra work, simply do not create elaborate points-to information for pt_anything pointers. */ - if (pt->anything - && (orig_vi->is_artificial_var - || !pt->vars_contains_restrict)) + if (pt->anything) return; /* Share the final set of variables when possible. */ @@ -5912,13 +5916,11 @@ pt_solution_reset (struct pt_solution *p it contains restrict tag variables. */ void -pt_solution_set (struct pt_solution *pt, bitmap vars, - bool vars_contains_global, bool vars_contains_restrict) +pt_solution_set (struct pt_solution *pt, bitmap vars, bool vars_contains_global) { memset (pt, 0, sizeof (struct pt_solution)); pt->vars = vars; pt->vars_contains_global = vars_contains_global; - pt->vars_contains_restrict = vars_contains_restrict; } /* Set the points-to solution *PT to point only to the variable VAR. */ @@ -5953,7 +5955,6 @@ pt_solution_ior_into (struct pt_solution dest->ipa_escaped |= src->ipa_escaped; dest->null |= src->null; dest->vars_contains_global |= src->vars_contains_global; - dest->vars_contains_restrict |= src->vars_contains_restrict; if (!src->vars) return; @@ -6141,27 +6142,6 @@ pt_solutions_intersect (struct pt_soluti return res; } -/* Return true if both points-to solutions PT1 and PT2 for two restrict - qualified pointers are possibly based on the same pointer. */ - -bool -pt_solutions_same_restrict_base (struct pt_solution *pt1, - struct pt_solution *pt2) -{ - /* If we deal with points-to solutions of two restrict qualified - pointers solely rely on the pointed-to variable bitmap intersection. - For two pointers that are based on each other the bitmaps will - intersect. */ - if (pt1->vars_contains_restrict - && pt2->vars_contains_restrict) - { - gcc_assert (pt1->vars && pt2->vars); - return bitmap_intersect_p (pt1->vars, pt2->vars); - } - - return true; -} - /* Dump points-to information to OUTFILE. */ Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c (revision 180077) +++ gcc/cfgexpand.c (working copy) @@ -530,7 +530,7 @@ update_alias_info_with_stack_vars (void) /* Make the SSA name point to all partition members. */ pi = get_ptr_info (name); - pt_solution_set (&pi->pt, part, false, false); + pt_solution_set (&pi->pt, part, false); } /* Make all points-to sets that contain one member of a partition Index: gcc/gimple-pretty-print.c =================================================================== --- gcc/gimple-pretty-print.c (revision 180077) +++ gcc/gimple-pretty-print.c (working copy) @@ -610,8 +610,6 @@ pp_points_to_solution (pretty_printer *b pp_character (buffer, '}'); if (pt->vars_contains_global) pp_string (buffer, " (glob)"); - if (pt->vars_contains_restrict) - pp_string (buffer, " (restr)"); } }