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: Andrew Haley <aph at redhat dot com>
- Cc: gcc at gcc dot gnu dot org, Per Bothner <per at bothner dot com>, Anthony Green <green at redhat dot com>, java at gcc dot gnu dot org
- Date: Sat, 12 Nov 2005 12:25:21 -0500
- Subject: Re: Null pointer check elimination
- References: <1131747852.3205.105.camel@localhost.localdomain> <200511121216.01403.dnovillo@redhat.com> <17270.9233.855010.791103@zapata.pink>
On Saturday 12 November 2005 12:19, Andrew Haley wrote:
> Couldn't we attach an assertion to the tree? That way we could just
> use the inference logic we already have.
>
We already do that. In Per's test case,
String x = shared ? "x" : new String("x");
we get into VRP with an SSA form along these lines:
if (shared_1)
x_4 = "x"
else
{
x_5 = new String("x");
x_6 = ASSERT_EXPR <x_5, x_5 != 0>
}
x_7 = PHI <x_4, x_6>
VRP already knows that "x" is non-NULL. The new function attribute will
cause VRP to insert the ASSERT_EXPR for x_5. VRP will detetermine that
x_7 is non-NULL.