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

via flang-commits flang-commits at lists.llvm.org
Fri Mar 20 06:26:14 PDT 2026


================
@@ -6239,7 +6239,16 @@ class FirConverter : public Fortran::lower::AbstractConverter {
     genConstructExitBranch(*getEval().controlSuccessor);
   }
   void genFIR(const Fortran::parser::GotoStmt &) {
-    genConstructExitBranch(*getEval().controlSuccessor);
+    auto &targetEval = *getEval().controlSuccessor;
+    if (Fortran::lower::isInOpenACCLoop(*builder)) {
+      mlir::Block *targetBlock = targetEval.block;
+      mlir::Region *currentRegion = &builder->getRegion();
----------------
jeanPerier wrote:

I think that you should somehow verify that the currentRegion is the one of the acc operation.
My concern is that as we move to keep the structure as much as possible the goto could be lowered inside an scf.execute_region and be branching inside the loop.


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


More information about the flang-commits mailing list