This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fix target/6087


We lost the REG_DEAD note by insertting just the PATTERN, which
turned a pop into a push.  :-(


r~


        * reload1.c (fixup_abnormal_edges): Move insn to edge via sequence.

Index: reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.325.2.3
diff -c -p -d -r1.325.2.3 reload1.c
*** reload1.c	2002/03/18 17:47:04	1.325.2.3
--- reload1.c	2002/03/29 06:14:09
*************** fixup_abnormal_edges ()
*** 9517,9524 ****
  	      next = NEXT_INSN (insn);
  	      if (INSN_P (insn))
  		{
! 	          insert_insn_on_edge (PATTERN (insn), e);
  	          delete_insn (insn);
  		}
  	      insn = next;
  	    }
--- 9517,9535 ----
  	      next = NEXT_INSN (insn);
  	      if (INSN_P (insn))
  		{
! 		  rtx seq;
! 
  	          delete_insn (insn);
+ 
+ 		  /* We're not deleting it, we're moving it.  */
+ 		  INSN_DELETED_P (insn) = 0;
+ 
+ 		  /* Emit a sequence, rather than scarfing the pattern, so
+ 		     that we don't lose REG_NOTES etc.  */
+ 		  /* ??? Could copy the test from gen_sequence, but don't
+ 		     think it's worth the bother.  */
+ 		  seq = gen_rtx_SEQUENCE (VOIDmode, gen_rtvec (1, insn));
+ 	          insert_insn_on_edge (seq, e);
  		}
  	      insn = next;
  	    }
Index: testsuite/g++.dg/opt/reg-stack.C
===================================================================
RCS file: reg-stack.C
diff -N reg-stack.C
*** /dev/null	Tue May  5 13:32:27 1998
--- testsuite/g++.dg/opt/reg-stack.C	Thu Mar 28 22:14:09 2002
***************
*** 0 ****
--- 1,47 ----
+ // PR target/6087
+ // The code that moves around insns emitted by reg-stack to cope with
+ // exception edges lost the REG_DEAD note indicating a pop.  Which
+ // eventually fills up the register stack resulting in Z == NaN.
+ 
+ // { dg-do run }
+ // { dg-options "-O" }
+ 
+ extern "C" void abort ();
+ 
+ struct Base
+ {
+   virtual ~Base() {}
+ };
+ 
+ struct Foo : public Base
+ {
+   Foo ();
+ };
+ 
+ double x = 3;
+ double y = 4;
+ 
+ double bar ()
+ {
+   double z = x*x+y*y;
+   if (z != 25.0)
+     throw 1;
+   return z;
+ }
+ 
+ Foo::Foo ()
+ {
+   bar ();
+ }
+ 
+ int main ()
+ {
+   try {
+     int i;
+     for (i = 0; i < 10; ++i)
+       new Foo;
+   } catch (...) {
+     abort ();
+   }
+   return 0;
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]