[flang-commits] [flang] [flang][PFT-to-MLIR] Default wrap-unstructured-constructs-in-execute-region to off (PR #211290)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Wed Jul 22 08:55:03 PDT 2026


https://github.com/ergawy updated https://github.com/llvm/llvm-project/pull/211290

>From 87ace9c83fc3919538d933710022ccd8369db589 Mon Sep 17 00:00:00 2001
From: ergawy <kareem.ergawy at gmail.com>
Date: Wed, 22 Jul 2026 08:25:03 -0700
Subject: [PATCH] [flang][PFT-to-MLIR] Default
 wrap-unstructured-constructs-in-execute-region to off

Flip the default of `-wrap-unstructured-constructs-in-execute-region`
from true to false while further miscompiles under the wrap path are
investigated. The flag is still available; lit tests that exercise the
wrap path now pass it explicitly on their RUN lines.

Co-Authored-By: Claude Sonnet 4.6 <noreply at anthropic.com>
---
 flang/lib/Lower/PFTBuilder.cpp                                | 2 +-
 flang/test/HLFIR/assumed_shape_with_value_keyword.f90         | 2 +-
 flang/test/HLFIR/optional_dummy.f90                           | 2 +-
 .../OpenMP/parallel-private-reduction-worstcase.f90           | 2 +-
 flang/test/Lower/HLFIR/intrinsic-subroutines.f90              | 2 +-
 flang/test/Lower/MIF/change_team2.f90                         | 4 ++--
 flang/test/Lower/OpenACC/acc-terminator.f90                   | 4 ++--
 flang/test/Lower/OpenACC/acc-unstructured.f90                 | 2 +-
 flang/test/Lower/OpenMP/loop-compound.f90                     | 4 ++--
 flang/test/Lower/OpenMP/parallel-reduction3.f90               | 4 ++--
 flang/test/Lower/OpenMP/stop-stmt-in-region.f90               | 4 ++--
 flang/test/Lower/OpenMP/unstructured.f90                      | 2 +-
 flang/test/Lower/OpenMP/wsloop-unstructured.f90               | 2 +-
 flang/test/Lower/branching-directive.f90                      | 2 +-
 flang/test/Lower/do_loop_unstructured.f90                     | 4 ++--
 flang/test/Lower/fail_image.f90                               | 2 +-
 flang/test/Lower/ifconvert.f90                                | 2 +-
 flang/test/Lower/mixed_loops.f90                              | 2 +-
 flang/test/Lower/nsw.f90                                      | 4 ++--
 flang/test/Lower/pre-fir-tree02.f90                           | 2 +-
 flang/test/Lower/while_loop.f90                               | 2 +-
 21 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/flang/lib/Lower/PFTBuilder.cpp b/flang/lib/Lower/PFTBuilder.cpp
index ced8df03eb68d..e5c91ac101679 100644
--- a/flang/lib/Lower/PFTBuilder.cpp
+++ b/flang/lib/Lower/PFTBuilder.cpp
@@ -26,7 +26,7 @@ static llvm::cl::opt<bool> clDisableStructuredFir(
     llvm::cl::init(false), llvm::cl::Hidden);
 
 llvm::cl::opt<bool> wrapUnstructuredConstructsInExecuteRegion(
-    "wrap-unstructured-constructs-in-execute-region", llvm::cl::init(true),
+    "wrap-unstructured-constructs-in-execute-region", llvm::cl::init(false),
     llvm::cl::desc("try to wrap unstructured constructs' CFGs in "
                    "self-contained MLIR regions"));
 
diff --git a/flang/test/HLFIR/assumed_shape_with_value_keyword.f90 b/flang/test/HLFIR/assumed_shape_with_value_keyword.f90
index 9e6cd57da785a..046355901e725 100644
--- a/flang/test/HLFIR/assumed_shape_with_value_keyword.f90
+++ b/flang/test/HLFIR/assumed_shape_with_value_keyword.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -emit-hlfir %s -o - | FileCheck %s
 
 ! Addresses assumed shape dummy argument with VALUE keyword
 
diff --git a/flang/test/HLFIR/optional_dummy.f90 b/flang/test/HLFIR/optional_dummy.f90
index 04751cae9f3cf..8044cd6241e1e 100644
--- a/flang/test/HLFIR/optional_dummy.f90
+++ b/flang/test/HLFIR/optional_dummy.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -emit-hlfir %s -o - | FileCheck %s
 
 ! Check that the lowering does not generate fir.box_addr for
 ! the optional box. It will cause segfault during execution.
diff --git a/flang/test/Integration/OpenMP/parallel-private-reduction-worstcase.f90 b/flang/test/Integration/OpenMP/parallel-private-reduction-worstcase.f90
index f9ea1a962d3c9..6e6fffe28a082 100644
--- a/flang/test/Integration/OpenMP/parallel-private-reduction-worstcase.f90
+++ b/flang/test/Integration/OpenMP/parallel-private-reduction-worstcase.f90
@@ -1,4 +1,4 @@
-! RUN: %flang_fc1 -fopenmp -emit-llvm %s -o - | FileCheck %s
+! RUN: %flang_fc1 -mmlir --wrap-unstructured-constructs-in-execute-region -fopenmp -emit-llvm %s -o - | FileCheck %s
 
 ! Combinational testing of control flow graph and builder insertion points
 ! in mlir-to-llvm conversion:
diff --git a/flang/test/Lower/HLFIR/intrinsic-subroutines.f90 b/flang/test/Lower/HLFIR/intrinsic-subroutines.f90
index cbd0f65ff0e20..74780e27b4178 100644
--- a/flang/test/Lower/HLFIR/intrinsic-subroutines.f90
+++ b/flang/test/Lower/HLFIR/intrinsic-subroutines.f90
@@ -1,7 +1,7 @@
 ! Test lowering of intrinsic subroutines to HLFIR what matters here
 ! is not to test each subroutine, but to check how their
 ! lowering interfaces with the rest of lowering.
-! RUN: bbc -emit-hlfir -o - %s | FileCheck %s
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -emit-hlfir -o - %s | FileCheck %s
 
 subroutine test_subroutine(x)
  real :: x
diff --git a/flang/test/Lower/MIF/change_team2.f90 b/flang/test/Lower/MIF/change_team2.f90
index 42d1f50cc10aa..2ce2fbede7e58 100644
--- a/flang/test/Lower/MIF/change_team2.f90
+++ b/flang/test/Lower/MIF/change_team2.f90
@@ -1,5 +1,5 @@
-! RUN: %flang_fc1 -emit-hlfir -fcoarray %s -o - | FileCheck %s --check-prefixes=COARRAY
-! RUN: not %flang_fc1 -emit-hlfir %s 2>&1 | FileCheck %s --check-prefixes=NOCOARRAY
+! RUN: %flang_fc1 -mmlir --wrap-unstructured-constructs-in-execute-region -emit-hlfir -fcoarray %s -o - | FileCheck %s --check-prefixes=COARRAY
+! RUN: not %flang_fc1 -mmlir --wrap-unstructured-constructs-in-execute-region -emit-hlfir %s 2>&1 | FileCheck %s --check-prefixes=NOCOARRAY
 
 ! NOCOARRAY: Not yet implemented: Multi-image features are experimental and are disabled by default, use '-fcoarray' to enable.
 
diff --git a/flang/test/Lower/OpenACC/acc-terminator.f90 b/flang/test/Lower/OpenACC/acc-terminator.f90
index fae147cbcc04d..6dda02dff9d98 100644
--- a/flang/test/Lower/OpenACC/acc-terminator.f90
+++ b/flang/test/Lower/OpenACC/acc-terminator.f90
@@ -1,7 +1,7 @@
 ! Check that acc.terminator is not inserted in data construct
 
-! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s
-! RUN: bbc -fopenacc -fcuda -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -fopenacc -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -fopenacc -fcuda -emit-hlfir %s -o - | FileCheck %s
 
 program main
   use, intrinsic :: iso_c_binding
diff --git a/flang/test/Lower/OpenACC/acc-unstructured.f90 b/flang/test/Lower/OpenACC/acc-unstructured.f90
index 8015e96d3bb92..5431e01a0ff65 100644
--- a/flang/test/Lower/OpenACC/acc-unstructured.f90
+++ b/flang/test/Lower/OpenACC/acc-unstructured.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -fopenacc -emit-hlfir %s -o - | FileCheck %s
 
 subroutine test_unstructured1(a, b, c)
   integer :: i, j, k
diff --git a/flang/test/Lower/OpenMP/loop-compound.f90 b/flang/test/Lower/OpenMP/loop-compound.f90
index b55235b3a4718..945bfd829f330 100644
--- a/flang/test/Lower/OpenMP/loop-compound.f90
+++ b/flang/test/Lower/OpenMP/loop-compound.f90
@@ -1,8 +1,8 @@
 ! This test checks lowering of OpenMP compound (combined and composite) loop
 ! constructs.
 
-! RUN: bbc -fopenmp -emit-hlfir %s -o - | FileCheck %s
-! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - | FileCheck %s
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -fopenmp -emit-hlfir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -mmlir --wrap-unstructured-constructs-in-execute-region -fopenmp -emit-hlfir %s -o - | FileCheck %s
 
 program main
   integer :: i,j
diff --git a/flang/test/Lower/OpenMP/parallel-reduction3.f90 b/flang/test/Lower/OpenMP/parallel-reduction3.f90
index ea6bf6cdf3ac9..eba55a7152098 100644
--- a/flang/test/Lower/OpenMP/parallel-reduction3.f90
+++ b/flang/test/Lower/OpenMP/parallel-reduction3.f90
@@ -1,5 +1,5 @@
-! RUN: bbc -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
-! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -mmlir --wrap-unstructured-constructs-in-execute-region -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
 
 ! CHECK-LABEL:   omp.declare_reduction @add_reduction_byref_box_Uxi32 : !fir.ref<!fir.box<!fir.array<?xi32>>> {{.*}} alloc {
 ! CHECK:           %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.array<?xi32>>
diff --git a/flang/test/Lower/OpenMP/stop-stmt-in-region.f90 b/flang/test/Lower/OpenMP/stop-stmt-in-region.f90
index 8acf1eaf387f8..d5476c50f1782 100644
--- a/flang/test/Lower/OpenMP/stop-stmt-in-region.f90
+++ b/flang/test/Lower/OpenMP/stop-stmt-in-region.f90
@@ -1,7 +1,7 @@
 ! This test checks lowering of stop statement in OpenMP region.
 
-! RUN: %flang_fc1 -emit-hlfir -fopenmp %s -o - | FileCheck %s
-! RUN: bbc -emit-hlfir -fopenmp %s -o - | FileCheck %s
+! RUN: %flang_fc1 -mmlir --wrap-unstructured-constructs-in-execute-region -emit-hlfir -fopenmp %s -o - | FileCheck %s
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -emit-hlfir -fopenmp %s -o - | FileCheck %s
 
 
 ! CHECK-LABEL: func.func @_QPtest_stop_in_region1() {
diff --git a/flang/test/Lower/OpenMP/unstructured.f90 b/flang/test/Lower/OpenMP/unstructured.f90
index 5d680576d26c6..32730b931abf7 100644
--- a/flang/test/Lower/OpenMP/unstructured.f90
+++ b/flang/test/Lower/OpenMP/unstructured.f90
@@ -1,6 +1,6 @@
 ! Test unstructured code adjacent to and inside OpenMP constructs.
 
-! RUN: bbc %s -fopenmp -emit-hlfir -o "-" \
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region %s -fopenmp -emit-hlfir -o "-" \
 ! RUN: | FileCheck %s
 
 ! CHECK-LABEL: func @_QPss1{{.*}} {
diff --git a/flang/test/Lower/OpenMP/wsloop-unstructured.f90 b/flang/test/Lower/OpenMP/wsloop-unstructured.f90
index aa5729daf6a24..f4a0777a603be 100644
--- a/flang/test/Lower/OpenMP/wsloop-unstructured.f90
+++ b/flang/test/Lower/OpenMP/wsloop-unstructured.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-hlfir -fopenmp -o - %s | FileCheck %s
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -emit-hlfir -fopenmp -o - %s | FileCheck %s
 
 subroutine sub(imax, jmax, x, y)
   integer, intent(in) :: imax, jmax
diff --git a/flang/test/Lower/branching-directive.f90 b/flang/test/Lower/branching-directive.f90
index bc62f325d6a0b..4c911d4b1b678 100644
--- a/flang/test/Lower/branching-directive.f90
+++ b/flang/test/Lower/branching-directive.f90
@@ -1,4 +1,4 @@
-!RUN: bbc -emit-hlfir -fopenacc -fopenmp -o - %s | FileCheck %s
+!RUN: bbc --wrap-unstructured-constructs-in-execute-region -emit-hlfir -fopenacc -fopenmp -o - %s | FileCheck %s
 
 !https://github.com/llvm/llvm-project/issues/91526
 
diff --git a/flang/test/Lower/do_loop_unstructured.f90 b/flang/test/Lower/do_loop_unstructured.f90
index 3d22a3e277812..a092590077303 100644
--- a/flang/test/Lower/do_loop_unstructured.f90
+++ b/flang/test/Lower/do_loop_unstructured.f90
@@ -1,5 +1,5 @@
-! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck %s
-! RUN: %flang_fc1 -emit-hlfir -fwrapv -o - %s | FileCheck %s --check-prefix=NO-NSW
+! RUN: %flang_fc1 -emit-hlfir -mmlir --wrap-unstructured-constructs-in-execute-region -o - %s | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -fwrapv -mmlir --wrap-unstructured-constructs-in-execute-region -o - %s | FileCheck %s --check-prefix=NO-NSW
 
 ! Tests for unstructured loops.
 
diff --git a/flang/test/Lower/fail_image.f90 b/flang/test/Lower/fail_image.f90
index 549f00e8d62cb..2e576ae3f18e2 100644
--- a/flang/test/Lower/fail_image.f90
+++ b/flang/test/Lower/fail_image.f90
@@ -1,4 +1,4 @@
-! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -mmlir --wrap-unstructured-constructs-in-execute-region -emit-hlfir %s -o - | FileCheck %s
 
 ! CHECK-LABEL: func.func @_QPfail_image_test(
 ! CHECK-SAME: %[[ARG0:.*]]: !fir.ref<!fir.logical<4>> {fir.bindc_name = "fail"}) {
diff --git a/flang/test/Lower/ifconvert.f90 b/flang/test/Lower/ifconvert.f90
index 256bb37c4e19f..0fbe02c8bc903 100644
--- a/flang/test/Lower/ifconvert.f90
+++ b/flang/test/Lower/ifconvert.f90
@@ -1,4 +1,4 @@
-! RUN: %flang_fc1 -fdebug-dump-pft %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -mmlir --wrap-unstructured-constructs-in-execute-region -fdebug-dump-pft %s 2>&1 | FileCheck %s
 
 ! Note: PFT dump output is fairly stable, including node indexes and
 !       annotations, so all output is CHECKed.
diff --git a/flang/test/Lower/mixed_loops.f90 b/flang/test/Lower/mixed_loops.f90
index 9c774caccf131..6cea19e3f87ba 100644
--- a/flang/test/Lower/mixed_loops.f90
+++ b/flang/test/Lower/mixed_loops.f90
@@ -1,4 +1,4 @@
-! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir -mmlir --wrap-unstructured-constructs-in-execute-region -o - %s | FileCheck %s
 
 ! Test while loop inside do loop.
 ! With the wrap-unstructured-constructs-in-execute-region pass, the inner
diff --git a/flang/test/Lower/nsw.f90 b/flang/test/Lower/nsw.f90
index fa18dbff97ecc..dc0d290b3cb60 100644
--- a/flang/test/Lower/nsw.f90
+++ b/flang/test/Lower/nsw.f90
@@ -1,5 +1,5 @@
-! RUN: bbc -emit-fir %s -o - | FileCheck %s
-! RUN: bbc -emit-fir -fwrapv %s -o - | FileCheck %s --check-prefix=NO-NSW
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -emit-fir %s -o - | FileCheck %s
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -emit-fir -fwrapv %s -o - | FileCheck %s --check-prefix=NO-NSW
 
 ! NO-NSW-NOT: overflow<nsw>
 
diff --git a/flang/test/Lower/pre-fir-tree02.f90 b/flang/test/Lower/pre-fir-tree02.f90
index 638dd94416229..ee2d5c214f740 100644
--- a/flang/test/Lower/pre-fir-tree02.f90
+++ b/flang/test/Lower/pre-fir-tree02.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -pft-test -o %t %s | FileCheck %s
+! RUN: bbc --wrap-unstructured-constructs-in-execute-region -pft-test -o %t %s | FileCheck %s
 
 ! Test Pre-FIR Tree captures all the intended nodes from the parse-tree
 ! Coarray and OpenMP related nodes are tested in other files.
diff --git a/flang/test/Lower/while_loop.f90 b/flang/test/Lower/while_loop.f90
index 8f2291f74a8ed..cf818b9720388 100644
--- a/flang/test/Lower/while_loop.f90
+++ b/flang/test/Lower/while_loop.f90
@@ -1,4 +1,4 @@
-! RUN: %flang_fc1 -emit-hlfir -o - %s | FileCheck %s
+! RUN: %flang_fc1 -mmlir --wrap-unstructured-constructs-in-execute-region -emit-hlfir -o - %s | FileCheck %s
 
 ! Test a simple while loop.
 ! CHECK-LABEL: simple_loop



More information about the flang-commits mailing list