This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Remove useless null pointer checks
- From: law at redhat dot com
- To: Diego Novillo <dnovillo at redhat dot com>
- Cc: Jeff Sturm <jsturm at one-point dot com>, Andrew Haley <aph at redhat dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 31 Jul 2003 11:12:24 -0600
- Subject: Re: [tree-ssa] Remove useless null pointer checks
- Reply-to: law at redhat dot com
In message <1059670009.3769.91.camel@frodo.toronto.redhat.com>, Diego Novillo w
rites:
>On Thu, 2003-07-31 at 12:43, Jeff Sturm wrote:
>> On Thu, 31 Jul 2003, Andrew Haley wrote:
>> > We need a way to mark such an attribute in Java source. We don't have
>> > an attribute syntax and we want to stay Java compatible. Stylized
>> > comments, perhaps?
>>
>> I was thinking primarily of library functions like _Jv_AllocObject. Since
>> they are declared in the frontend, we can assign any attributes we like.
>>
>C++'s new() operator could be similarly marked, right?
Note folks there's a bigger and more interesting problem here. And
that is automatic propagation of these attributes to other functions.
ie, if you have a function which does something like this:
void *
my_malloc (size_t size)
{
void *x;
[ ... say some profiling code ... ]
x = malloc (size);
[ ... say some error checking code ... ]
return x;
}
You really want to also mark my_malloc has having malloc-like behavior for its
return value (doesn't aliasing anything). [ The same applies to functions
which always return a non-null value. ]
The way this is done is to walk the use-def chains back from the return
statement to see if the return value is directly derived from another
malloc-like call. If so, then you mark the current function as also
returning a non-aliased location just like malloc does.
IIRC Intel stated this was pretty important to be able to disambiguate
memory references for codes which wrap malloc (much like GCC does with
xmalloc).
Anyway, just something to keep in mind.
jeff