diff options
author | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2020-03-13 09:58:44 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2020-03-13 10:03:30 +0100 |
commit | 3e6ab5cefa81165e90fb62abf50e515f85a17e9a (patch) | |
tree | 83673fa186fe53cda48fbd1dc671d68115091816 /gcc/resource.c | |
parent | 82f620e2ba4c440c5e89bb1f73d10a11ed0f2eb4 (diff) | |
download | gcc-3e6ab5cefa81165e90fb62abf50e515f85a17e9a.zip gcc-3e6ab5cefa81165e90fb62abf50e515f85a17e9a.tar.gz gcc-3e6ab5cefa81165e90fb62abf50e515f85a17e9a.tar.bz2 |
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.
Diffstat (limited to 'gcc/resource.c')
-rw-r--r-- | gcc/resource.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/gcc/resource.c b/gcc/resource.c index d26217c..32faa73 100644 --- a/gcc/resource.c +++ b/gcc/resource.c @@ -1282,7 +1282,26 @@ clear_hashed_info_for_insn (rtx_insn *insn) tinfo->block = -1; } } - + +/* Clear any hashed information that we have stored for instructions + between INSN and the next BARRIER that follow a JUMP or a LABEL. */ + +void +clear_hashed_info_until_next_barrier (rtx_insn *insn) +{ + while (insn && !BARRIER_P (insn)) + { + if (JUMP_P (insn) || LABEL_P (insn)) + { + rtx_insn *next = next_active_insn (insn); + if (next) + clear_hashed_info_for_insn (next); + } + + insn = next_nonnote_insn (insn); + } +} + /* Increment the tick count for the basic block that contains INSN. */ void |