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]

[PATCH] Fix dest_cfun->last_label_uid after move_sese_region_to_fn


Hi!

On the attached testcase, one of the std::terminate calling BBs is optimized
away before omp expansion, unfortunately one with highest LABEL_DECL_UID
(<L2> and <L4> are kept, <L8> is not in any bb).  move_sese_region_to_fn
in new_label_mapper copies all the EH labels with their UIDs and then
when moving the individual basic blocks also ensures
dest_cfun->last_label_uid is higher than LABEL_DECL_UID of any label
mentioned in moved LABEL_EXPR.  Unfortunately nothing ensures last_label_uid
is also higher than any label in the new cfun->eh->region_array.  This
during inlining then sometimes leads to two different LABEL_DECLs with the
same LABEL_DECL_UID and not unsurprisingly ICEs afterwards.

Fixed thusly, bootstrapped/regtested on x86_64-linux, committed to trunk.
Will commit to 4.3 when testing finishes there too.

2008-03-10  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/35099
	* tree-cfg.c (new_label_mapper): Update cfun->last_label_uid.

	* g++.dg/gomp/pr35099.C: New test.

--- gcc/tree-cfg.c.jj	2008-02-29 09:15:41.000000000 +0100
+++ gcc/tree-cfg.c	2008-03-10 14:40:55.000000000 +0100
@@ -5871,6 +5871,8 @@ new_label_mapper (tree decl, void *data)
   m->base.from = decl;
   m->to = create_artificial_label ();
   LABEL_DECL_UID (m->to) = LABEL_DECL_UID (decl);
+  if (LABEL_DECL_UID (m->to) >= cfun->last_label_uid)
+    cfun->last_label_uid = LABEL_DECL_UID (m->to) + 1;
 
   slot = htab_find_slot_with_hash (hash, m, m->hash, INSERT);
   gcc_assert (*slot == NULL);
--- gcc/testsuite/g++.dg/gomp/pr35099.C.jj	2008-03-10 14:51:33.000000000 +0100
+++ gcc/testsuite/g++.dg/gomp/pr35099.C	2008-03-10 14:51:10.000000000 +0100
@@ -0,0 +1,39 @@
+// PR middle-end/35099
+// { dg-do compile }
+// { dg-options "-O2 -fopenmp" }
+
+struct A
+{
+  ~A () throw ();
+  void foo ();
+};
+
+struct B
+{
+  B () { A ().foo (); }
+};
+
+void
+bar ()
+{
+#pragma omp parallel
+  {
+  #pragma omp single
+    B ();
+  #pragma omp for
+    for (int i = 0; i < 2; ++i)
+      B ();
+  }
+}
+
+void
+baz ()
+{
+#pragma omp parallel
+  {
+  #pragma omp single
+    B ();
+  #pragma omp single
+    B ();
+  }
+}

	Jakub


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