This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
Re: Null pointer check elimination
On Fri, 2005-11-11 at 22:53 -0800, Ian Lance Taylor wrote:
> David Daney <ddaney@avtrex.com> writes:
>
> > > Eventually we should manually mark certain function DECLs as
> > > not-returning-null instead of my kludgy test for this one case. I don't
> > > know if/when I can get to that. Perhaps somebody else can take it from
> > > here.
> >
> > Looks like all the bits in struct tree_common are used up.
> >
> > Q: Would it make sense to add a flag to struct tree_decl_common to
> > indicate !zero, set it using an attribute, (and automatically in the
> > java front-end for the cases above), and then test for it in
> > tree-vrp.c similar to below?
>
> This should be done using an attribute, yes. If this is going to be
> tested frequently enough, it would make sense to add a bit to struct
> tree_function_decl (I don't see any reason to put it in struct
> tree_decl-common) (there is currently room for one more bit in
> tree_function_decl on a machine which requires 16-bit alignment, or 17
> more bits on a machine which requires 32-bit alignment).
Note you could also put things in decl_non_common, but i'd probably beat
you up :)
> Note that it
> is also possible to simply store the attribute on DECL_ATTRIBUTES and
> look it up using lookup_attribute.
IMHO, this is the way to go. The number of times we look at attributes
on function_decls (IE through call_expr_flags, etc) is so small i've
never understood why we use so many bits to represent thing we are
getting from attributes.
Most functions have no attributes, so it's a very simple check for
lookup_attribute to perform. Even when they have *1* attribute, it's
still simple.
>
> Ian