Hi!

I've committed following 3 backports to 4.7 branch after
bootstrapping/regtesting it on x86_64-linux and i686-linux.

        Jakub
2012-06-14  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2012-06-06  Jakub Jelinek  <ja...@redhat.com>

        PR libgomp/52993
        * config/linux/lock.c (gomp_init_nest_lock_25): Fix up last
        argument to memset call.

--- libgomp/config/linux/lock.c (revision 188275)
+++ libgomp/config/linux/lock.c (revision 188276)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2008, 2009, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2008, 2009, 2011, 2012 Free Software Foundation, Inc.
    Contributed by Richard Henderson <r...@redhat.com>.
 
    This file is part of the GNU OpenMP Library (libgomp).
@@ -175,7 +175,7 @@ static inline int gomp_tid (void)
 void
 gomp_init_nest_lock_25 (omp_nest_lock_25_t *lock)
 {
-  memset (lock, 0, sizeof (lock));
+  memset (lock, 0, sizeof (*lock));
 }
 
 void
2012-06-14  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2012-06-07  Jakub Jelinek  <ja...@redhat.com>

        PR middle-end/53580
        * omp-low.c (scan_omp_1_stmt): If check_omp_nesting_restrictions
        returns false, replace stmt with GIMPLE_NOP.
        (check_omp_nesting_restrictions): Instead of issuing warnings,
        issue errors and return false if any errors were reported.

        * gcc.dg/gomp/nesting-1.c: Expect errors rather than warnings.
        * gcc.dg/gomp/critical-4.c: Likewise.
        * gfortran.dg/gomp/appendix-a/a.35.1.f90: Likewise.
        * gfortran.dg/gomp/appendix-a/a.35.3.f90: Likewise.
        * gfortran.dg/gomp/appendix-a/a.35.4.f90: Likewise.
        * gfortran.dg/gomp/appendix-a/a.35.6.f90: Likewise.
        * c-c++-common/gomp/pr53580.c: New test.

        * testsuite/libgomp.c/pr26943-2.c: Remove #pragma omp barrier,
        use GOMP_barrier () call instead.
        * testsuite/libgomp.c/pr26943-3.c: Likewise.
        * testsuite/libgomp.c/pr26943-4.c: Likewise.
        * testsuite/libgomp.fortran/vla4.f90: Remove !$omp barrier,
        call GOMP_barrier instead.
        * testsuite/libgomp.fortran/vla5.f90: Likewise.

--- libgomp/testsuite/libgomp.fortran/vla4.f90  (revision 188297)
+++ libgomp/testsuite/libgomp.fortran/vla4.f90  (revision 188298)
@@ -10,6 +10,10 @@ contains
 
   subroutine foo (c, d, e, f, g, h, i, j, k, n)
     use omp_lib
+    interface
+      subroutine GOMP_barrier () bind(c, name="GOMP_barrier")
+      end subroutine
+    end interface
     integer :: n
     character (len = *) :: c
     character (len = n) :: d
@@ -94,7 +98,7 @@ contains
     forall (p = 1:2, q = 3:7, r = 1:7) u(p, q, r) = 30 - x - p + q - 2 * r
     forall (p = 1:5, q = 3:7, p + q .le. 8) v(p, q) = w(1:7)
     forall (p = 1:5, q = 3:7, p + q .gt. 8) v(p, q) = w(20:26)
-!$omp barrier          ! { dg-warning "may not be closely nested" }
+    call GOMP_barrier
     y = ''
     if (x .eq. 0) y = '0'
     if (x .eq. 1) y = '1'
--- libgomp/testsuite/libgomp.fortran/vla5.f90  (revision 188297)
+++ libgomp/testsuite/libgomp.fortran/vla5.f90  (revision 188298)
@@ -10,6 +10,10 @@ contains
 
   subroutine foo (c, d, e, f, g, h, i, j, k, n)
     use omp_lib
+    interface
+      subroutine GOMP_barrier () bind(c, name="GOMP_barrier")
+      end subroutine
+    end interface
     integer :: n
     character (len = *) :: c
     character (len = n) :: d
@@ -66,7 +70,7 @@ contains
     forall (p = 1:2, q = 3:7, r = 1:7) u(p, q, r) = 30 - x - p + q - 2 * r
     forall (p = 1:5, q = 3:7, p + q .le. 8) v(p, q) = w(1:7)
     forall (p = 1:5, q = 3:7, p + q .gt. 8) v(p, q) = w(20:26)
-!$omp barrier          ! { dg-warning "may not be closely nested" }
+    call GOMP_barrier
     y = ''
     if (x .eq. 0) y = '0'
     if (x .eq. 1) y = '1'
--- libgomp/testsuite/libgomp.c/pr26943-2.c     (revision 188297)
+++ libgomp/testsuite/libgomp.c/pr26943-2.c     (revision 188298)
@@ -3,6 +3,7 @@
 
 extern int omp_set_dynamic (int);
 extern void abort (void);
+extern void GOMP_barrier (void);
 
 int a = 8, b = 12, c = 16, d = 20, j = 0;
 char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
@@ -20,7 +21,7 @@ main (void)
     {
       if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
        j++;
-#pragma omp barrier    /* { dg-warning "may not be closely nested" } */
+      GOMP_barrier ();
 #pragma omp atomic
       a += i;
       b += i;
@@ -31,7 +32,7 @@ main (void)
       f[0] += i;
       g[0] = 'g' + i;
       h[0] = 'h' + i;
-#pragma omp barrier    /* { dg-warning "may not be closely nested" } */
+      GOMP_barrier ();
       if (a != 8 + 6 || b != 12 + i || c != i || d != i)
        j += 8;
       if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
--- libgomp/testsuite/libgomp.c/pr26943-3.c     (revision 188297)
+++ libgomp/testsuite/libgomp.c/pr26943-3.c     (revision 188298)
@@ -4,6 +4,7 @@
 extern int omp_set_dynamic (int);
 extern int omp_get_thread_num (void);
 extern void abort (void);
+extern void GOMP_barrier (void);
 
 int a = 8, b = 12, c = 16, d = 20, j = 0, l = 0;
 char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
@@ -26,7 +27,7 @@ main (void)
        {
          if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
            j++;
-#pragma omp barrier    /* { dg-warning "may not be closely nested" } */
+         GOMP_barrier ();
 #pragma omp atomic
          a += i;
          b += i;
@@ -37,7 +38,7 @@ main (void)
          f[0] += i;
          g[0] = 'g' + i;
          h[0] = 'h' + i;
-#pragma omp barrier    /* { dg-warning "may not be closely nested" } */
+         GOMP_barrier ();
          if (a != 8 + 6 || b != 12 + i || c != i || d != i)
            j += 8;
          if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
--- libgomp/testsuite/libgomp.c/pr26943-4.c     (revision 188297)
+++ libgomp/testsuite/libgomp.c/pr26943-4.c     (revision 188298)
@@ -4,6 +4,7 @@
 extern int omp_set_dynamic (int);
 extern int omp_get_thread_num (void);
 extern void abort (void);
+extern void GOMP_barrier (void);
 
 int a = 8, b = 12, c = 16, d = 20, j = 0, l = 0;
 char e[10] = "a", f[10] = "b", g[10] = "c", h[10] = "d";
@@ -27,7 +28,7 @@ main (void)
        {
          if (a != 8 || b != 12 || e[0] != 'a' || f[0] != 'b')
            j++;
-#pragma omp barrier    /* { dg-warning "may not be closely nested" } */
+         GOMP_barrier ();
 #pragma omp atomic
          a += i;
          b += i;
@@ -38,7 +39,7 @@ main (void)
          f[0] += i;
          g[0] = 'g' + i;
          h[0] = 'h' + i;
-#pragma omp barrier    /* { dg-warning "may not be closely nested" } */
+         GOMP_barrier ();
          if (a != 8 + 6 || b != 12 + i || c != i || d != i)
            j += 8;
          if (e[0] != 'a' + 6 || f[0] != 'b' + i || g[0] != 'g' + i)
--- gcc/omp-low.c       (revision 188297)
+++ gcc/omp-low.c       (revision 188298)
@@ -1823,8 +1823,8 @@ scan_omp_single (gimple stmt, omp_contex
 
 
 /* Check OpenMP nesting restrictions.  */
-static void
-check_omp_nesting_restrictions (gimple  stmt, omp_context *ctx)
+static bool
+check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
 {
   switch (gimple_code (stmt))
     {
@@ -1843,17 +1843,19 @@ check_omp_nesting_restrictions (gimple
          case GIMPLE_OMP_TASK:
            if (is_gimple_call (stmt))
              {
-               warning (0, "barrier region may not be closely nested inside "
-                           "of work-sharing, critical, ordered, master or "
-                           "explicit task region");
-               return;
+               error_at (gimple_location (stmt),
+                         "barrier region may not be closely nested inside "
+                         "of work-sharing, critical, ordered, master or "
+                         "explicit task region");
+               return false;
              }
-           warning (0, "work-sharing region may not be closely nested inside "
-                       "of work-sharing, critical, ordered, master or explicit 
"
-                       "task region");
-           return;
+           error_at (gimple_location (stmt),
+                     "work-sharing region may not be closely nested inside "
+                     "of work-sharing, critical, ordered, master or explicit "
+                     "task region");
+           return false;
          case GIMPLE_OMP_PARALLEL:
-           return;
+           return true;
          default:
            break;
          }
@@ -1866,11 +1868,12 @@ check_omp_nesting_restrictions (gimple
          case GIMPLE_OMP_SECTIONS:
          case GIMPLE_OMP_SINGLE:
          case GIMPLE_OMP_TASK:
-           warning (0, "master region may not be closely nested inside "
-                       "of work-sharing or explicit task region");
-           return;
+           error_at (gimple_location (stmt),
+                     "master region may not be closely nested inside "
+                     "of work-sharing or explicit task region");
+           return false;
          case GIMPLE_OMP_PARALLEL:
-           return;
+           return true;
          default:
            break;
          }
@@ -1881,17 +1884,22 @@ check_omp_nesting_restrictions (gimple
          {
          case GIMPLE_OMP_CRITICAL:
          case GIMPLE_OMP_TASK:
-           warning (0, "ordered region may not be closely nested inside "
-                       "of critical or explicit task region");
-           return;
+           error_at (gimple_location (stmt),
+                     "ordered region may not be closely nested inside "
+                     "of critical or explicit task region");
+           return false;
          case GIMPLE_OMP_FOR:
            if (find_omp_clause (gimple_omp_for_clauses (ctx->stmt),
                                 OMP_CLAUSE_ORDERED) == NULL)
-             warning (0, "ordered region must be closely nested inside "
+             {
+               error_at (gimple_location (stmt),
+                         "ordered region must be closely nested inside "
                          "a loop region with an ordered clause");
-           return;
+               return false;
+             }
+           return true;
          case GIMPLE_OMP_PARALLEL:
-           return;
+           return true;
          default:
            break;
          }
@@ -1902,14 +1910,16 @@ check_omp_nesting_restrictions (gimple
            && (gimple_omp_critical_name (stmt)
                == gimple_omp_critical_name (ctx->stmt)))
          {
-           warning (0, "critical region may not be nested inside a critical "
-                       "region with the same name");
-           return;
+           error_at (gimple_location (stmt),
+                     "critical region may not be nested inside a critical "
+                     "region with the same name");
+           return false;
          }
       break;
     default:
       break;
     }
+  return true;
 }
 
 
@@ -1980,14 +1990,20 @@ scan_omp_1_stmt (gimple_stmt_iterator *g
   /* Check the OpenMP nesting restrictions.  */
   if (ctx != NULL)
     {
+      bool remove = false;
       if (is_gimple_omp (stmt))
-       check_omp_nesting_restrictions (stmt, ctx);
+       remove = !check_omp_nesting_restrictions (stmt, ctx);
       else if (is_gimple_call (stmt))
        {
          tree fndecl = gimple_call_fndecl (stmt);
          if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
              && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_GOMP_BARRIER)
-           check_omp_nesting_restrictions (stmt, ctx);
+           remove = !check_omp_nesting_restrictions (stmt, ctx);
+       }
+      if (remove)
+       {
+         stmt = gimple_build_nop ();
+         gsi_replace (gsi, stmt, false);
        }
     }
 
--- gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.1.f90        (revision 
188297)
+++ gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.1.f90        (revision 
188298)
@@ -10,7 +10,7 @@
 !$OMP DO
           DO I = 1, N
             ! incorrect nesting of loop regions
-!$OMP DO     ! { dg-warning "may not be closely nested" }
+!$OMP DO     ! { dg-error "may not be closely nested" }
              DO J = 1, N
                 CALL WORK(I,J)
              END DO
--- gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.3.f90        (revision 
188297)
+++ gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.3.f90        (revision 
188298)
@@ -7,7 +7,7 @@
 !$OMP DO
           DO I = 1, N
               ! incorrect nesting of regions
-!$OMP SINGLE   ! { dg-warning "may not be closely nested" }
+!$OMP SINGLE   ! { dg-error "may not be closely nested" }
                CALL WORK(I, 1)
 !$OMP END SINGLE
           END DO
--- gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.4.f90        (revision 
188297)
+++ gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.4.f90        (revision 
188298)
@@ -8,7 +8,7 @@
           DO I = 1, N
              CALL WORK(I, 1)
 ! incorrect nesting of barrier region in a loop region
-!$OMP BARRIER  ! { dg-warning "may not be closely nested" }
+!$OMP BARRIER  ! { dg-error "may not be closely nested" }
              CALL WORK(I, 2)
           END DO
 !$OMP END PARALLEL
--- gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.6.f90        (revision 
188297)
+++ gcc/testsuite/gfortran.dg/gomp/appendix-a/a.35.6.f90        (revision 
188298)
@@ -6,7 +6,7 @@
 !$OMP SINGLE
            CALL WORK(N,1)
 ! incorrect nesting of barrier region in a single region
-!$OMP BARRIER  ! { dg-warning "may not be closely nested" }
+!$OMP BARRIER  ! { dg-error "may not be closely nested" }
             CALL WORK(N,2)
 !$OMP END SINGLE
 !$OMP END PARALLEL
--- gcc/testsuite/gcc.dg/gomp/critical-4.c      (revision 188297)
+++ gcc/testsuite/gcc.dg/gomp/critical-4.c      (revision 188298)
@@ -15,7 +15,7 @@ void
 foo2 (void)
 {
   #pragma omp critical
-  #pragma omp critical         /* { dg-warning "with the same name" } */
+  #pragma omp critical         /* { dg-error "with the same name" } */
     bar (0);
 }
 
@@ -23,6 +23,6 @@ void
 foo3 (void)
 {
   #pragma omp critical(foo)
-  #pragma omp critical(foo)    /* { dg-warning "with the same name" } */
+  #pragma omp critical(foo)    /* { dg-error "with the same name" } */
     bar (0);
 }
--- gcc/testsuite/gcc.dg/gomp/nesting-1.c       (revision 188297)
+++ gcc/testsuite/gcc.dg/gomp/nesting-1.c       (revision 188298)
@@ -8,89 +8,89 @@ f1 (void)
   #pragma omp for
   for (i = 0; i < 3; i++)
     {
-      #pragma omp for          /* { dg-warning "may not be closely nested" } */
+      #pragma omp for          /* { dg-error "may not be closely nested" } */
       for (j = 0; j < 3; j++)
        ;
-      #pragma omp sections     /* { dg-warning "may not be closely nested" } */
+      #pragma omp sections     /* { dg-error "may not be closely nested" } */
       {
        ;
       #pragma omp section
        ;
       }
-      #pragma omp single       /* { dg-warning "may not be closely nested" } */
+      #pragma omp single       /* { dg-error "may not be closely nested" } */
        ;
-    #pragma omp master         /* { dg-warning "may not be closely nested" } */
+    #pragma omp master         /* { dg-error "may not be closely nested" } */
       ;
-      #pragma omp barrier      /* { dg-warning "may not be closely nested" } */
+      #pragma omp barrier      /* { dg-error "may not be closely nested" } */
     }
   #pragma omp sections
   {
-    #pragma omp for            /* { dg-warning "may not be closely nested" } */
+    #pragma omp for            /* { dg-error "may not be closely nested" } */
     for (j = 0; j < 3; j++)
       ;
-    #pragma omp sections       /* { dg-warning "may not be closely nested" } */
+    #pragma omp sections       /* { dg-error "may not be closely nested" } */
     {
       ;
     #pragma omp section
       ;
     }
-    #pragma omp single         /* { dg-warning "may not be closely nested" } */
+    #pragma omp single         /* { dg-error "may not be closely nested" } */
       ;
-    #pragma omp master         /* { dg-warning "may not be closely nested" } */
+    #pragma omp master         /* { dg-error "may not be closely nested" } */
       ;
     #pragma omp section
       ;
   }
   #pragma omp single
   {
-    #pragma omp for            /* { dg-warning "may not be closely nested" } */
+    #pragma omp for            /* { dg-error "may not be closely nested" } */
     for (j = 0; j < 3; j++)
       ;
-    #pragma omp sections       /* { dg-warning "may not be closely nested" } */
+    #pragma omp sections       /* { dg-error "may not be closely nested" } */
     {
       ;
     #pragma omp section
       ;
     }
-    #pragma omp single         /* { dg-warning "may not be closely nested" } */
+    #pragma omp single         /* { dg-error "may not be closely nested" } */
       ;
-    #pragma omp master         /* { dg-warning "may not be closely nested" } */
+    #pragma omp master         /* { dg-error "may not be closely nested" } */
       ;
-    #pragma omp barrier                /* { dg-warning "may not be closely 
nested" } */
+    #pragma omp barrier                /* { dg-error "may not be closely 
nested" } */
   }
   #pragma omp master
   {
-    #pragma omp for            /* { dg-warning "may not be closely nested" } */
+    #pragma omp for            /* { dg-error "may not be closely nested" } */
     for (j = 0; j < 3; j++)
       ;
-    #pragma omp sections       /* { dg-warning "may not be closely nested" } */
+    #pragma omp sections       /* { dg-error "may not be closely nested" } */
     {
       ;
     #pragma omp section
       ;
     }
-    #pragma omp single         /* { dg-warning "may not be closely nested" } */
+    #pragma omp single         /* { dg-error "may not be closely nested" } */
       ;
     #pragma omp master
       ;
-    #pragma omp barrier                /* { dg-warning "may not be closely 
nested" } */
+    #pragma omp barrier                /* { dg-error "may not be closely 
nested" } */
   }
   #pragma omp task
   {
-    #pragma omp for            /* { dg-warning "may not be closely nested" } */
+    #pragma omp for            /* { dg-error "may not be closely nested" } */
     for (j = 0; j < 3; j++)
       ;
-    #pragma omp sections       /* { dg-warning "may not be closely nested" } */
+    #pragma omp sections       /* { dg-error "may not be closely nested" } */
     {
       ;
     #pragma omp section
       ;
     }
-    #pragma omp single         /* { dg-warning "may not be closely nested" } */
+    #pragma omp single         /* { dg-error "may not be closely nested" } */
       ;
-    #pragma omp master         /* { dg-warning "may not be closely nested" } */
+    #pragma omp master         /* { dg-error "may not be closely nested" } */
       ;
-    #pragma omp barrier                /* { dg-warning "may not be closely 
nested" } */
+    #pragma omp barrier                /* { dg-error "may not be closely 
nested" } */
   }
   #pragma omp parallel
   {
@@ -117,20 +117,20 @@ f2 (void)
   int i, j;
   #pragma omp ordered
   {
-    #pragma omp for            /* { dg-warning "may not be closely nested" } */
+    #pragma omp for            /* { dg-error "may not be closely nested" } */
     for (j = 0; j < 3; j++)
       ;
-    #pragma omp sections       /* { dg-warning "may not be closely nested" } */
+    #pragma omp sections       /* { dg-error "may not be closely nested" } */
     {
       ;
     #pragma omp section
       ;
     }
-    #pragma omp single         /* { dg-warning "may not be closely nested" } */
+    #pragma omp single         /* { dg-error "may not be closely nested" } */
       ;
     #pragma omp master
       ;
-    #pragma omp barrier                /* { dg-warning "may not be closely 
nested" } */
+    #pragma omp barrier                /* { dg-error "may not be closely 
nested" } */
   }
 }
 
@@ -139,7 +139,7 @@ f3 (void)
 {
   #pragma omp critical
   {
-    #pragma omp ordered                /* { dg-warning "may not be closely 
nested" } */
+    #pragma omp ordered                /* { dg-error "may not be closely 
nested" } */
       ;
   }
 }
@@ -149,7 +149,7 @@ f4 (void)
 {
   #pragma omp task
   {
-    #pragma omp ordered                /* { dg-warning "may not be closely 
nested" } */
+    #pragma omp ordered                /* { dg-error "may not be closely 
nested" } */
       ;
   }
 }
@@ -161,7 +161,7 @@ f5 (void)
   #pragma omp for
   for (i = 0; i < 10; i++)
     {
-      #pragma omp ordered              /* { dg-warning "must be closely 
nested" } */
+      #pragma omp ordered              /* { dg-error "must be closely nested" 
} */
        ;
     }
   #pragma omp for ordered
@@ -190,9 +190,9 @@ f7 (void)
     #pragma omp critical
       ;
   #pragma omp critical (bar)
-    #pragma omp critical (bar)         /* { dg-warning "may not be nested" } */
+    #pragma omp critical (bar)         /* { dg-error "may not be nested" } */
       ;
   #pragma omp critical
-    #pragma omp critical               /* { dg-warning "may not be nested" } */
+    #pragma omp critical               /* { dg-error "may not be nested" } */
       ;
 }
--- gcc/testsuite/c-c++-common/gomp/pr53580.c   (revision 0)
+++ gcc/testsuite/c-c++-common/gomp/pr53580.c   (revision 188298)
@@ -0,0 +1,19 @@
+/* PR middle-end/53580 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+int
+main ()
+{
+  int x, y, v = 0;
+
+#pragma omp parallel
+  #pragma omp for
+    for (x = 0; x < 10; x++)
+      {
+      #pragma omp for reduction(+: v)  /* { dg-error "work-sharing region may 
not be closely nested inside of work-sharing" } */
+       for (y = 0; y < 10; y++)
+         v++;
+      }
+  return v - 100;
+}
2012-06-14  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2012-06-12  Jakub Jelinek  <ja...@redhat.com>

        PR rtl-optimization/53589
        * cfgrtl.c (force_nonfallthru_and_redirect): Do asm_goto_edge
        discovery even when e->dest != target.  If any LABEL_REF points
        to e->dest label, redirect it to target's label.

        * gcc.dg/torture/pr53589.c: New test.

--- gcc/cfgrtl.c        (revision 188427)
+++ gcc/cfgrtl.c        (revision 188428)
@@ -1293,21 +1293,21 @@ force_nonfallthru_and_redirect (edge e,
     }
 
   /* If e->src ends with asm goto, see if any of the ASM_OPERANDS_LABELs
-     don't point to target label.  */
+     don't point to the target or fallthru label.  */
   if (JUMP_P (BB_END (e->src))
       && target != EXIT_BLOCK_PTR
-      && e->dest == target
       && (e->flags & EDGE_FALLTHRU)
       && (note = extract_asm_operands (PATTERN (BB_END (e->src)))))
     {
       int i, n = ASM_OPERANDS_LABEL_LENGTH (note);
 
       for (i = 0; i < n; ++i)
-       if (XEXP (ASM_OPERANDS_LABEL (note, i), 0) == BB_HEAD (target))
-         {
+       {
+         if (XEXP (ASM_OPERANDS_LABEL (note, i), 0) == BB_HEAD (e->dest))
+           XEXP (ASM_OPERANDS_LABEL (note, i), 0) = block_label (target);
+         if (XEXP (ASM_OPERANDS_LABEL (note, i), 0) == BB_HEAD (target))
            asm_goto_edge = true;
-           break;
-         }
+       }
     }
 
   if (EDGE_COUNT (e->src->succs) >= 2 || abnormal_edge_flags || asm_goto_edge)
--- gcc/testsuite/gcc.dg/torture/pr53589.c      (revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr53589.c      (revision 188428)
@@ -0,0 +1,15 @@
+/* PR rtl-optimization/53589 */
+/* { dg-do compile } */
+
+extern void foo (void) __attribute__ ((__noreturn__));
+
+void
+bar (int x)
+{
+  if (x < 0)
+    foo ();
+  if (x == 0)
+    return;
+  __asm goto ("# %l[lab]" : : : : lab);
+lab:;
+}

Reply via email to