This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa]: Bug fixes and updates for points-to
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 16 Oct 2002 15:04:53 -0400
- Subject: [tree-ssa]: Bug fixes and updates for points-to
Committed.
I'll likely remove the macros in favor of inlines, i'm just doing this
all
incrementally.
Bootstrapped on x86-linux and powerpc-darwin
2002-10-15 Daniel Berlin <dberlin@dberlin.org>
* tree-alias-type.c (alias_tvar_new_with_aterm): New function.
Update all allocations to allocate right type, rather than the union.
Update to use macros to access members of alias_typevar.
* tree-alias-type.h: Split alias_typevar into a common, an ECR, and
an aterm, update all users.
Add macros to access members of union.
* tree-alias-common.c (create_alias_var): Handle function_decl's
properly (needed for proper handling of function pointers).
Updates for macros to access typevars.
Fix some indentation.
* tree-alias-steen.c: Updates for macros to access typevars.
Index: tree-alias-type.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-alias-type.c,v
retrieving revision 1.1.2.3
diff -c -3 -p -w -B -b -r1.1.2.3 tree-alias-type.c
*** tree-alias-type.c 18 Jul 2002 21:09:53 -0000 1.1.2.3
--- tree-alias-type.c 16 Oct 2002 16:25:41 -0000
*************** location_pointsto (t)
*** 183,197 ****
return ret;
}
alias_typevar
alias_tvar_new_with_at (decl, type)
tree decl;
alias_type type;
{
! alias_typevar ret = ggc_alloc (sizeof (struct alias_typevar_def));
! ret->decl = decl;
! ret->ecr = ECR_new_with_type (type, ret);
return ret;
}
--- 185,211 ----
return ret;
}
+ alias_typevar
+ alias_tvar_new_with_aterm (decl, term)
+ tree decl;
+ struct aterm_ *term;
+ {
+ alias_typevar ret = ggc_alloc (sizeof (struct alias_typevar_aterm));
+ ALIAS_TVAR_KIND (ret) = ATERM_ATVAR;
+ ALIAS_TVAR_DECL (ret) = decl;
+ ALIAS_TVAR_ATERM (ret) = term;
+ return ret;
+ }
alias_typevar
alias_tvar_new_with_at (decl, type)
tree decl;
alias_type type;
{
! alias_typevar ret = ggc_alloc (sizeof (struct alias_typevar_ecr));
! ALIAS_TVAR_KIND (ret) = ECR_ATVAR;
! ALIAS_TVAR_DECL (ret) = decl;
! ALIAS_TVAR_ECR (ret) = ECR_new_with_type (type, ret);
return ret;
}
*************** alias_tvar_new_equiv_to (decl, var)
*** 207,216 ****
tree decl;
alias_typevar var;
{
! alias_typevar ret = ggc_alloc (sizeof (struct alias_typevar_def));
! ret->decl = decl;
! ret->ecr = ECR_new_with_type (ECR_get_type (alias_tvar_get_ECR
(var)), ret);
! ECR_union (ret->ecr, alias_tvar_get_ECR (var));
return ret;
}
--- 221,231 ----
tree decl;
alias_typevar var;
{
! alias_typevar ret = ggc_alloc (sizeof (struct alias_typevar_ecr));
! ALIAS_TVAR_KIND (ret) = ECR_ATVAR;
! ALIAS_TVAR_DECL (ret) = decl;
! ALIAS_TVAR_ECR (ret) = ECR_new_with_type (ECR_get_type
(alias_tvar_get_ECR (var)), ret);
! ECR_union (ALIAS_TVAR_ECR (ret), alias_tvar_get_ECR (var));
return ret;
}
*************** ECR
*** 218,245 ****
alias_tvar_get_ECR (var)
alias_typevar var;
{
! return ECR_find (var->ecr);
}
ECR
alias_tvar_get_orig_ECR (var)
alias_typevar var;
{
! return var->ecr;
}
bool
alias_tvar_is_alias (var)
alias_typevar var;
{
! return ECR_size (var->ecr) > 1;
}
varray_type
alias_tvar_pointsto (var)
alias_typevar var;
{
! varray_type v = ALIAS_TYPE_POINTSTO (ECR_get_type (var->ecr));
varray_type p;
size_t i, l;
--- 233,260 ----
alias_tvar_get_ECR (var)
alias_typevar var;
{
! return ECR_find (ALIAS_TVAR_ECR (var));
}
ECR
alias_tvar_get_orig_ECR (var)
alias_typevar var;
{
! return ALIAS_TVAR_ECR (var);
}
bool
alias_tvar_is_alias (var)
alias_typevar var;
{
! return ECR_size (ALIAS_TVAR_ECR (var)) > 1;
}
varray_type
alias_tvar_pointsto (var)
alias_typevar var;
{
! varray_type v = ALIAS_TYPE_POINTSTO (ECR_get_type (ALIAS_TVAR_ECR
(var)));
varray_type p;
size_t i, l;
*************** alias_tvar_allpointsto (var, tv)
*** 270,278 ****
varray_type *tv;
{
ECR e;
! if (ECR_get_type (var->ecr) == alias_bottom)
return;
! e = alias_ltype_loc (ECR_get_type (var->ecr));
if (e->color == next_color)
return;
--- 286,294 ----
varray_type *tv;
{
ECR e;
! if (ECR_get_type (ALIAS_TVAR_ECR (var)) == alias_bottom)
return;
! e = alias_ltype_loc (ECR_get_type (ALIAS_TVAR_ECR (var)));
if (e->color == next_color)
return;
Index: tree-alias-type.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-alias-type.h,v
retrieving revision 1.1.2.4
diff -c -3 -p -w -B -b -r1.1.2.4 tree-alias-type.h
*** tree-alias-type.h 13 Oct 2002 19:09:57 -0000 1.1.2.4
--- tree-alias-type.h 16 Oct 2002 16:25:41 -0000
***************
*** 3,22 ****
struct ECR_def;
typedef struct ECR_def *ECR;
! struct alias_typevar_def;
struct aterm_;
! struct alias_typevar_def GTY (())
{
tree decl;
ECR ecr;
struct aterm_ * GTY((skip (""))) data;
};
! typedef struct alias_typevar_def *alias_typevar;
!
union alias_type_def;
typedef union alias_type_def *alias_type;
alias_typevar alias_tvar_new_with_at PARAMS ((tree, alias_type));
alias_typevar alias_tvar_new PARAMS ((tree));
alias_typevar alias_tvar_new_equiv_to PARAMS ((tree, alias_typevar));
--- 3,47 ----
struct ECR_def;
typedef struct ECR_def *ECR;
! union alias_typevar_def;
struct aterm_;
! enum alias_typevar_kind
{
+ ECR_ATVAR,
+ ATERM_ATVAR
+ };
+ struct alias_typevar_common GTY (())
+ {
+ enum alias_typevar_kind kind;
tree decl;
+ };
+ struct alias_typevar_ecr GTY (())
+ {
+ struct alias_typevar_common common;
ECR ecr;
struct aterm_ * GTY((skip (""))) data;
};
+ struct alias_typevar_aterm GTY (())
+ {
+ struct alias_typevar_common common;
+ struct aterm_ * GTY((skip (""))) term;
+ };
+ union alias_typevar_def GTY ((desc ("%0.common.kind")))
+ {
+ struct alias_typevar_common GTY ((tag ("-1"))) common;
+ struct alias_typevar_ecr GTY ((tag ("ECR_ATVAR"))) ecr;
+ struct alias_typevar_aterm GTY ((tag ("ATERM_ATVAR"))) aterm;
+ };
+ typedef union alias_typevar_def *alias_typevar;
! #define ALIAS_TVAR_KIND(x) ((x)->common.kind)
! #define ALIAS_TVAR_DECL(x) ((x)->common.decl)
! #define ALIAS_TVAR_ECR(x) ((x)->ecr.ecr)
! #define ALIAS_TVAR_ATERM(x) ((x)->aterm.term)
union alias_type_def;
typedef union alias_type_def *alias_type;
+ alias_typevar alias_tvar_new_with_aterm PARAMS ((tree, struct aterm_
*));
alias_typevar alias_tvar_new_with_at PARAMS ((tree, alias_type));
alias_typevar alias_tvar_new PARAMS ((tree));
alias_typevar alias_tvar_new_equiv_to PARAMS ((tree, alias_typevar));
Index: tree-alias-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-alias-common.c,v
retrieving revision 1.1.2.5
diff -c -3 -p -w -B -b -r1.1.2.5 tree-alias-common.c
*** tree-alias-common.c 13 Oct 2002 19:09:57 -0000 1.1.2.5
--- tree-alias-common.c 16 Oct 2002 16:25:41 -0000
*************** Foundation, Inc., 59 Temple Place, Suite
*** 50,56 ****
#include "hashtab.h"
#include "splay-tree.h"
static splay_tree alias_annot;
! static GTY ((param_is (struct alias_typevar_def))) varray_type
alias_vars = NULL;
struct tree_alias_ops *current_alias_ops;
static splay_tree varmap;
static varray_type local_alias_vars;
--- 50,56 ----
#include "hashtab.h"
#include "splay-tree.h"
static splay_tree alias_annot;
! static GTY ((param_is (union alias_typevar_def))) varray_type
alias_vars = NULL;
struct tree_alias_ops *current_alias_ops;
static splay_tree varmap;
static varray_type local_alias_vars;
*************** get_alias_var_decl (decl)
*** 76,90 ****
node = splay_tree_lookup (alias_annot, (splay_tree_key) decl);
if (node != NULL && node->value != 0)
return (alias_typevar) node->value;
! /* For debugging, remove this, and re-enable the find_func_decls
call. */
newvar = create_alias_var (decl);
if (!TREE_PUBLIC (decl))
{
! VARRAY_PUSH_INT (local_alias_varnums, VARRAY_ACTIVE_SIZE
(alias_vars) - 1);
VARRAY_PUSH_GENERIC_PTR (local_alias_vars, decl);
}
return newvar;
- abort ();
}
static alias_typevar
--- 76,95 ----
node = splay_tree_lookup (alias_annot, (splay_tree_key) decl);
if (node != NULL && node->value != 0)
return (alias_typevar) node->value;
! /* For debugging, remove this whole if block, and re-enable the
! find_func_decls call. */
! if (TREE_CODE (decl) == FUNCTION_DECL)
! newvar = create_fun_alias_var (decl, 0);
! else
newvar = create_alias_var (decl);
+
if (!TREE_PUBLIC (decl))
{
! VARRAY_PUSH_INT (local_alias_varnums,
! VARRAY_ACTIVE_SIZE (alias_vars) - 1);
VARRAY_PUSH_GENERIC_PTR (local_alias_vars, decl);
}
return newvar;
}
static alias_typevar
*************** intra_function_call (args)
*** 181,207 ****
{
size_t l = VARRAY_ACTIVE_SIZE (args);
size_t i;
! tree globvar = getdecls();
/* We assume that an actual parameter can point to any global. */
- while (globvar)
- {
- if (TREE_CODE (globvar) == VAR_DECL)
- {
- alias_typevar av = get_alias_var (globvar);
for (i = 0; i < l; i++)
{
alias_typevar argav = VARRAY_GENERIC_PTR (args, i);
/* Restricted pointers can't be aliased with other
restricted pointers. */
! if (!TYPE_RESTRICT (TREE_TYPE (argav->decl))
! || !TYPE_RESTRICT (TREE_TYPE (av->decl)))
current_alias_ops->addr_assign (current_alias_ops, argav, av);
}
- }
- globvar = TREE_CHAIN (globvar);
- }
/* We assume assignments among the actual parameters. */
for (i = 0; i < l; i++)
--- 185,203 ----
{
size_t l = VARRAY_ACTIVE_SIZE (args);
size_t i;
! alias_typevar av = get_alias_var (global_var);
/* We assume that an actual parameter can point to any global. */
for (i = 0; i < l; i++)
{
alias_typevar argav = VARRAY_GENERIC_PTR (args, i);
/* Restricted pointers can't be aliased with other
restricted pointers. */
! if (!TYPE_RESTRICT (TREE_TYPE (ALIAS_TVAR_DECL (argav)))
! || !TYPE_RESTRICT (TREE_TYPE (ALIAS_TVAR_DECL (av))))
current_alias_ops->addr_assign (current_alias_ops, argav, av);
}
/* We assume assignments among the actual parameters. */
for (i = 0; i < l; i++)
*************** intra_function_call (args)
*** 217,224 ****
/* Restricted pointers can't be aliased with other
restricted pointers. */
! if (!TYPE_RESTRICT (TREE_TYPE (argi->decl))
! || !TYPE_RESTRICT (TREE_TYPE (argj->decl)))
current_alias_ops->simple_assign (current_alias_ops, argi, argj);
}
}
--- 213,220 ----
/* Restricted pointers can't be aliased with other
restricted pointers. */
! if (!TYPE_RESTRICT (TREE_TYPE (ALIAS_TVAR_DECL (argi)))
! || !TYPE_RESTRICT (TREE_TYPE (ALIAS_TVAR_DECL (argj))))
current_alias_ops->simple_assign (current_alias_ops, argi, argj);
}
}
*************** find_func_decls (tp, walk_subtrees, data
*** 455,461 ****
if (TREE_CODE (*tp) == DECL_STMT)
{
create_alias_var (DECL_STMT_DECL (*tp));
! VARRAY_PUSH_INT (local_alias_varnums, VARRAY_ACTIVE_SIZE
(alias_vars) - 1);
VARRAY_PUSH_GENERIC_PTR (local_alias_vars, DECL_STMT_DECL
(*tp));
}
return NULL_TREE;
--- 451,458 ----
if (TREE_CODE (*tp) == DECL_STMT)
{
create_alias_var (DECL_STMT_DECL (*tp));
! VARRAY_PUSH_INT (local_alias_varnums,
! VARRAY_ACTIVE_SIZE (alias_vars) - 1);
VARRAY_PUSH_GENERIC_PTR (local_alias_vars, DECL_STMT_DECL
(*tp));
}
return NULL_TREE;
*************** create_fun_alias_var (decl, force)
*** 498,504 ****
for (arg = DECL_ARGUMENTS (decl); arg; arg = TREE_CHAIN (arg))
{
alias_typevar tvar = create_alias_var (arg);
! splay_tree_insert (alias_annot, (splay_tree_key) arg,
(splay_tree_value) tvar);
VARRAY_PUSH_GENERIC_PTR (params, tvar);
}
}
--- 496,503 ----
for (arg = DECL_ARGUMENTS (decl); arg; arg = TREE_CHAIN (arg))
{
alias_typevar tvar = create_alias_var (arg);
! splay_tree_insert (alias_annot, (splay_tree_key) arg,
! (splay_tree_value) tvar);
VARRAY_PUSH_GENERIC_PTR (params, tvar);
}
}
*************** create_alias_var (decl)
*** 615,632 ****
if (node != NULL && node->value != 0)
return (alias_typevar) node->value;
! /* FIXME: Need to handle creating alias variables for PTF's. The
! cleanest way is to make create_fun_alias_var take 2 arguments:
! 1. The function variable decl (IE the name in the case of normal
! function, the PTF variable's name in the case of PTF's)
! 2. The function type.
!
! */
! if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE)
! if (TREE_CODE (TREE_TYPE (TREE_TYPE (decl))) == FUNCTION_TYPE)
! create_fun_alias_var_ptf (decl, TREE_TYPE (TREE_TYPE (decl)));
!
avar = current_alias_ops->add_var (current_alias_ops, decl);
splay_tree_insert (alias_annot, (splay_tree_key)decl,
(splay_tree_value) avar);
VARRAY_PUSH_GENERIC_PTR (alias_vars, avar);
--- 614,629 ----
if (node != NULL && node->value != 0)
return (alias_typevar) node->value;
! if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
! && TREE_CODE (TREE_TYPE (TREE_TYPE (decl))) == FUNCTION_TYPE)
! {
! avar = create_fun_alias_var_ptf (decl, TREE_TYPE (TREE_TYPE
(decl)));
! }
! else
! {
avar = current_alias_ops->add_var (current_alias_ops, decl);
+ }
+
splay_tree_insert (alias_annot, (splay_tree_key)decl,
(splay_tree_value) avar);
VARRAY_PUSH_GENERIC_PTR (alias_vars, avar);
*************** display_points_to_set_helper (tvar)
*** 648,662 ****
{
size_t i;
varray_type tmp;
tmp = alias_tvar_pointsto (tvar);
if (VARRAY_ACTIVE_SIZE (tmp) <= 0)
return;
! print_c_node (stderr, tvar->decl);
fprintf (stderr, " => { ");
for (i = 0; i < VARRAY_ACTIVE_SIZE (tmp); i++)
{
alias_typevar tmpatv = (alias_typevar) VARRAY_GENERIC_PTR (tmp,
i);
! print_c_node (stderr, tmpatv->decl);
fprintf (stderr, ", ");
}
fprintf (stderr, " }\n");
--- 645,661 ----
{
size_t i;
varray_type tmp;
+ if (ALIAS_TVAR_KIND (tvar) != ECR_ATVAR)
+ return;
tmp = alias_tvar_pointsto (tvar);
if (VARRAY_ACTIVE_SIZE (tmp) <= 0)
return;
! print_c_node (stderr, ALIAS_TVAR_DECL (tvar));
fprintf (stderr, " => { ");
for (i = 0; i < VARRAY_ACTIVE_SIZE (tmp); i++)
{
alias_typevar tmpatv = (alias_typevar) VARRAY_GENERIC_PTR (tmp,
i);
! print_c_node (stderr, ALIAS_TVAR_DECL (tmpatv));
fprintf (stderr, ", ");
}
fprintf (stderr, " }\n");
*************** create_alias_vars ()
*** 706,717 ****
current_alias_ops = steen_alias_ops;
#endif
init_alias_vars ();
- while (currdecl)
- {
- if (TREE_CODE (currdecl) == VAR_DECL)
- create_alias_var (currdecl);
- currdecl = TREE_CHAIN (currdecl);
- }
create_fun_alias_var (current_function_decl, 1);
/* For debugging, disable the on-the-fly variable creation,
and reenable this. */
--- 705,710 ----
*************** ptr_may_alias_var (ptr, var)
*** 770,786 ****
alias_typevar ptrtv, vartv;
result = splay_tree_lookup (alias_annot, (splay_tree_key) ptr);
if (!result)
abort ();
- ptrtv = (alias_typevar) result->value;
result = splay_tree_lookup (alias_annot, (splay_tree_key) var);
if (!result)
abort ();
vartv = (alias_typevar) result->value;
return current_alias_ops->may_alias (current_alias_ops, ptrtv,
vartv);
}
-
#include "gt-tree-alias-common.h"
--- 763,781 ----
alias_typevar ptrtv, vartv;
result = splay_tree_lookup (alias_annot, (splay_tree_key) ptr);
+
if (!result)
abort ();
+ ptrtv = (alias_typevar) result->value;
result = splay_tree_lookup (alias_annot, (splay_tree_key) var);
+
if (!result)
abort ();
+
vartv = (alias_typevar) result->value;
return current_alias_ops->may_alias (current_alias_ops, ptrtv,
vartv);
}
#include "gt-tree-alias-common.h"
Index: tree-alias-steen.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-alias-steen.c,v
retrieving revision 1.1.2.9
diff -c -3 -p -w -B -b -r1.1.2.9 tree-alias-steen.c
*** tree-alias-steen.c 13 Oct 2002 19:09:57 -0000 1.1.2.9
--- tree-alias-steen.c 16 Oct 2002 16:25:41 -0000
*************** steen_add_var_same (ops, decl, tv)
*** 169,175 ****
fprintf (stderr, "Steen: Adding variable " );
print_c_node (stderr, decl);
fprintf (stderr, " same as ");
! print_c_node (stderr, tv->decl);
fprintf (stderr, "\n");
#endif
return alias_tvar_new_equiv_to (decl, tv);
--- 168,174 ----
fprintf (stderr, "Steen: Adding variable " );
print_c_node (stderr, decl);
fprintf (stderr, " same as ");
! print_c_node (stderr, ALIAS_TVAR_DECL (tv));
fprintf (stderr, "\n");
#endif
return alias_tvar_new_equiv_to (decl, tv);
*************** steen_simple_assign (ops, lhs, rhs)
*** 187,195 ****
#if STEEN_DEBUG
fprintf (stderr, "Steen: simple assignment ");
! print_c_node (stderr, lhs->decl);
fprintf (stderr, " = ");
! print_c_node (stderr, rhs->decl);
fprintf (stderr, "\n");
#endif
--- 186,194 ----
#if STEEN_DEBUG
fprintf (stderr, "Steen: simple assignment ");
! print_c_node (stderr, ALIAS_TVAR_DECL (lhs));
fprintf (stderr, " = ");
! print_c_node (stderr, ALIAS_TVAR_DECL (rhs));
fprintf (stderr, "\n");
#endif
*************** steen_addr_assign (ops, lhs, addr)
*** 226,234 ****
#if STEEN_DEBUG
fprintf (stderr, "Steen: address assignment ");
! print_c_node (stderr, lhs->decl);
fprintf (stderr, " = &");
! print_c_node (stderr, addr->decl);
fprintf (stderr, "\n");
#endif
--- 225,233 ----
#if STEEN_DEBUG
fprintf (stderr, "Steen: address assignment ");
! print_c_node (stderr, ALIAS_TVAR_DECL (lhs));
fprintf (stderr, " = &");
! print_c_node (stderr, ALIAS_TVAR_DECL (addr));
fprintf (stderr, "\n");
#endif
*************** steen_ptr_assign (ops, lhs, ptr)
*** 259,267 ****
return;
#if STEEN_DEBUG
fprintf (stderr, "Steen: pointer assignment ");
! print_c_node (stderr, lhs->decl);
fprintf (stderr, " = *");
! print_c_node (stderr, ptr->decl);
fprintf (stderr, "\n");
#endif
--- 258,266 ----
return;
#if STEEN_DEBUG
fprintf (stderr, "Steen: pointer assignment ");
! print_c_node (stderr, ALIAS_TVAR_DECL (lhs));
fprintf (stderr, " = *");
! print_c_node (stderr, ALIAS_TVAR_DECL (ptr));
fprintf (stderr, "\n");
#endif
*************** steen_op_assign (ops, lhs, operands)
*** 316,322 ****
#if STEEN_DEBUG
fprintf (stderr, "Steen: op assignment ");
! print_c_node (stderr, lhs->decl);
fprintf (stderr, " = op(...)");
fprintf (stderr, "\n");
#endif
--- 315,321 ----
#if STEEN_DEBUG
fprintf (stderr, "Steen: op assignment ");
! print_c_node (stderr, ALIAS_TVAR_DECL (lhs));
fprintf (stderr, " = op(...)");
fprintf (stderr, "\n");
#endif
*************** steen_assign_ptr (ops, ptr, rhs)
*** 378,386 ****
#if STEEN_DEBUG
fprintf (stderr, "Steen: assignment to pointer *");
! print_c_node (stderr, ptr->decl);
fprintf (stderr, " = ");
! print_c_node (stderr, rhs->decl);
fprintf (stderr, "\n");
#endif
type1 = ECR_get_type (alias_tvar_get_ECR (ptr));
--- 377,385 ----
#if STEEN_DEBUG
fprintf (stderr, "Steen: assignment to pointer *");
! print_c_node (stderr, ALIAS_TVAR_DECL (ptr));
fprintf (stderr, " = ");
! print_c_node (stderr, ALIAS_TVAR_DECL (rhs));
fprintf (stderr, "\n");
#endif
type1 = ECR_get_type (alias_tvar_get_ECR (ptr));