This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Provide special function to find ranges used for aliasing
On Wed, 14 Dec 2005, Daniel Berlin wrote:
> On Mon, 2005-12-12 at 16:00 +0100, Richard Guenther wrote:
> > This replaces the use of get_inner_reference in the aliasing machinery
> > whenever it tries to find out what parts of a structure is
> > (possibly) affected by an access expression. It provides a cleaner
> > interface for this use and at the same time improves the precision of
> > the information generated (this is needed for array aliasing, too).
> >
>
>
> > Bootstrapped and regtested on x86_64-unknown-linux-gnu on mainline and
> > IAB. Ada won't bootstrap for me with a gcc 3.3 based installation
> > (insert random rant here), so it got no testing.
> >
> > Ok for mainline?
> >
>
>
> > *************** find_used_portions (tree *tp, int *walk_
> > *** 2712,2748 ****
> >
> > if (bitpos <= up->minused)
> > up->minused = bitpos;
> > ! if ((bitpos + bitsize >= up->maxused))
> > ! up->maxused = bitpos + bitsize;
> >
> > ! up->explicit_uses = true;
> > up_insert (uid, up);
> >
> > *walk_subtrees = 0;
> > return NULL_TREE;
> > }
> > - else if (DECL_P (ref))
> > - {
> > - if (DECL_SIZE (ref)
> > - && var_can_have_subvars (ref)
> > - && TREE_CODE (DECL_SIZE (ref)) == INTEGER_CST)
> > - {
> > - used_part_t up;
> > - size_t uid = DECL_UID (ref);
> > -
> > - up = get_or_create_used_part_for (uid);
> > -
> > - up->minused = 0;
> > - up->maxused = TREE_INT_CST_LOW (DECL_SIZE (ref));
> > -
> > - up->implicit_uses = true;
> > -
> > - up_insert (uid, up);
> > -
> > - *walk_subtrees = 0;
> > - return NULL_TREE;
> > - }
> > - }
> > }
> > break;
> > /* This is here to make sure we mark the entire base variable as used
>
>
> What is with this part?
> It's not clear why you are removing it
I have convinced myself that we can merge the two cases. Consider
the original code re-written as:
if (DECL_P (ref))
{
size_t uid = DECL_UID (ref);
used_part_t up;
if ((offset == NULL && bitsize != -1)
|| (DECL_SIZE (ref)
&& var_can_have_subvars (ref)
&& TREE_CODE (DECL_SIZE (ref)) == INTEGER_CST))
{
up = get_or_create_used_part_for (uid);
}
if (offset == NULL && bitsize != -1)
{
/* We have a use that we know precisely. Not recording
anything if !var_can_have_subvars is ok. Note that
bitmaxsize is only -1 if the DECL does have variable
size, else it is at most DECL_SIZE (ref). We didn't
record used portions for variable sized types before
(see DEC_SIZE == INTEGER_CST check below). */
if (bitpos <= up->minused)
up->minused = bitpos;
if ((bitpos + bitsize >= up->maxused))
up->maxused = bitpos + bitsize;
up->explicit_uses = true;
}
else if (DECL_SIZE (ref)
&& var_can_have_subvars (ref)
&& TREE_CODE (DECL_SIZE (ref)) == INTEGER_CST)
{
/* We have a use but don't know exactly. In this
case bitsize != bitmaxsize. We still know
partly, so we just adjust the ranges like in
the case we know. */
up->minused = 0;
up->maxused = TREE_INT_CST_LOW (DECL_SIZE (ref));
up->implicit_uses = true;
}
if ((offset == NULL && bitsize != -1)
|| (DECL_SIZE (ref)
&& var_can_have_subvars (ref)
&& TREE_CODE (DECL_SIZE (ref)) == INTEGER_CST))
{
up_insert (uid, up);
*walk_subtrees = 0;
return NULL_TREE;
}
}
and look at the added comments to the part where the two cases differ.
So I think it is safe to merge the two cases.
Richard.