[flang-commits] [flang] 9745669 - [flang][acc] remap no_create array sections (#178660)

via flang-commits flang-commits at lists.llvm.org
Tue Feb 3 02:01:30 PST 2026


Author: jeanPerier
Date: 2026-02-03T11:01:25+01:00
New Revision: 974566914c4e78d53239bfebf3c73d160bed6cc6

URL: https://github.com/llvm/llvm-project/commit/974566914c4e78d53239bfebf3c73d160bed6cc6
DIFF: https://github.com/llvm/llvm-project/commit/974566914c4e78d53239bfebf3c73d160bed6cc6.diff

LOG: [flang][acc] remap no_create array sections (#178660)

The workaround for no_create with array section is not needed anymore
because it has been expected that it would be up to the runtime to make
sure fir.box for the variable are always readable on the device even
when the variable is not present.

Added: 
    flang/test/Lower/OpenACC/acc-no-create-array-section.f90

Modified: 
    flang/lib/Lower/OpenACC.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 183f9e717532a..133cc973897af 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -775,16 +775,9 @@ genDataOperandOperations(const Fortran::parser::AccObjectList &objectList,
       if (auto *defOp = op.getVar().getDefiningOp())
         addDeclareAttr(builder, defOp, dataClause);
 
-    // TODO: no_create remapping could currently cause segfaults because of the
-    // fir.box_addr that may be inserted in the remapping in the region.
-    // This is an issue if the variable is not mapped (which is OK if its
-    // accesses are not reached inside the construct).
-    bool isNoCreateWithBounds =
-        std::is_same_v<Op, mlir::acc::NoCreateOp> && !bounds.empty();
-
     // Track the symbol and its corresponding mlir::Value if requested so that
     // accesses inside regions can be remapped.
-    if (dataMap && !isNoCreateWithBounds) {
+    if (dataMap) {
       if (componentRef)
         dataMap->emplaceComponent(op.getAccVar(), std::move(*componentRef),
                                   baseAddr);

diff  --git a/flang/test/Lower/OpenACC/acc-no-create-array-section.f90 b/flang/test/Lower/OpenACC/acc-no-create-array-section.f90
new file mode 100644
index 0000000000000..3097eccc8cbee
--- /dev/null
+++ b/flang/test/Lower/OpenACC/acc-no-create-array-section.f90
@@ -0,0 +1,21 @@
+! This test checks lowering of OpenACC no_create with an array section.
+
+! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s
+
+subroutine foo(n)
+  real :: a(n)
+  !$acc parallel no_create(a(11:20))
+    call bar(a)
+  !$acc end parallel
+end subroutine
+! CHECK-LABEL:   func.func @_QPfoo(
+! CHECK:           %[[SHAPE_0:.*]] = fir.shape
+! CHECK:           %[[BOUNDS_0:.*]] = acc.bounds
+! CHECK:           %[[NOCREATE_0:.*]] = acc.nocreate var(%{{.*}} : !fir.box<!fir.array<?xf32>>) bounds(%[[BOUNDS_0]]) -> !fir.box<!fir.array<?xf32>> {name = "a(11:20)"}
+! CHECK:           acc.parallel dataOperands(%[[NOCREATE_0]] : !fir.box<!fir.array<?xf32>>) {
+! CHECK:             %[[BOX_ADDR_0:.*]] = fir.box_addr %[[NOCREATE_0]] : (!fir.box<!fir.array<?xf32>>) -> !fir.ref<!fir.array<?xf32>>
+! CHECK:             %[[DECLARE_2:.*]]:2 = hlfir.declare %[[BOX_ADDR_0]](%[[SHAPE_0]]) {uniq_name = "_QFfooEa"} : (!fir.ref<!fir.array<?xf32>>, !fir.shape<1>) -> (!fir.box<!fir.array<?xf32>>, !fir.ref<!fir.array<?xf32>>)
+! CHECK:             fir.call @_QPbar(%[[DECLARE_2]]#1) fastmath<contract> : (!fir.ref<!fir.array<?xf32>>) -> ()
+! CHECK:             acc.yield
+! CHECK:           }
+! CHECK:           acc.delete accVar(%[[NOCREATE_0]] : !fir.box<!fir.array<?xf32>>) bounds(%[[BOUNDS_0]]) {dataClause = #acc<data_clause acc_no_create>, name = "a(11:20)"}


        


More information about the flang-commits mailing list