diff mbox series

lra: Stop eh_return data regs being incorrectly marked live [PR92989]

Message ID mpt8sjawf3g.fsf@arm.com
State New
Headers show
Series lra: Stop eh_return data regs being incorrectly marked live [PR92989] | expand

Commit Message

Richard Sandiford April 5, 2020, 7:45 a.m. UTC
lra_assign has an assert to make sure that no pseudo is allocated
to a conflicting hard register.  It used to be restricted to
!flag_ipa_ra, but in g:a1e6ee38e708ef2bdef4 I'd enabled it for
flag_ipa_ra too.  It then tripped a few times while building
libstdc++ for mips-mti-linux.

Previous patches fixed one of the problems: registers clobbered
by the taking of an exception were being treated as live at the
beginning of the EH receiver, and this got propagated to predecessor
blocks.  But it turns out that there was a second problem: eh_return
data registers were also being marked live in the same way.

These registers are defined by the unwinder and so in reality they
really are live on entry to the EH receiver.  But definitions can
only happen in blocks, not on edges, so for liveness purposes
we use artificial definitions at the start of the EH receiver.
process_bb_lives should therefore model the effect of a definition,
not a plain use.

Tested this time by building a full mips-mti-linux-gnu toolchain
(including the prerequisite 26 glibc sysroots).  Also boostrapped
& regression tested on aarch64-linux-gnu and x86_64-linux-gnu.
OK to install?

Richard


2020-04-05  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	PR rtl-optimization/92989
	* lra-lives.c (process_bb_lives): Do not treat eh_return data
	registers as being live at the beginning of the EH receiver.
---
 gcc/lra-lives.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Li, Pan2 via Gcc-patches April 6, 2020, 5:43 p.m. UTC | #1
On Sun, 2020-04-05 at 08:45 +0100, Richard Sandiford wrote:
> lra_assign has an assert to make sure that no pseudo is allocated
> to a conflicting hard register.  It used to be restricted to
> !flag_ipa_ra, but in g:a1e6ee38e708ef2bdef4 I'd enabled it for
> flag_ipa_ra too.  It then tripped a few times while building
> libstdc++ for mips-mti-linux.
> 
> Previous patches fixed one of the problems: registers clobbered
> by the taking of an exception were being treated as live at the
> beginning of the EH receiver, and this got propagated to predecessor
> blocks.  But it turns out that there was a second problem: eh_return
> data registers were also being marked live in the same way.
> 
> These registers are defined by the unwinder and so in reality they
> really are live on entry to the EH receiver.  But definitions can
> only happen in blocks, not on edges, so for liveness purposes
> we use artificial definitions at the start of the EH receiver.
> process_bb_lives should therefore model the effect of a definition,
> not a plain use.
> 
> Tested this time by building a full mips-mti-linux-gnu toolchain
> (including the prerequisite 26 glibc sysroots).  Also boostrapped
> & regression tested on aarch64-linux-gnu and x86_64-linux-gnu.
> OK to install?
> 
> Richard
> 
> 
> 2020-04-05  Richard Sandiford  <richard.sandiford@arm.com>
> 
> gcc/
> 	PR rtl-optimization/92989
> 	* lra-lives.c (process_bb_lives): Do not treat eh_return data
> 	registers as being live at the beginning of the EH receiver.
OK
jeff
>
diff mbox series

Patch

diff --git a/gcc/lra-lives.c b/gcc/lra-lives.c
index c8780779a11..917c617903f 100644
--- a/gcc/lra-lives.c
+++ b/gcc/lra-lives.c
@@ -1014,13 +1014,19 @@  process_bb_lives (basic_block bb, int &curr_point, bool dead_insn_p)
     }
 
   if (bb_has_eh_pred (bb))
+    /* Any pseudos that are currently live conflict with the eh_return
+       data registers.  For liveness purposes, these registers are set
+       by artificial definitions at the start of the BB, so are not
+       actually live on entry.  */
     for (j = 0; ; ++j)
       {
 	unsigned int regno = EH_RETURN_DATA_REGNO (j);
 
 	if (regno == INVALID_REGNUM)
 	  break;
+
 	make_hard_regno_live (regno);
+	make_hard_regno_dead (regno);
       }
 
   /* Pseudos can't go in stack regs at the start of a basic block that