This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Null pointer check elimination
- From: Diego Novillo <dnovillo at redhat dot com>
- To: Per Bothner <per at bothner dot com>
- Cc: gcc at gcc dot gnu dot org, java at gcc dot gnu dot org
- Date: Sat, 12 Nov 2005 15:33:19 -0500
- Subject: Re: Null pointer check elimination
- References: <1131747852.3205.105.camel@localhost.localdomain> <200511121352.54076.dnovillo@redhat.com> <4376441D.4060507@bothner.com>
On Saturday 12 November 2005 14:35, Per Bothner wrote:
> The internal SSA form might be something like:
>
> foo()
> {
> if (test)
> {
> int __attribute__((never_null)) *p_1 =
> this_never_returns_NULL(); < ... use p without modifying it ... > <--
> p_1 never NULL here. }
> else
> {
> int *p_2 = other_fn ();
> < ... use p without modifying it ... > <-- p_2 may be NULL here.
> }
> int *p_3 = PHI(p_1, p_2);
> ... more uses of p ...;
> }
>
Well, I am not an FE person, so I don't much care how you convey the
information into the optimizers.
From a user's perspective I see the obvious drawback that you've just
forced me to edit a potentially large number of source files just to add
the __attribute__((never_null)). The other approach just needs a single
__attribute__ in the function declaration.
Another problem I would have as a user is if you suddenly make 'int *' and
'int * __attribute__((non_null))' different/incompatible types. If I have
a function that takes 'int *' as argument, I don't want to start adding
tons of type casts to get around compiler warnings/errors.
From an optimizer perspective, I fail to see how would your approach give
me better information inside VRP. But since your approach seems to give
me the same information, I don't much care how the FE implements this. If
you decide to have type attributes, I'll use it. If you mark the
function, I'll use it with the same effect.