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 c++/6764


The problem here is that the comment in set_label_offsets,

      /* If we know nothing about this label, set the desired offsets.  Note
         that this sets the offset at a label to be the offset before a label
         if we don't know anything about the label.  This is not correct for
         the label after a BARRIER, but is the best guess we can make.  If
         we guessed wrong, we will suppress an elimination that might have
         been possible had we been able to guess correctly.  */

is absolutely correct, and we *did* get the wrong answer for a label
following a barrier.  I'm thinking that perhaps we ought to abort for
this situation, but don't feel like messing with that right now.

The proximate problem is that set_initial_label_offsets doesn't do the
right thing with EH labels (anymore?  I didn't feel like tracking down
the history).  Easily solved.


r~


	* reload1.c (set_initial_eh_label_offset): New.
	(set_initial_label_offsets): Use it.

Index: gcc/reload1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reload1.c,v
retrieving revision 1.454
diff -u -p -r1.454 reload1.c
--- gcc/reload1.c	23 Nov 2004 19:55:17 -0000	1.454
+++ gcc/reload1.c	26 Nov 2004 01:54:51 -0000
@@ -3316,6 +3316,14 @@ set_initial_elim_offsets (void)
   num_not_at_initial_offset = 0;
 }
 
+/* Subroutine of set_initial_label_offsets called via for_each_eh_label.  */
+
+static void
+set_initial_eh_label_offset (rtx label)
+{
+  set_label_offsets (label, NULL_RTX, 1);
+}
+
 /* Initialize the known label offsets.
    Set a known offset for each forced label to be at the initial offset
    of each elimination.  We do this because we assume that all
@@ -3332,6 +3340,8 @@ set_initial_label_offsets (void)
   for (x = forced_labels; x; x = XEXP (x, 1))
     if (XEXP (x, 0))
       set_label_offsets (XEXP (x, 0), NULL_RTX, 1);
+
+  for_each_eh_label (set_initial_eh_label_offset);
 }
 
 /* Set all elimination offsets to the known values for the code label given
Index: gcc/testsuite/g++.dg/opt/eh2.C
===================================================================
RCS file: gcc/testsuite/g++.dg/opt/eh2.C
diff -N gcc/testsuite/g++.dg/opt/eh2.C
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gcc/testsuite/g++.dg/opt/eh2.C	26 Nov 2004 01:54:51 -0000
@@ -0,0 +1,34 @@
+// PR 6764
+// { dg-do run }
+// { dg-options "-O -fomit-frame-pointer" }
+
+extern "C" void abort ();
+
+class test
+{
+ public:
+  test * const me;
+  test () : me(this) { }
+  ~test () { if (me != this) abort (); }
+};
+
+void x1 ()
+{
+  test w1;
+  throw 1;
+}
+
+void x2 ()
+{
+  test w2;
+  x1 ();
+}
+
+int main (void)
+{
+  try {
+    x2 ();
+  } catch (...) {
+  }
+  return 0;
+}


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