Fix incorrect filling of delay slots in branchy code at -O2
authorEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 13 Mar 2020 08:58:44 +0000 (09:58 +0100)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 13 Mar 2020 09:03:30 +0000 (10:03 +0100)
commit3e6ab5cefa81165e90fb62abf50e515f85a17e9a
tree83673fa186fe53cda48fbd1dc671d68115091816
parent82f620e2ba4c440c5e89bb1f73d10a11ed0f2eb4
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.
gcc/ChangeLog
gcc/reorg.c
gcc/resource.c
gcc/resource.h