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

--- Comment #6 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:26c9b95b9f712ff1f813351b5d45371620085221

commit r14-8516-g26c9b95b9f712ff1f813351b5d45371620085221
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Tue Jan 30 09:57:21 2024 +0100

    except: Fix __builtin_eh_return_data_regno (-42) expansion [PR101195]

    The expansion of this builtin emits an error if the argument is not
    INTEGER_CST, otherwise uses tree_to_uhwi on the argument (which is declared
    int) and then uses EH_RETURN_DATA_REGNO macro which on most targets returns
    INVALID_REGNUM for all values but some small number (2 or 4); if it returns
    INVALID_REGNUM, we silently expand to -1.

    Now, I think the error for non-INTEGER_CST makes sense to catch when people
    unintentionally don't call it with a constant (but, users shouldn't really
    use this builtin anyway, it is for the unwinder only).  Initially I thought
    about emitting an error for the negative values as well on which
    tree_to_uhwi otherwise ICEs, but given that the function will silently
    expand to -1 for INT_MAX - 1 or INT_MAX - 3 other values, I think treating
    the negatives the same silently is fine too.

    2024-01-30  Jakub Jelinek  <ja...@redhat.com>

            PR middle-end/101195
            * except.cc (expand_builtin_eh_return_data_regno): If which doesn't
            fit into unsigned HOST_WIDE_INT, return constm1_rtx.

            * gcc.dg/pr101195.c: New test.

Reply via email to