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

Jakub Jelinek jakub@redhat.com
Fri Feb 19 15:08:00 GMT 2016


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.

--- 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


More information about the Gcc-patches mailing list