From: dnovillo Date: Tue, 18 Jan 2005 03:54:38 +0000 (+0000) Subject: PR tree-optimization/19121 X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=97d6b11869fc65a21d62bb925277e4202649a953 PR tree-optimization/19121 * tree-ssa-alias.c (compute_flow_sensitive_aliasing): When adding aliases to a name tag, also add them to the pointer's type tag. * tree-ssa-copy.c (merge_alias_info): Do not merge flow sensitive alias info at all. Only check that the two pointers have compatible pointed-to sets. * tree-ssa.c (verify_name_tags): Verify that the alias set of a pointer's type tag is a superset of the alias set of the pointer's name tag. testsuite/ChangeLog: PR tree-optimization/19121 * gcc.c-torture/compile/pr19121.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@93810 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ec637b52c0d..be9c0a45cb8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2005-01-17 Diego Novillo + + PR tree-optimization/19121 + * tree-ssa-alias.c (compute_flow_sensitive_aliasing): When + adding aliases to a name tag, also add them to the pointer's + type tag. + * tree-ssa-copy.c (merge_alias_info): Do not merge flow + sensitive alias info at all. Only check that the two pointers + have compatible pointed-to sets. + * tree-ssa.c (verify_name_tags): Verify that the alias set of + a pointer's type tag is a superset of the alias set of the + pointer's name tag. + 2005-01-17 James E Wilson PR target/19357 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5a5a3b83f91..3c1611399e6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-01-17 Diego Novillo + + PR tree-optimization/19121 + * gcc.c-torture/compile/pr19121.c: New test. + 2005-01-17 James E. Wilson PR target/19357 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr19121.c b/gcc/testsuite/gcc.c-torture/compile/pr19121.c new file mode 100644 index 00000000000..b8f4c21f9ee --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr19121.c @@ -0,0 +1,23 @@ +typedef struct interpreter { + char Itokenbuf[256]; +} PerlInterpreter; +static inline void S_missingterm(char *s) +{ + char tmpbuf[3] = ""; + char q; + if (!s) + s = tmpbuf; + q = strchr(s,'"') ? '\'' : '"'; +} +void S_scan_heredoc(PerlInterpreter *my_perl, char *s, int i) +{ + char term; + term = *my_perl->Itokenbuf; + if (i) + { + *s = term; + S_missingterm(my_perl->Itokenbuf); + } + else + S_missingterm(my_perl->Itokenbuf); +} diff --git a/gcc/tree-ssa-alias.c b/gcc/tree-ssa-alias.c index 8df7b82c991..a41021792a7 100644 --- a/gcc/tree-ssa-alias.c +++ b/gcc/tree-ssa-alias.c @@ -913,6 +913,7 @@ compute_flow_sensitive_aliasing (struct alias_info *ai) EXECUTE_IF_SET_IN_BITMAP (pi->pt_vars, 0, j, bi) { add_may_alias (pi->name_mem_tag, referenced_var (j)); + add_may_alias (v_ann->type_mem_tag, referenced_var (j)); } /* If the name tag is call clobbered, so is the type tag diff --git a/gcc/tree-ssa-copy.c b/gcc/tree-ssa-copy.c index 8a03c2435d1..c679eb221be 100644 --- a/gcc/tree-ssa-copy.c +++ b/gcc/tree-ssa-copy.c @@ -178,10 +178,10 @@ merge_alias_info (tree orig, tree new) tree orig_sym = SSA_NAME_VAR (orig); var_ann_t new_ann = var_ann (new_sym); var_ann_t orig_ann = var_ann (orig_sym); - struct ptr_info_def *orig_ptr_info; gcc_assert (POINTER_TYPE_P (TREE_TYPE (orig))); gcc_assert (POINTER_TYPE_P (TREE_TYPE (new))); + #if defined ENABLE_CHECKING gcc_assert (lang_hooks.types_compatible_p (TREE_TYPE (orig), TREE_TYPE (new))); @@ -202,41 +202,30 @@ merge_alias_info (tree orig, tree new) else gcc_assert (new_ann->type_mem_tag == orig_ann->type_mem_tag); - orig_ptr_info = SSA_NAME_PTR_INFO (orig); - if (orig_ptr_info && orig_ptr_info->name_mem_tag) - { - struct ptr_info_def *new_ptr_info = get_ptr_info (new); - - if (new_ptr_info->name_mem_tag == NULL_TREE) - { - /* If ORIG had a name tag, it means that was dereferenced in - the code, and since pointer NEW will now replace every - occurrence of ORIG, we have to make sure that NEW has an - appropriate tag. If, NEW did not have a name tag, get it - from ORIG. */ - memcpy (new_ptr_info, orig_ptr_info, sizeof (*new_ptr_info)); - new_ptr_info->pt_vars = BITMAP_GGC_ALLOC (); - bitmap_copy (new_ptr_info->pt_vars, orig_ptr_info->pt_vars); - new_ptr_info->name_mem_tag = orig_ptr_info->name_mem_tag; - } - else - { - /* If NEW already had a name tag, nothing needs to be done. - Note that pointer NEW may actually have a different set of - pointed-to variables. - - However, since NEW is being copy-propagated into ORIG, it must - always be true that the pointed-to set for pointer NEW is the - same, or a subset, of the pointed-to set for pointer ORIG. If - this isn't the case, we shouldn't have been able to do the - propagation of NEW into ORIG. */ #if defined ENABLE_CHECKING - if (orig_ptr_info->pt_vars && new_ptr_info->pt_vars) - gcc_assert (bitmap_intersect_p (new_ptr_info->pt_vars, - orig_ptr_info->pt_vars)); -#endif - } + { + struct ptr_info_def *orig_ptr_info = SSA_NAME_PTR_INFO (orig); + struct ptr_info_def *new_ptr_info = SSA_NAME_PTR_INFO (new); + + if (orig_ptr_info + && new_ptr_info + && orig_ptr_info->name_mem_tag + && new_ptr_info->name_mem_tag + && orig_ptr_info->pt_vars + && new_ptr_info->pt_vars) + { + /* Note that pointer NEW may actually have a different set of + pointed-to variables. However, since NEW is being + copy-propagated into ORIG, it must always be true that the + pointed-to set for pointer NEW is the same, or a subset, of + the pointed-to set for pointer ORIG. If this isn't the case, + we shouldn't have been able to do the propagation of NEW into + ORIG. */ + gcc_assert (bitmap_intersect_p (new_ptr_info->pt_vars, + orig_ptr_info->pt_vars)); } + } +#endif } diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c index 24b5697f220..fe608f61987 100644 --- a/gcc/tree-ssa.c +++ b/gcc/tree-ssa.c @@ -469,7 +469,11 @@ DEF_VEC_MALLOC_P (bitmap); same name tag must have the same points-to set. So we check a single variable for each name tag, and verify that its points-to set is different from every other points-to set for other name - tags. */ + tags. + + Additionally, given a pointer P_i with name tag NMT and type tag + TMT, this function verified the alias set of TMT is a superset of + the alias set of NMT. */ static void verify_name_tags (void) @@ -479,25 +483,62 @@ verify_name_tags (void) bitmap first, second; VEC (tree) *name_tag_reps = NULL; VEC (bitmap) *pt_vars_for_reps = NULL; + bitmap type_aliases = BITMAP_XMALLOC (); /* First we compute the name tag representatives and their points-to sets. */ for (i = 0; i < num_ssa_names; i++) { - if (ssa_name (i)) + struct ptr_info_def *pi; + tree tmt, ptr = ssa_name (i); + + if (ptr == NULL_TREE) + continue; + + pi = SSA_NAME_PTR_INFO (ptr); + + if (!TREE_VISITED (ptr) + || !POINTER_TYPE_P (TREE_TYPE (ptr)) + || !pi + || !pi->name_mem_tag + || TREE_VISITED (pi->name_mem_tag)) + continue; + + TREE_VISITED (pi->name_mem_tag) = 1; + + if (pi->pt_vars == NULL) + continue; + + VEC_safe_push (tree, name_tag_reps, ptr); + VEC_safe_push (bitmap, pt_vars_for_reps, pi->pt_vars); + + /* Verify that alias set of PTR's type tag is a superset of the + alias set of PTR's name tag. */ + tmt = var_ann (SSA_NAME_VAR (ptr))->type_mem_tag; + if (tmt) { - tree ptr = ssa_name (i); - struct ptr_info_def *pi = SSA_NAME_PTR_INFO (ptr); - if (!TREE_VISITED (ptr) - || !POINTER_TYPE_P (TREE_TYPE (ptr)) - || !pi - || !pi->name_mem_tag - || TREE_VISITED (pi->name_mem_tag)) + size_t i; + varray_type aliases = var_ann (tmt)->may_aliases; + bitmap_clear (type_aliases); + for (i = 0; aliases && i < VARRAY_ACTIVE_SIZE (aliases); i++) + { + tree alias = VARRAY_TREE (aliases, i); + bitmap_set_bit (type_aliases, var_ann (alias)->uid); + } + + /* When grouping, we may have added PTR's type tag into the + alias set of PTR's name tag. To prevent a false + positive, pretend that TMT is in its own alias set. */ + bitmap_set_bit (type_aliases, var_ann (tmt)->uid); + + if (bitmap_equal_p (type_aliases, pi->pt_vars)) continue; - TREE_VISITED (pi->name_mem_tag) = 1; - if (pi->pt_vars != NULL) - { - VEC_safe_push (tree, name_tag_reps, ptr); - VEC_safe_push (bitmap, pt_vars_for_reps, pi->pt_vars); + + if (!bitmap_intersect_compl_p (type_aliases, pi->pt_vars)) + { + error ("Alias set of a pointer's type tag should be a superset of the corresponding name tag"); + debug_variable (tmt); + debug_variable (pi->name_mem_tag); + goto err; } } } @@ -532,13 +573,17 @@ verify_name_tags (void) TREE_VISITED (pi->name_mem_tag) = 0; } } + VEC_free (bitmap, pt_vars_for_reps); + BITMAP_FREE (type_aliases); return; err: debug_variable (VEC_index (tree, name_tag_reps, i)); internal_error ("verify_name_tags failed"); } + + /* Verify the consistency of aliasing information. */ static void