From a646f6ccc1113db8d1faeb1a902b44c1c7774e8c Mon Sep 17 00:00:00 2001
From: Andrew Haley <aph@redhat.com>
Date: Tue, 1 Oct 2002 12:19:36 +0000
Subject: [PATCH] flow.c (insn_dead_p): When using non-call-exceptions, don't
 eliminate insns that may trap.

2002-09-30  Andrew Haley  <aph@redhat.com>

	* flow.c (insn_dead_p): When using non-call-exceptions, don't
	eliminate insns that may trap.
	* cse.c (insn_live_p): Likewise.

From-SVN: r57688
---
 gcc/ChangeLog | 6 ++++++
 gcc/cse.c     | 4 +++-
 gcc/flow.c    | 4 ++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8325d029bda9..64fa602f8438 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2002-09-30  Andrew Haley  <aph@redhat.com>
+
+	* flow.c (insn_dead_p): When using non-call-exceptions, don't 
+	eliminate insns that may trap.
+	* cse.c (insn_live_p): Likewise.
+
 2002-10-01  Richard Sandiford  <rsandifo@redhat.com>
 
 	* config/mips/mips.h (PROCESSOR_R4121): Rename to PROCESSOR_R4120.
diff --git a/gcc/cse.c b/gcc/cse.c
index 706fe80f4ebc..29c771b93f64 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -7582,7 +7582,9 @@ insn_live_p (insn, counts)
      int *counts;
 {
   int i;
-  if (GET_CODE (PATTERN (insn)) == SET)
+  if (flag_non_call_exceptions && may_trap_p (insn))
+    return true;
+  else if (GET_CODE (PATTERN (insn)) == SET)
     return set_live_p (PATTERN (insn), insn, counts);
   else if (GET_CODE (PATTERN (insn)) == PARALLEL)
     {
diff --git a/gcc/flow.c b/gcc/flow.c
index 2905917cbcc7..d9e3ae3ce402 100644
--- a/gcc/flow.c
+++ b/gcc/flow.c
@@ -2110,6 +2110,10 @@ insn_dead_p (pbi, x, call_ok, notes)
 {
   enum rtx_code code = GET_CODE (x);
 
+  /* Don't eliminate insns that may trap.  */
+  if (flag_non_call_exceptions && may_trap_p (x))
+    return 0;
+
 #ifdef AUTO_INC_DEC
   /* As flow is invoked after combine, we must take existing AUTO_INC
      expressions into account.  */
-- 
GitLab