https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117023

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:912d5cfb8cf3c2568a544a4260bac4f6f932767a

commit r15-5751-g912d5cfb8cf3c2568a544a4260bac4f6f932767a
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Thu Nov 28 11:50:49 2024 +0100

    ranger: Handle nonnull_if_nonzero attribute [PR117023]

    On top of the
    https://gcc.gnu.org/pipermail/gcc-patches/2024-November/668554.html
    patch which introduces the nonnull_if_nonzero attribute (because
    C2Y is allowing NULL arguments on various calls like memcpy, memset,
    strncpy etc. as long as the count is 0) the following patch adds just
    limited handling of the attribute in the ranger, in particular infers
    nonnull for the pointer argument referenced in first argument of the
    attribute if the second argument is a non-zero INTEGER_CST
    (integer_nonzerop).

    Ideally (as the FIXME says) I'd like to query arg2 range and check if
    it doesn't contain zero, but am not sure such queries are possible from
    gimple_infer_range (and if it is possible whether one can just query
    the currently recorded range for it or if one can call something that
    will try to compute the range by walking the def stmts etc.).

    Could you handle as a follow-up the range querying if it is possible?

    As for useful testcase, with the patch I'm going to post next
    e.g. gcc.dg/tree-ssa/pr78154.c if the calls use d as destination (not dn)
    and count that will have a range which doesn't include 0 and isn't
constant.

    2024-11-28  Jakub Jelinek  <ja...@redhat.com>

            PR c/117023
            * gimple-range-infer.cc (gimple_infer_range::gimple_infer_range):
            Handle also nonnull_if_nonzero attributes.

Reply via email to