diff mbox

Fix up handling of REG_EH_REGION notes in LRA (PR middle-end/69838)

Message ID 20160219150837.GO3017@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Feb. 19, 2016, 3:08 p.m. UTC
Hi!

For -fnon-call-exceptions, if an instruction with REG_EH_REGION note is
reloaded, we should copy or move it to the instruction(s) corresponding to
the original one that could throw.  reload1.c apparently does this, but LRA
does not, so we can end up with REG_EH_REGION notes being dropped, or not
present on insns that actually can throw etc.

Fixed by calling the functions reload1.c does for this purpose.

Bootstrapped/regtested on x86_64-linux (including Ada) and i686-linux
(without Ada), and Dominik has kindly tested this on s390x-linux
(presumably with Ada, but don't know for sure).  Ok for trunk?

2016-02-19  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/69838
	* lra.c (lra_process_new_insns): If non-call exceptions are enabled,
	call copy_reg_eh_region_note_forward on before and/or after sequences
	and remove note from insn if it no longer can throw.


	Jakub

Comments

Dominik Vogt Feb. 19, 2016, 3:24 p.m. UTC | #1
On Fri, Feb 19, 2016 at 04:08:37PM +0100, Jakub Jelinek wrote:
> For -fnon-call-exceptions, if an instruction with REG_EH_REGION note is
> reloaded, we should copy or move it to the instruction(s) corresponding to
> the original one that could throw.  reload1.c apparently does this, but LRA
> does not, so we can end up with REG_EH_REGION notes being dropped, or not
> present on insns that actually can throw etc.
> 
> Fixed by calling the functions reload1.c does for this purpose.
> 
> Bootstrapped/regtested on x86_64-linux (including Ada) and i686-linux
> (without Ada),

> and Dominik has kindly tested this on s390x-linux
> (presumably with Ada, but don't know for sure).

Yes, all languages with the whole testsuite.

Ciao

Dominik ^_^  ^_^
Vladimir Makarov Feb. 19, 2016, 4:17 p.m. UTC | #2
On 02/19/2016 10:08 AM, Jakub Jelinek wrote:
> Hi!
>
> For -fnon-call-exceptions, if an instruction with REG_EH_REGION note is
> reloaded, we should copy or move it to the instruction(s) corresponding to
> the original one that could throw.  reload1.c apparently does this, but LRA
> does not, so we can end up with REG_EH_REGION notes being dropped, or not
> present on insns that actually can throw etc.
>
> Fixed by calling the functions reload1.c does for this purpose.
>
> Bootstrapped/regtested on x86_64-linux (including Ada) and i686-linux
> (without Ada), and Dominik has kindly tested this on s390x-linux
> (presumably with Ada, but don't know for sure).  Ok for trunk?
>
>
Yes.  Thanks, Jakub.
diff mbox

Patch

--- gcc/lra.c.jj	2016-01-04 14:55:52.000000000 +0100
+++ gcc/lra.c	2016-02-19 12:01:49.747724404 +0100
@@ -1742,20 +1742,29 @@  lra_process_new_insns (rtx_insn *insn, r
     }
   if (before != NULL_RTX)
     {
+      if (cfun->can_throw_non_call_exceptions)
+	copy_reg_eh_region_note_forward (insn, before, NULL);
       emit_insn_before (before, insn);
       push_insns (PREV_INSN (insn), PREV_INSN (before));
       setup_sp_offset (before, PREV_INSN (insn));
     }
   if (after != NULL_RTX)
     {
+      if (cfun->can_throw_non_call_exceptions)
+	copy_reg_eh_region_note_forward (insn, after, NULL);
       for (last = after; NEXT_INSN (last) != NULL_RTX; last = NEXT_INSN (last))
 	;
       emit_insn_after (after, insn);
       push_insns (last, insn);
       setup_sp_offset (after, last);
     }
+  if (cfun->can_throw_non_call_exceptions)
+    {
+      rtx note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
+      if (note && !insn_could_throw_p (insn))
+	remove_note (insn, note);
+    }
 }
-
 
 
 /* Replace all references to register OLD_REGNO in *LOC with pseudo