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

--- Comment #9 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:f7d1b9cdc0dd811722798530efffd736bfc2bc1d

commit r15-6179-gf7d1b9cdc0dd811722798530efffd736bfc2bc1d
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Thu Dec 12 19:47:46 2024 +0100

    match.pd: Defer some CTZ/CLZ foldings until after ubsan pass for
-fsanitize=builtin [PR115127]

    As the following testcase shows, -fsanitize=builtin instruments the
    builtins in the ubsan pass which is done shortly after going into
    SSA, but if optimizations optimize the builtins away before that,
    nothing is instrumented.  Now, I think it is just fine if the
    result of the builtins isn't used in any way and we just DCE them,
    but in the following optimizations the result is used.
    So, the following patch for -fsanitize=builtin only defers the
    optimizations that might turn single argument CLZ/CTZ (aka undefined
    at zero) until the ubsan pass is done.
    Now, we don't have PROP_ubsan and am not sure it is worth adding it,
    there is PROP_ssa set by the ssa pass which is 3 passes before
    ubsan, but there are only 2 warning passes in between, so PROP_ssa
    looked good enough to me.

    2024-12-12  Jakub Jelinek  <ja...@redhat.com>

            PR sanitizer/115127
            * match.pd (clz (X) == C, ctz (X) == C, ctz (X) >= C): Don't
            optimize if -fsanitize=builtin and not yet in SSA form.

            * c-c++-common/ubsan/builtin-2.c: New test.

Reply via email to