This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
improving g++ alias analysis (was: Re: g++ and aliasing bools)
- From: Dan Nicolaescu <dann at godzilla dot ICS dot UCI dot EDU>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Cc: Joe Buck <jbuck at synopsys dot com>, Mark Mitchell <mark at codesourcery dot com>, Daniel Berlin <dan at dberlin dot org>
- Date: Mon, 04 Mar 2002 16:20:22 -0800
- Subject: improving g++ alias analysis (was: Re: g++ and aliasing bools)
Now that 3.1 has branched we can go back to this discussion.
Here is a refinement of my initial patch (using the name/structure
proposed by Joe).
It does not deal with inheritance and unions yet.
bootstrapped on sparc-sun-solaris2.8, make check-c++ shows no new
regressions.
It solves the problem shown here: http://gcc.gnu.org/ml/gcc/2002-01/msg01478.html
static bool
cxx_simple_enough_type (t)
tree t;
{
if (AGGREGATE_TYPE_P (t))
{
if (TREE_CODE (t) == RECORD_TYPE)
{
tree fields;
/* PODs are safe */
if (! CLASSTYPE_NON_POD_P(t))
return true;
/* classes with virtual baseclasses are not */
if (TYPE_USES_VIRTUAL_BASECLASSES (t))
return false;
/* don't deal with inheritance for now */
if (CLASSTYPE_N_BASECLASSES(t))
return false;
for (fields = TYPE_FIELDS (t); fields; fields = TREE_CHAIN (fields))
{
if (TREE_CODE (fields) != FIELD_DECL)
continue;
if (! cxx_simple_enough_type (TREE_TYPE (fields)))
return false;
}
return true;
}
else if (TREE_CODE (t) == ARRAY_TYPE)
return cxx_simple_enough_type (TREE_TYPE (t));
/* FIXME: do something about UNION_TYPE */
else
return false;
}
else
return true;
}
static HOST_WIDE_INT
cxx_get_alias_set (t)
tree t;
{
if (!cxx_simple_enough_type(t))
return 0;
else
{
if (AGGREGATE_TYPE_P (t))
return 0;
}
return c_common_get_alias_set (t);
}
Mark, is this code acceptable for 3.2? If so I can submit a patch to
gcc-patches.
Next in line is adding support for inheritance using Dan Berlin's
idea: http://gcc.gnu.org/ml/gcc/2002-01/msg01849.html