On Wed, Nov 13, 2024 at 10:13:23AM +0100, Richard Biener wrote:
> >  /* Return true if OP can be inferred to be a non-NULL after STMT
> > -   executes by using attributes.  */
> > +   executes by using attributes.  If OP2 is non-NULL and nonnull_if_nonzero
> > +   is the only attribute implying OP being non-NULL and the corresponding
> > +   argument isn't non-zero INTEGER_CST, set *OP2 to the corresponding
> > +   argument.  */
> 
> I think this should say it returns true when *OP2 is set.

Added incremental
--- gcc/gimple.cc.jj    2024-11-12 14:30:29.104618853 +0100
+++ gcc/gimple.cc       2024-11-12 14:30:29.104618853 +0100
@@ -3092,7 +3092,8 @@
    executes by using attributes.  If OP2 is non-NULL and nonnull_if_nonzero
    is the only attribute implying OP being non-NULL and the corresponding
    argument isn't non-zero INTEGER_CST, set *OP2 to the corresponding
-   argument.  */
+   argument and return true (in that case returning true doesn't mean
+   OP can be unconditionally inferred to be non-NULL, but conditionally).  */
 bool
 infer_nonnull_range_by_attribute (gimple *stmt, tree op, tree *op2)
 {
to my copy.

> The rest looks reasonable to me.  I think we should tell clang and/or
> glibc people we're doing this.

Not sure how much clang cares about that because as the C2Y paper mentions,
they actually don't use the nonnull attribute on the caller side (except for
UBSan), they seem to only use it on the callee side and the new attribute
can't be used on the callee side (ok, could be used with IPA-VRP).
Anyway, I'll work today on changing the affected builtins and if/when both
patches are committed will file a RFE in clang for support of that attribute
and mail libc-alpha.

        Jakub

Reply via email to