[Bug rtl-optimization/94119] [8/9/10 regression] invalid filling of branch delay slots leads to corrupt jump

marxin at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Mar 13 09:12:19 GMT 2020


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

--- Comment #9 from Martin Liška <marxin at gcc dot gnu.org> ---
commit r8-10121-g92902501c2ad030d56fd3347defd00e79187c51f
Author: Eric Botcazou <ebotcazou@gcc.gnu.org>
Date:   Fri Mar 13 09:58:44 2020 +0100

    Fix incorrect filling of delay slots in branchy code at -O2

    The issue is that relax_delay_slots can streamline the CFG in some cases,
    in particular remove BARRIERs, but removing BARRIERs changes the way the
    instructions are associated with (basic) blocks by the liveness analysis
    code in resource.c (find_basic_block) and thus can cause entries in the
    cache maintained by resource.c to become outdated, thus producing wrong
    answers downstream.

    The fix is to invalidate the cache entries affected by the removal of
    BARRIERs in relax_delay_slots, i.e. for the instructions down to the
    next BARRIER.

            PR rtl-optimization/94119
            * resource.h (clear_hashed_info_until_next_barrier): Declare.
            * resource.c (clear_hashed_info_until_next_barrier): New function.
            * reorg.c (add_to_delay_list): Fix formatting.
            (relax_delay_slots): Call clear_hashed_info_until_next_barrier on
            the next instruction after removing a BARRIER.


More information about the Gcc-bugs mailing list