Commit 2845f02a by Nathan Sidwell Committed by Nathan Sidwell

tree-ssa-alias.c (fieldoff_t): Remove.

	* tree-ssa-alias.c (fieldoff_t): Remove.
	(fieldoff_s): typedef the structure itself.  Create a vector of
	objects.
	(push_fields_onto_fieldstack): Return count of fields pushed.
	Remove peeling of first field.  Adjust.
	(fieldoff_compare): Adjust.
	(create_overlap_variables_for): Adjust.

From-SVN: r98723
parent 9821b257
2005-04-25 Nathan Sidwell <nathan@codesourcery.com>
* tree-ssa-alias.c (fieldoff_t): Remove.
(fieldoff_s): typedef the structure itself. Create a vector of
objects.
(push_fields_onto_fieldstack): Return count of fields pushed.
Remove peeling of first field. Adjust.
(fieldoff_compare): Adjust.
(create_overlap_variables_for): Adjust.
2005-04-25 Joseph S. Myers <joseph@codesourcery.com> 2005-04-25 Joseph S. Myers <joseph@codesourcery.com>
* doc/invoke.texi (Blackfin Options): Avoid empty @opindex line. * doc/invoke.texi (Blackfin Options): Avoid empty @opindex line.
......
...@@ -2789,11 +2789,10 @@ typedef struct fieldoff ...@@ -2789,11 +2789,10 @@ typedef struct fieldoff
{ {
tree field; tree field;
HOST_WIDE_INT offset; HOST_WIDE_INT offset;
} *fieldoff_t; } fieldoff_s;
DEF_VEC_P (fieldoff_t); /* FIXME: This can be a vector of struct DEF_VEC_O (fieldoff_s);
fieldoff objects (nathan 2005/04/15) */ DEF_VEC_ALLOC_O(fieldoff_s,heap);
DEF_VEC_ALLOC_P(fieldoff_t,heap);
/* Return the position, in bits, of FIELD_DECL from the beginning of its /* Return the position, in bits, of FIELD_DECL from the beginning of its
structure. structure.
...@@ -2815,71 +2814,52 @@ bitpos_of_field (const tree fdecl) ...@@ -2815,71 +2814,52 @@ bitpos_of_field (const tree fdecl)
/* Given a TYPE, and a vector of field offsets FIELDSTACK, push all the fields /* Given a TYPE, and a vector of field offsets FIELDSTACK, push all the fields
of TYPE onto fieldstack, recording their offsets along the way. of TYPE onto fieldstack, recording their offsets along the way.
OFFSET is used to keep track of the offset in this entire structure, rather OFFSET is used to keep track of the offset in this entire structure, rather
than just the immediately containing structure. */ than just the immediately containing structure. Returns the number
of fields pushed. */
static void static int
push_fields_onto_fieldstack (tree type, VEC(fieldoff_t,heap) **fieldstack, push_fields_onto_fieldstack (tree type, VEC(fieldoff_s,heap) **fieldstack,
HOST_WIDE_INT offset) HOST_WIDE_INT offset)
{ {
fieldoff_t pair; tree field;
tree field = TYPE_FIELDS (type); int count = 0;
if (!field)
return; /* Although there is nothing wrong per se with a structure whose
if (var_can_have_subvars (field) first field does not start at offset 0, there appeared to be an
&& TREE_CODE (field) == FIELD_DECL) Ada bug where the first field's offset was not zero, but the
{ field itself was at offset zero. Make sure that doesn't
size_t before = VEC_length (fieldoff_t, *fieldstack); reoccur. */
/* Empty structures may have actual size, like in C++. So see if we gcc_assert (!TYPE_FIELDS (type)
actually end up pushing a field, and if not, if the size is nonzero, || TREE_CODE (TYPE_FIELDS (type)) != FIELD_DECL
push the field onto the stack */ || !bitpos_of_field (TYPE_FIELDS (type)));
push_fields_onto_fieldstack (TREE_TYPE (field), fieldstack, offset); for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
if (before == VEC_length (fieldoff_t, *fieldstack) if (TREE_CODE (field) == FIELD_DECL)
&& DECL_SIZE (field) {
&& !integer_zerop (DECL_SIZE (field))) bool push = false;
{
pair = xmalloc (sizeof (struct fieldoff)); if (!var_can_have_subvars (field))
pair->field = field; push = true;
pair->offset = offset; else if (!(push_fields_onto_fieldstack
VEC_safe_push (fieldoff_t, heap, *fieldstack, pair); (TREE_TYPE (field), fieldstack,
} offset + bitpos_of_field (field)))
} && DECL_SIZE (field)
else if (TREE_CODE (field) == FIELD_DECL) && !integer_zerop (DECL_SIZE (field)))
{ /* Empty structures may have actual size, like in C++. So
pair = xmalloc (sizeof (struct fieldoff)); see if we didn't push any subfields and the size is
pair->field = field; nonzero, push the field onto the stack */
pair->offset = offset + bitpos_of_field (field); push = true;
VEC_safe_push (fieldoff_t, heap, *fieldstack, pair);
} if (push)
for (field = TREE_CHAIN (field); field; field = TREE_CHAIN (field)) {
{ fieldoff_s *pair;
if (TREE_CODE (field) != FIELD_DECL)
continue; pair = VEC_safe_push (fieldoff_s, heap, *fieldstack, NULL);
if (var_can_have_subvars (field)) pair->field = field;
{ pair->offset = offset + bitpos_of_field (field);
size_t before = VEC_length (fieldoff_t, *fieldstack); count++;
push_fields_onto_fieldstack (TREE_TYPE (field), fieldstack, }
offset + bitpos_of_field (field)); }
/* Empty structures may have actual size, like in C++. So see if we return count;
actually end up pushing a field, and if not, if the size is nonzero,
push the field onto the stack */
if (before == VEC_length (fieldoff_t, *fieldstack)
&& DECL_SIZE (field)
&& !integer_zerop (DECL_SIZE (field)))
{
pair = xmalloc (sizeof (struct fieldoff));
pair->field = field;
pair->offset = offset + bitpos_of_field (field);
VEC_safe_push (fieldoff_t, heap, *fieldstack, pair);
}
}
else
{
pair = xmalloc (sizeof (struct fieldoff));
pair->field = field;
pair->offset = offset + bitpos_of_field (field);
VEC_safe_push (fieldoff_t, heap, *fieldstack, pair);
}
}
} }
...@@ -2922,22 +2902,21 @@ get_or_create_used_part_for (size_t uid) ...@@ -2922,22 +2902,21 @@ get_or_create_used_part_for (size_t uid)
return up; return up;
} }
/* qsort comparison function for two fieldoff_t's PA and PB */ /* qsort comparison function for two fieldoff's PA and PB */
static int static int
fieldoff_compare (const void *pa, const void *pb) fieldoff_compare (const void *pa, const void *pb)
{ {
const fieldoff_t foa = *(fieldoff_t *)pa; const fieldoff_s *foa = (const fieldoff_s *)pa;
const fieldoff_t fob = *(fieldoff_t *)pb; const fieldoff_s *fob = (const fieldoff_s *)pb;
HOST_WIDE_INT foasize, fobsize; HOST_WIDE_INT foasize, fobsize;
if (foa->offset != fob->offset) if (foa->offset != fob->offset)
return foa->offset - fob->offset; return foa->offset - fob->offset;
foasize = TREE_INT_CST_LOW (DECL_SIZE (foa->field)); foasize = TREE_INT_CST_LOW (DECL_SIZE (foa->field));
fobsize = TREE_INT_CST_LOW (DECL_SIZE (fob->field)); fobsize = TREE_INT_CST_LOW (DECL_SIZE (fob->field));
if (foasize != fobsize) return foasize - fobsize;
return foasize - fobsize;
return 0;
} }
/* Given an aggregate VAR, create the subvariables that represent its /* Given an aggregate VAR, create the subvariables that represent its
...@@ -2946,7 +2925,7 @@ fieldoff_compare (const void *pa, const void *pb) ...@@ -2946,7 +2925,7 @@ fieldoff_compare (const void *pa, const void *pb)
static void static void
create_overlap_variables_for (tree var) create_overlap_variables_for (tree var)
{ {
VEC(fieldoff_t,heap) *fieldstack = NULL; VEC(fieldoff_s,heap) *fieldstack = NULL;
used_part_t up; used_part_t up;
size_t uid = var_ann (var)->uid; size_t uid = var_ann (var)->uid;
...@@ -2955,10 +2934,10 @@ create_overlap_variables_for (tree var) ...@@ -2955,10 +2934,10 @@ create_overlap_variables_for (tree var)
up = used_portions[uid]; up = used_portions[uid];
push_fields_onto_fieldstack (TREE_TYPE (var), &fieldstack, 0); push_fields_onto_fieldstack (TREE_TYPE (var), &fieldstack, 0);
if (VEC_length (fieldoff_t, fieldstack) != 0) if (VEC_length (fieldoff_s, fieldstack) != 0)
{ {
subvar_t *subvars; subvar_t *subvars;
fieldoff_t fo; fieldoff_s *fo;
bool notokay = false; bool notokay = false;
int fieldcount = 0; int fieldcount = 0;
int i; int i;
...@@ -2975,7 +2954,7 @@ create_overlap_variables_for (tree var) ...@@ -2975,7 +2954,7 @@ create_overlap_variables_for (tree var)
currently don't. Doing so would require some extra changes to currently don't. Doing so would require some extra changes to
tree-ssa-operands.c. */ tree-ssa-operands.c. */
for (i = 0; VEC_iterate (fieldoff_t, fieldstack, i, fo); i++) for (i = 0; VEC_iterate (fieldoff_s, fieldstack, i, fo); i++)
{ {
if (!DECL_SIZE (fo->field) if (!DECL_SIZE (fo->field)
|| TREE_CODE (DECL_SIZE (fo->field)) != INTEGER_CST || TREE_CODE (DECL_SIZE (fo->field)) != INTEGER_CST
...@@ -3012,34 +2991,29 @@ create_overlap_variables_for (tree var) ...@@ -3012,34 +2991,29 @@ create_overlap_variables_for (tree var)
notokay = true; notokay = true;
} }
/* Bail out, if we can't create overlap variables. */
/* Cleanup after ourselves if we can't create overlap variables. */
if (notokay) if (notokay)
{ {
while (VEC_length (fieldoff_t, fieldstack) != 0) VEC_free (fieldoff_s, heap, fieldstack);
{
fo = VEC_pop (fieldoff_t, fieldstack);
free (fo);
}
VEC_free (fieldoff_t, heap, fieldstack);
return; return;
} }
/* Otherwise, create the variables. */ /* Otherwise, create the variables. */
subvars = lookup_subvars_for_var (var); subvars = lookup_subvars_for_var (var);
qsort (VEC_address (fieldoff_t, fieldstack), qsort (VEC_address (fieldoff_s, fieldstack),
VEC_length (fieldoff_t, fieldstack), VEC_length (fieldoff_s, fieldstack),
sizeof (fieldoff_t), sizeof (fieldoff_s),
fieldoff_compare); fieldoff_compare);
while (VEC_length (fieldoff_t, fieldstack) != 0) for (i = VEC_length (fieldoff_s, fieldstack);
VEC_iterate (fieldoff_s, fieldstack, --i, fo);)
{ {
subvar_t sv; subvar_t sv;
HOST_WIDE_INT fosize; HOST_WIDE_INT fosize;
var_ann_t ann; var_ann_t ann;
tree currfotype; tree currfotype;
fo = VEC_pop (fieldoff_t, fieldstack);
fosize = TREE_INT_CST_LOW (DECL_SIZE (fo->field)); fosize = TREE_INT_CST_LOW (DECL_SIZE (fo->field));
currfotype = TREE_TYPE (fo->field); currfotype = TREE_TYPE (fo->field);
...@@ -3053,10 +3027,7 @@ create_overlap_variables_for (tree var) ...@@ -3053,10 +3027,7 @@ create_overlap_variables_for (tree var)
|| (fo->offset == lastfooffset || (fo->offset == lastfooffset
&& fosize == lastfosize && fosize == lastfosize
&& currfotype == lastfotype)) && currfotype == lastfotype))
{ continue;
free (fo);
continue;
}
sv = ggc_alloc (sizeof (struct subvar)); sv = ggc_alloc (sizeof (struct subvar));
sv->offset = fo->offset; sv->offset = fo->offset;
sv->size = fosize; sv->size = fosize;
...@@ -3071,7 +3042,6 @@ create_overlap_variables_for (tree var) ...@@ -3071,7 +3042,6 @@ create_overlap_variables_for (tree var)
fprintf (dump_file, " size " HOST_WIDE_INT_PRINT_DEC, fprintf (dump_file, " size " HOST_WIDE_INT_PRINT_DEC,
sv->size); sv->size);
fprintf (dump_file, "\n"); fprintf (dump_file, "\n");
} }
/* We need to copy the various flags from var to sv->var, so that /* We need to copy the various flags from var to sv->var, so that
...@@ -3097,7 +3067,6 @@ create_overlap_variables_for (tree var) ...@@ -3097,7 +3067,6 @@ create_overlap_variables_for (tree var)
lastfooffset = fo->offset; lastfooffset = fo->offset;
lastfosize = fosize; lastfosize = fosize;
*subvars = sv; *subvars = sv;
free (fo);
} }
/* Once we have created subvars, the original is no longer call /* Once we have created subvars, the original is no longer call
...@@ -3108,10 +3077,9 @@ create_overlap_variables_for (tree var) ...@@ -3108,10 +3077,9 @@ create_overlap_variables_for (tree var)
marking subvars of global variables as call clobbered for us marking subvars of global variables as call clobbered for us
to start, since they are global as well. */ to start, since they are global as well. */
clear_call_clobbered (var); clear_call_clobbered (var);
} }
VEC_free (fieldoff_t, heap, fieldstack); VEC_free (fieldoff_s, heap, fieldstack);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment