[flang-commits] [flang] [flang] Fix crash when GoTo exits acc.loop region (PR #187613)

via flang-commits flang-commits at lists.llvm.org
Thu Mar 19 22:17:18 PDT 2026


================
@@ -0,0 +1,24 @@
+! Test that GoTo exiting an acc.loop seq region generates acc.yield
+! instead of an illegal cross-region cf.br that would crash the compiler.
+! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s
+
+! CHECK-LABEL: func.func @_QPfoo
+subroutine foo(N, A, B)
+  implicit real*8 (a-h, o-z)
+  !$acc routine gang
+  dimension A(*), B(*)
+  !$acc loop gang vector
+  do 100 i = 1, N
+  ! CHECK: acc.loop gang vector
+  ! CHECK: acc.loop
+  !$acc loop seq
+    do 10 j = 1, 1000
+      if (A(i) .gt. B(i)) goto 20
+10  continue
+  ! The GoTo crossing the acc.loop region boundary must generate
+  ! acc.yield (not cf.br) to properly exit the inner acc.loop.
+  ! CHECK: acc.yield
+  ! CHECK: acc.yield
----------------
khaki3 wrote:

There are legitimate cf.br(s) inside acc.loop. I added braces and CHECK-NEXT instead. Thanks.

https://github.com/llvm/llvm-project/pull/187613


More information about the flang-commits mailing list