public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Vladimir Makarov <vmakarov@redhat.com>
Cc: gcc-patches@gcc.gnu.org, Dominik Vogt <vogt@linux.vnet.ibm.com>
Subject: [PATCH] Fix up handling of REG_EH_REGION notes in LRA (PR middle-end/69838)
Date: Fri, 19 Feb 2016 15:08:00 -0000	[thread overview]
Message-ID: <20160219150837.GO3017@tucnak.redhat.com> (raw)

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.

--- 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);
+    }
 }
-
 \f
 
 /* Replace all references to register OLD_REGNO in *LOC with pseudo

	Jakub

             reply	other threads:[~2016-02-19 15:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-19 15:08 Jakub Jelinek [this message]
2016-02-19 15:24 ` Dominik Vogt
2016-02-19 16:17 ` Vladimir Makarov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160219150837.GO3017@tucnak.redhat.com \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=vmakarov@redhat.com \
    --cc=vogt@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).