OSDN Git Service

PR middle-end/44102
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 May 2010 17:18:24 +0000 (17:18 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 May 2010 17:18:24 +0000 (17:18 +0000)
* cfgcleanup.c (try_optimize_cfg): When removing trivially empty
bb with no successors, move footer whenever in IR_RTL_CFGLAYOUT
mode, not just when CLEANUP_CFGLAYOUT, and when in IR_RTL_CFGRTL
add BARRIER after previous bb if needed.

* g++.dg/ext/asmgoto1.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159495 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cfgcleanup.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/asmgoto1.C [new file with mode: 0644]

index a469dee..eeb5110 100644 (file)
@@ -1,3 +1,11 @@
+2010-05-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/44102
+       * cfgcleanup.c (try_optimize_cfg): When removing trivially empty
+       bb with no successors, move footer whenever in IR_RTL_CFGLAYOUT
+       mode, not just when CLEANUP_CFGLAYOUT, and when in IR_RTL_CFGRTL
+       add BARRIER after previous bb if needed.
+
 2010-05-17  Nathan Froyd  <froydnj@codesourcery.com>
  
        * tree.c (build_function_type_list_1): Remove bogus assert condition.
index 75f5651..7139e3a 100644 (file)
@@ -1999,24 +1999,40 @@ try_optimize_cfg (int mode)
                      && single_succ_edge (ENTRY_BLOCK_PTR)->dest != b))
                {
                  c = b->prev_bb;
-                 if ((mode & CLEANUP_CFGLAYOUT)
-                     && EDGE_COUNT (b->preds) > 0
-                     && b->il.rtl->footer
-                     && BARRIER_P (b->il.rtl->footer))
+                 if (EDGE_COUNT (b->preds) > 0)
                    {
                      edge e;
                      edge_iterator ei;
 
-                     FOR_EACH_EDGE (e, ei, b->preds)
-                       if (e->flags & EDGE_FALLTHRU)
-                         {
-                           if (e->src->il.rtl->footer == NULL)
-                             {
-                               e->src->il.rtl->footer = b->il.rtl->footer;
-                               b->il.rtl->footer = NULL;
-                             }
-                           break;
-                         }
+                     if (current_ir_type () == IR_RTL_CFGLAYOUT)
+                       {
+                         if (b->il.rtl->footer
+                             && BARRIER_P (b->il.rtl->footer))
+                           FOR_EACH_EDGE (e, ei, b->preds)
+                             if ((e->flags & EDGE_FALLTHRU)
+                                 && e->src->il.rtl->footer == NULL)
+                               {
+                                 if (b->il.rtl->footer)
+                                   {
+                                     e->src->il.rtl->footer = b->il.rtl->footer;
+                                     b->il.rtl->footer = NULL;
+                                   }
+                                 else
+                                   {
+                                     start_sequence ();
+                                     e->src->il.rtl->footer = emit_barrier ();
+                                     end_sequence ();
+                                   }
+                               }
+                       }
+                     else
+                       {
+                         rtx last = get_last_bb_insn (b);
+                         if (last && BARRIER_P (last))
+                           FOR_EACH_EDGE (e, ei, b->preds)
+                             if ((e->flags & EDGE_FALLTHRU))
+                               emit_barrier_after (BB_END (e->src));
+                       }
                    }
                  delete_basic_block (b);
                  if (!(mode & CLEANUP_CFGLAYOUT))
index ba78c98..dfe8de7 100644 (file)
@@ -1,3 +1,8 @@
+2010-05-17  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/44102
+       * g++.dg/ext/asmgoto1.C: New test.
+
 2010-05-17  Martin Jambor  <mjambor@suse.cz>
 
        PR middle-end/44133
diff --git a/gcc/testsuite/g++.dg/ext/asmgoto1.C b/gcc/testsuite/g++.dg/ext/asmgoto1.C
new file mode 100644 (file)
index 0000000..dda5167
--- /dev/null
@@ -0,0 +1,32 @@
+// PR middle-end/44102
+// { dg-do compile }
+// { dg-options "-O2" }
+
+void baz (void);
+struct A { A (); ~A (); };
+
+static inline int
+foo (void)
+{
+  asm goto ("" : : : : l1, l2);
+  __builtin_unreachable ();
+ l1:
+  return 1;
+ l2:
+  return 0;
+}
+
+int
+bar (int x)
+{
+  if (x == 5)
+    {
+      A a, b;
+      baz ();
+    }
+  if (foo () || x == 6)
+    x = 1;
+  else
+    x = 2;
+  return x;
+}