chandlerc added a comment.

In https://reviews.llvm.org/D30806#697372, @ahatanak wrote:

> Are users allowed to call these routines with a null pointer and a non-zero 
> size? Or can we assume that if the size is known to be non-zero at compile 
> time, the pointers are not null?


If the sizes are non-zero, all of these will access memory through the pointer.

But we don't currently have any way of easily expressing this in the IR. We 
could try something fancy like call-side attributes when the size is known, but 
it is pretty redundant -- we could just teach the same things that look at the 
attributes to know that these are reads or writes of a constant size...

> I'm thinking we might miss optimization opportunities if it's not possible to 
> mark the pointer parameters as nonnull.

Note that currently, *nothing marks these parameters as nonnull*. So in all the 
years that folks have used Clang and LLVM with libc headers that have an 
__attribute__((nonnull)), no one has found a performance problem with this as 
the root cause and fixed it.

To me, this indicates that this isn't that important of an optimization *for 
these libc routines*.

If someone ever comes up with a testcase where this is important thing for 
performance, I think we can cross the bridge of finding a fancier way to 
analyze things then.


https://reviews.llvm.org/D30806



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to