Skip to content

Conversation

@vzakhari
Copy link
Contributor

Basic generation of array repacking operations in Lowering.

@vzakhari vzakhari requested review from jeanPerier and tblah March 18, 2025 01:19
@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Mar 18, 2025
@vzakhari
Copy link
Contributor Author

Depends on #131662

@llvmbot
Copy link
Member

llvmbot commented Mar 18, 2025

@llvm/pr-subscribers-flang-fir-hlfir

Author: Slava Zakharin (vzakhari)

Changes

Basic generation of array repacking operations in Lowering.


Patch is 22.42 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/131704.diff

5 Files Affected:

  • (modified) flang/include/flang/Lower/ConvertVariable.h (+16)
  • (modified) flang/include/flang/Lower/LoweringOptions.def (+15)
  • (modified) flang/lib/Lower/ConvertVariable.cpp (+99-2)
  • (added) flang/test/Lower/repack-arrays.f90 (+247)
  • (modified) flang/tools/bbc/bbc.cpp (+26)
diff --git a/flang/include/flang/Lower/ConvertVariable.h b/flang/include/flang/Lower/ConvertVariable.h
index b9d7f89138032..293ffa010d14a 100644
--- a/flang/include/flang/Lower/ConvertVariable.h
+++ b/flang/include/flang/Lower/ConvertVariable.h
@@ -182,6 +182,22 @@ void genDeclareSymbol(Fortran::lower::AbstractConverter &converter,
 /// track the cray pointee as Fortran pointer.
 mlir::Type getCrayPointeeBoxType(mlir::Type);
 
+/// If the given array symbol must be repacked into contiguous
+/// memory, generate fir.pack_array for the given box array value.
+/// The returned extended value is a box with the same properties
+/// as the original.
+fir::ExtendedValue genPackArray(Fortran::lower::AbstractConverter &converter,
+                                const Fortran::semantics::Symbol &sym,
+                                fir::ExtendedValue exv);
+
+/// Given an operation defining the variable corresponding
+/// to the given symbol, generate fir.unpack_array operation
+/// that reverts the effect of fir.pack_array.
+/// \p def is expected to be hlfir.declare operation.
+void genUnpackArray(fir::FirOpBuilder &builder, mlir::Location loc,
+                    fir::FortranVariableOpInterface def,
+                    const Fortran::semantics::Symbol &sym);
+
 } // namespace lower
 } // namespace Fortran
 #endif // FORTRAN_LOWER_CONVERT_VARIABLE_H
diff --git a/flang/include/flang/Lower/LoweringOptions.def b/flang/include/flang/Lower/LoweringOptions.def
index 396c91948be36..6735bea551414 100644
--- a/flang/include/flang/Lower/LoweringOptions.def
+++ b/flang/include/flang/Lower/LoweringOptions.def
@@ -47,5 +47,20 @@ ENUM_LOWERINGOPT(ReallocateLHS, unsigned, 1, 1)
 /// If true, initialize globals without initialization to zero.
 /// On by default.
 ENUM_LOWERINGOPT(InitGlobalZero, unsigned, 1, 1)
+
+/// If true, the arrays of unknown size and array temporaries
+/// are requested to be allocated in stack memory.
+ENUM_LOWERINGOPT(StackArrays, unsigned, 1, 0)
+
+/// If true, the dummy assumed shape arrays are conditionally
+/// packed into contiguous memory.
+ENUM_LOWERINGOPT(RepackArrays, unsigned, 1, 0)
+
+/// If true, the repacking (RepackArrays option above)
+/// will be done for arrays non-contiguous in any dimension,
+/// otherwise, it will be done only for arrays non-contiguous
+/// in the leading dimension.
+ENUM_LOWERINGOPT(RepackArraysWhole, unsigned, 1, 0)
+
 #undef LOWERINGOPT
 #undef ENUM_LOWERINGOPT
diff --git a/flang/lib/Lower/ConvertVariable.cpp b/flang/lib/Lower/ConvertVariable.cpp
index 05256fec67241..52e3578ae21f0 100644
--- a/flang/lib/Lower/ConvertVariable.cpp
+++ b/flang/lib/Lower/ConvertVariable.cpp
@@ -1009,6 +1009,17 @@ static void deallocateIntentOut(Fortran::lower::AbstractConverter &converter,
   }
 }
 
+static bool needsRepack(Fortran::lower::AbstractConverter &converter,
+                        const Fortran::semantics::Symbol &sym) {
+  if (!converter.getLoweringOptions().getRepackArrays() ||
+      !converter.isRegisteredDummySymbol(sym) ||
+      !Fortran::semantics::IsAssumedShape(sym) ||
+      Fortran::evaluate::IsSimplyContiguous(sym, converter.getFoldingContext()))
+    return false;
+
+  return true;
+}
+
 /// Instantiate a local variable. Precondition: Each variable will be visited
 /// such that if its properties depend on other variables, the variables upon
 /// which its properties depend will already have been visited.
@@ -1077,6 +1088,17 @@ static void instantiateLocal(Fortran::lower::AbstractConverter &converter,
                                                  loc, sym);
       });
     }
+  } else if (var.hasSymbol() && needsRepack(converter, var.getSymbol())) {
+    auto *builder = &converter.getFirOpBuilder();
+    mlir::Location loc = converter.getCurrentLocation();
+    auto *sym = &var.getSymbol();
+    std::optional<fir::FortranVariableOpInterface> varDef =
+        symMap.lookupVariableDefinition(*sym);
+    assert(varDef && "cannot find defining operation for an array that needs "
+                     "to be repacked");
+    converter.getFctCtx().attachCleanup([builder, loc, varDef, sym]() {
+      Fortran::lower::genUnpackArray(*builder, loc, *varDef, *sym);
+    });
   }
 }
 
@@ -1914,10 +1936,13 @@ void Fortran::lower::genDeclareSymbol(
                                                         sym.GetUltimate());
     auto name = converter.mangleName(sym);
     mlir::Value dummyScope;
-    if (converter.isRegisteredDummySymbol(sym))
+    fir::ExtendedValue base = exv;
+    if (converter.isRegisteredDummySymbol(sym)) {
+      base = genPackArray(converter, sym, exv);
       dummyScope = converter.dummyArgsScopeValue();
+    }
     hlfir::EntityWithAttributes declare = hlfir::genDeclare(
-        loc, builder, exv, name, attributes, dummyScope, dataAttr);
+        loc, builder, base, name, attributes, dummyScope, dataAttr);
     symMap.addVariableDefinition(sym, declare.getIfVariableInterface(), force);
     return;
   }
@@ -2562,3 +2587,75 @@ mlir::Type Fortran::lower::getCrayPointeeBoxType(mlir::Type fortranType) {
   }
   return fir::BoxType::get(fir::PointerType::get(baseType));
 }
+
+fir::ExtendedValue
+Fortran::lower::genPackArray(Fortran::lower::AbstractConverter &converter,
+                             const Fortran::semantics::Symbol &sym,
+                             fir::ExtendedValue exv) {
+  if (!needsRepack(converter, sym))
+    return exv;
+
+  auto &opts = converter.getLoweringOptions();
+  llvm::SmallVector<mlir::Value> lenParams;
+  exv.match(
+      [&](const fir::CharArrayBoxValue &box) {
+        lenParams.emplace_back(box.getLen());
+      },
+      [&](const fir::BoxValue &box) {
+        lenParams.append(box.getExplicitParameters().begin(),
+                         box.getExplicitParameters().end());
+      },
+      [](const auto &) {
+        llvm_unreachable("unexpected lowering for assumed-shape dummy");
+      });
+  fir::FirOpBuilder &builder = converter.getFirOpBuilder();
+  const mlir::Location loc = genLocation(converter, sym);
+  bool stackAlloc = opts.getStackArrays();
+  // 1D arrays must always use 'whole' mode.
+  bool isInnermostMode = !opts.getRepackArraysWhole() && sym.Rank() > 1;
+  // Avoid copy-in for 'intent(out)' variables.
+  bool noCopy = Fortran::semantics::IsIntentOut(sym);
+  auto boxType = mlir::cast<fir::BaseBoxType>(fir::getBase(exv).getType());
+  mlir::Type elementType = boxType.unwrapInnerType();
+  llvm::SmallVector<mlir::Value> elidedLenParams =
+      fir::factory::elideLengthsAlreadyInType(elementType, lenParams);
+  auto packOp = builder.create<fir::PackArrayOp>(
+      loc, fir::getBase(exv), stackAlloc, isInnermostMode, noCopy,
+      /*max_size=*/mlir::IntegerAttr{},
+      /*max_element_size=*/mlir::IntegerAttr{},
+      /*min_stride=*/mlir::IntegerAttr{}, fir::PackArrayHeuristics::None,
+      elidedLenParams);
+
+  mlir::Value newBase = packOp.getResult();
+  return exv.match(
+      [&](const fir::CharArrayBoxValue &box) -> fir::ExtendedValue {
+        return box.clone(newBase);
+      },
+      [&](const fir::BoxValue &box) -> fir::ExtendedValue {
+        return box.clone(newBase);
+      },
+      [](const auto &) -> fir::ExtendedValue {
+        llvm_unreachable("unexpected lowering for assumed-shape dummy");
+      });
+}
+
+void Fortran::lower::genUnpackArray(fir::FirOpBuilder &builder,
+                                    mlir::Location loc,
+                                    fir::FortranVariableOpInterface def,
+                                    const Fortran::semantics::Symbol &sym) {
+  // Subtle: rely on the fact that the memref of the defining
+  // hlfir.declare is a result of fir.pack_array.
+  // Alternatively, we can track the pack operation for a symbol
+  // via SymMap.
+  auto declareOp = mlir::dyn_cast<hlfir::DeclareOp>(def.getOperation());
+  assert(declareOp &&
+         "cannot find hlfir.declare for an array that needs to be repacked");
+  auto packOp = declareOp.getMemref().getDefiningOp<fir::PackArrayOp>();
+  assert(packOp && "cannot find fir.pack_array");
+  mlir::Value temp = packOp.getResult();
+  mlir::Value original = packOp.getArray();
+  bool stackAlloc = packOp.getStack();
+  // Avoid copy-out for 'intent(in)' variables.
+  bool noCopy = Fortran::semantics::IsIntentIn(sym);
+  builder.create<fir::UnpackArrayOp>(loc, temp, original, stackAlloc, noCopy);
+}
diff --git a/flang/test/Lower/repack-arrays.f90 b/flang/test/Lower/repack-arrays.f90
new file mode 100644
index 0000000000000..19ea93a3521a3
--- /dev/null
+++ b/flang/test/Lower/repack-arrays.f90
@@ -0,0 +1,247 @@
+! RUN: bbc -emit-hlfir -frepack-arrays -fstack-arrays -frepack-arrays-continuity-whole %s -o - -I nowhere | FileCheck --check-prefixes=ALL,STACK,WHOLE %s
+! RUN: bbc -emit-hlfir -frepack-arrays -fstack-arrays=false -frepack-arrays-continuity-whole %s -o - -I nowhere | FileCheck --check-prefixes=ALL,HEAP,WHOLE %s
+! RUN: bbc -emit-hlfir -frepack-arrays -fstack-arrays -frepack-arrays-continuity-whole=false %s -o - -I nowhere | FileCheck --check-prefixes=ALL,STACK,INNER %s
+! RUN: bbc -emit-hlfir -frepack-arrays -fstack-arrays=false -frepack-arrays-continuity-whole=false %s -o - -I nowhere | FileCheck --check-prefixes=ALL,HEAP,INNER %s
+
+! ALL-LABEL:   func.func @_QPtest1(
+! ALL-SAME:                        %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x"}) {
+subroutine test1(x)
+  real :: x(:)
+! ALL:           %[[VAL_2:.*]] = fir.pack_array %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! WHOLE-SAME:    whole
+! ALL-NOT:       no_copy
+! ALL-SAME       : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>
+! ALL:           %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] dummy_scope %{{.*}} {uniq_name = "_QFtest1Ex"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! ALL:           fir.unpack_array %[[VAL_2]] to %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! ALL-NOT:       no_copy
+! ALL-SAME:      : !fir.box<!fir.array<?xf32>>
+end subroutine test1
+
+! ALL-LABEL:   func.func @_QPtest2(
+! ALL-SAME:                        %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.ref<i32> {fir.bindc_name = "n"},
+! ALL-SAME:                        %[[VAL_1:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?x?x!fir.char<1,?>>> {fir.bindc_name = "x"}) {
+subroutine test2(n, x)
+  integer :: n
+  character(n) :: x(:,:)
+! ALL:           %[[VAL_8:.*]] = fir.pack_array %[[VAL_1]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! WHOLE-SAME:    whole
+! INNER-SAME:    innermost
+! ALL-NOT:       no_copy
+! ALL-SAME:      typeparams %[[VAL_7:.*]] : (!fir.box<!fir.array<?x?x!fir.char<1,?>>>, i32) -> !fir.box<!fir.array<?x?x!fir.char<1,?>>>
+! ALL:           %[[VAL_9:.*]]:2 = hlfir.declare %[[VAL_8]] typeparams %[[VAL_7]] dummy_scope %{{.*}} {uniq_name = "_QFtest2Ex"} : (!fir.box<!fir.array<?x?x!fir.char<1,?>>>, i32, !fir.dscope) -> (!fir.box<!fir.array<?x?x!fir.char<1,?>>>, !fir.box<!fir.array<?x?x!fir.char<1,?>>>)
+! ALL:           fir.unpack_array %[[VAL_8]] to %[[VAL_1]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! ALL-NOT:       no_copy
+! ALL-SAME:      : !fir.box<!fir.array<?x?x!fir.char<1,?>>>
+end subroutine test2
+
+! ALL-LABEL:   func.func @_QPtest3(
+! ALL-SAME:                        %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?x?x!fir.type<_QFtest3Tt>>> {fir.bindc_name = "x"}) {
+subroutine test3(x)
+  type t
+  end type t
+  type(t) :: x(:,:)
+! ALL:           %[[VAL_2:.*]] = fir.pack_array %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! WHOLE-SAME:    whole
+! INNER-SAME:    innermost
+! ALL-NOT:       no_copy
+! ALL-SAME:      : (!fir.box<!fir.array<?x?x!fir.type<_QFtest3Tt>>>) -> !fir.box<!fir.array<?x?x!fir.type<_QFtest3Tt>>>
+! ALL:           %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] dummy_scope %{{.*}} {uniq_name = "_QFtest3Ex"} : (!fir.box<!fir.array<?x?x!fir.type<_QFtest3Tt>>>, !fir.dscope) -> (!fir.box<!fir.array<?x?x!fir.type<_QFtest3Tt>>>, !fir.box<!fir.array<?x?x!fir.type<_QFtest3Tt>>>)
+! ALL:           fir.unpack_array %[[VAL_2]] to %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! ALL-NOT:       no_copy
+! ALL-SAME:      : !fir.box<!fir.array<?x?x!fir.type<_QFtest3Tt>>>
+end subroutine test3
+
+! ALL-LABEL:   func.func @_QPtest4(
+! ALL-SAME:                        %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x"}) {
+subroutine test4(x)
+  real, intent(inout) :: x(:)
+! ALL:           %[[VAL_2:.*]] = fir.pack_array %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! WHOLE-SAME:    whole
+! ALL-NOT:       no_copy
+! ALL-SAME       : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>
+! ALL:           %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] dummy_scope %{{.*}} {fortran_attrs = #fir.var_attrs<intent_inout>, uniq_name = "_QFtest4Ex"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! ALL:           fir.unpack_array %[[VAL_2]] to %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! ALL-NOT:       no_copy
+! ALL-SAME       : !fir.box<!fir.array<?xf32>>
+end subroutine test4
+
+! ALL-LABEL:   func.func @_QPtest5(
+! ALL-SAME:                        %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x"}) {
+subroutine test5(x)
+  real, intent(in) :: x(:)
+! ALL:           %[[VAL_2:.*]] = fir.pack_array %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! WHOLE-SAME:    whole
+! ALL-NOT:       no_copy
+! ALL-SAME:      (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>
+! ALL:           %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] dummy_scope %{{.*}} {fortran_attrs = #fir.var_attrs<intent_in>, uniq_name = "_QFtest5Ex"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! ALL:           fir.unpack_array %[[VAL_2]] to %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! ALL-SAME       no_copy : !fir.box<!fir.array<?xf32>>
+end subroutine test5
+
+! ALL-LABEL:   func.func @_QPtest6(
+! ALL-SAME:                        %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x"}) {
+subroutine test6(x)
+  real, intent(out) :: x(:)
+! ALL:           %[[VAL_2:.*]] = fir.pack_array %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! WHOLE-SAME:    whole
+! ALL-SAME       no_copy : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>
+! ALL:           %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] dummy_scope %{{.*}} {fortran_attrs = #fir.var_attrs<intent_out>, uniq_name = "_QFtest6Ex"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+! ALL:           fir.unpack_array %[[VAL_2]] to %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! ALL-NOT:       no_copy
+! ALL-SAME       : !fir.box<!fir.array<?xf32>>
+end subroutine test6
+
+! ALL-LABEL:   func.func @_QPtest7(
+! ALL-SAME:                        %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.class<!fir.array<?x!fir.type<_QFtest7Tt>>> {fir.bindc_name = "x"}) {
+subroutine test7(x)
+  type t
+  end type t
+  class(t) :: x(:)
+! ALL:           %[[VAL_2:.*]] = fir.pack_array %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! WHOLE-SAME:    whole
+! ALL-NOT:       no_copy
+! ALL-SAME       : (!fir.class<!fir.array<?x!fir.type<_QFtest7Tt>>>) -> !fir.class<!fir.array<?x!fir.type<_QFtest7Tt>>>
+! ALL:           %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] dummy_scope %{{.*}} {uniq_name = "_QFtest7Ex"} : (!fir.class<!fir.array<?x!fir.type<_QFtest7Tt>>>, !fir.dscope) -> (!fir.class<!fir.array<?x!fir.type<_QFtest7Tt>>>, !fir.class<!fir.array<?x!fir.type<_QFtest7Tt>>>)
+! ALL:           fir.unpack_array %[[VAL_2]] to %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! ALL-NOT:       no_copy
+! ALL-SAME       : !fir.class<!fir.array<?x!fir.type<_QFtest7Tt>>>
+end subroutine test7
+
+! ALL-LABEL:   func.func @_QPtest8(
+! ALL-SAME:                        %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x"}) {
+subroutine test8(x)
+  real :: x(:)
+! ALL:           %[[VAL_2:.*]] = fir.pack_array %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! WHOLE-SAME:    whole
+! ALL-NOT:       no_copy
+! ALL-SAME       : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>
+! ALL:           %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] dummy_scope %{{.*}} {uniq_name = "_QFtest8Ex"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+  call inner(x(1))
+! ALL:           fir.call @_QFtest8Pinner
+! ALL:           fir.unpack_array %[[VAL_2]] to %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! ALL-NOT:       no_copy
+! ALL-SAME       : !fir.box<!fir.array<?xf32>>
+contains
+! ALL-LABEL:   func.func private @_QFtest8Pinner(
+  subroutine inner(y)
+! ALL-NOT: fir.pack_array
+! ALL-NOT: fir.unpack_array
+    real :: y
+    y = 1.0
+  end subroutine inner
+end subroutine test8
+
+! ALL-LABEL:   func.func @_QPtest9(
+! ALL-SAME:                        %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?xf32>> {fir.bindc_name = "x"}) -> f32 {
+real function test9(x)
+  real :: x(:)
+! ALL:           %[[VAL_6:.*]] = fir.pack_array %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! WHOLE-SAME:    whole
+! ALL-NOT:       no_copy
+! ALL-SAME       : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>
+! ALL:           %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_6]] dummy_scope %{{.*}} {uniq_name = "_QFtest9Ex"} : (!fir.box<!fir.array<?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?xf32>>)
+  real :: y(10)
+  test9 = x(1)
+! ALL:           fir.unpack_array %[[VAL_6]] to %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! ALL-NOT:       no_copy
+! ALL-SAME       : !fir.box<!fir.array<?xf32>>
+! ALL-NEXT:      return
+  return
+
+! ALL-LABEL:   func.func @_QPtest9_alt(
+  entry test9_alt(y)
+! ALL-NOT: fir.pack_array
+! ALL-NOT: fir.unpack_array
+  rest9_ = y(1)
+end function test9
+
+! ALL-LABEL:   func.func @_QPtest10(
+! ALL-SAME:                         %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?x?xf32>> {fir.bindc_name = "x", fir.optional}) {
+subroutine test10(x)
+  real, optional :: x(:,:)
+! ALL:           %[[VAL_2:.*]] = fir.pack_array %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! WHOLE-SAME:    whole
+! INNER-SAME:    innermost
+! ALL-NOT:       no_copy
+! ALL-SAME:      : (!fir.box<!fir.array<?x?xf32>>) -> !fir.box<!fir.array<?x?xf32>>
+! ALL:           %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] dummy_scope %{{.*}} {fortran_attrs = #fir.var_attrs<optional>, uniq_name = "_QFtest10Ex"} : (!fir.box<!fir.array<?x?xf32>>, !fir.dscope) -> (!fir.box<!fir.array<?x?xf32>>, !fir.box<!fir.array<?x?xf32>>)
+! ALL:           fir.unpack_array %[[VAL_2]] to %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! ALL-NOT:       no_copy
+! ALL-SAME:      : !fir.box<!fir.array<?x?xf32>>
+end subroutine test10
+
+! ALL-LABEL:   func.func @_QPtest11(
+! ALL-SAME:                         %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?x!fir.char<1,10>>> {fir.bindc_name = "x"}) {
+subroutine test11(x)
+  character(10) :: x(:)
+! ALL:           %[[VAL_3:.*]] = fir.pack_array %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! WHOLE-SAME:    whole
+! INNER-SAME:    whole
+! ALL-NOT:       no_copy
+! ALL-SAME:      : (!fir.box<!fir.array<?x!fir.char<1,10>>>) -> !fir.box<!fir.array<?x!fir.char<1,10>>>
+! ALL:           fir.unpack_array %[[VAL_3]] to %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! ALL-NOT:       no_copy
+! ALL-SAME:      : !fir.box<!fir.array<?x!fir.char<1,10>>>
+end subroutine test11
+
+! ALL-LABEL:   func.func @_QPtest12(
+! ALL-SAME:                         %[[VAL_0:[0-9]+|[a-zA-Z$._-][a-zA-Z0-9$._-]*]]: !fir.box<!fir.array<?x!fir.char<1,?>>> {fir.bindc_name = "x"}) {
+subroutine test12(x)
+  character(*) :: x(:)
+! ALL:           %[[VAL_2:.*]] = fir.pack_array %[[VAL_0]]
+! STACK-SAME:    stack
+! HEAP-SAME:     heap
+! WHOLE-SAME:    whole
+! INNER-SAME:    whole
+! AL...
[truncated]

Copy link
Contributor

@tblah tblah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks Slava

Copy link
Contributor

@jeanPerier jeanPerier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

Basic generation of array repacking operations in Lowering.
@vzakhari vzakhari force-pushed the repack_arrays_lowering branch from f070204 to 00bd36c Compare March 18, 2025 19:59
@vzakhari vzakhari merged commit fd0e20a into llvm:main Mar 19, 2025
11 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 19, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-windows running on premerge-windows-1 while building flang at step 7 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/35/builds/8321

Here is the relevant piece of the build log for the reference
Step 7 (build-unified-tree) failure: build (failure)
...
[46/3845] Linking CXX executable bin\lld.exe
[47/3845] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\HlfirIntrinsics.cpp.obj
[48/3845] Linking CXX executable bin\mlir-reduce.exe
[49/3845] Linking CXX executable bin\mlir-translate.exe
[50/3845] Linking CXX executable bin\toyc-ch5.exe
[51/3845] Linking CXX executable bin\mlir-rewrite.exe
[52/3845] Building CXX object tools\flang\lib\Optimizer\Builder\CMakeFiles\FIRBuilder.dir\IntrinsicCall.cpp.obj
C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Optimizer\Builder\IntrinsicCall.cpp(5841): warning C4927: illegal conversion; more than one user-defined conversion has been implicitly applied
[53/3845] Linking CXX executable bin\mlir-runner.exe
[54/3845] Linking CXX executable bin\transform-opt-ch3.exe
FAILED: bin/transform-opt-ch3.exe 
cmd.exe /C "cd . && C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe -E vs_link_exe --intdir=tools\mlir\examples\transform\Ch3\CMakeFiles\transform-opt-ch3.dir --rc="C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\rc.exe" --mt="C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\mt.exe" --manifests  -- C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\transform-opt-ch3.rsp  /out:bin\transform-opt-ch3.exe /implib:lib\transform-opt-ch3.lib /pdb:bin\transform-opt-ch3.pdb /version:0.0 /machine:x64 /STACK:10000000 /INCREMENTAL:NO /subsystem:console  && cd ."
Not enough memory resources are available to process this command.

[55/3845] Linking CXX executable bin\toyc-ch7.exe
FAILED: bin/toyc-ch7.exe 
cmd.exe /C "cd . && C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe -E vs_link_exe --intdir=tools\mlir\examples\toy\Ch7\CMakeFiles\toyc-ch7.dir --rc="C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\rc.exe" --mt="C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64\mt.exe" --manifests  -- C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\toyc-ch7.rsp  /out:bin\toyc-ch7.exe /implib:lib\toyc-ch7.lib /pdb:bin\toyc-ch7.pdb /version:0.0 /machine:x64 /STACK:10000000 /INCREMENTAL:NO /subsystem:console  && cd ."
LINK: command "C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\toyc-ch7.rsp /out:bin\toyc-ch7.exe /implib:lib\toyc-ch7.lib /pdb:bin\toyc-ch7.pdb /version:0.0 /machine:x64 /STACK:10000000 /INCREMENTAL:NO /subsystem:console /MANIFEST /MANIFESTFILE:bin\toyc-ch7.exe.manifest" failed (exit code 1102) with the following output:
LINK : fatal error LNK1102: out of memory

[56/3845] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\ConvertExpr.cpp.obj
FAILED: tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/ConvertExpr.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Lower\CMakeFiles\FortranLower.dir\ConvertExpr.cpp.obj /Fdtools\flang\lib\Lower\CMakeFiles\FortranLower.dir\FortranLower.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower\ConvertExpr.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\functional(821): fatal error C1060: compiler is out of heap space
[57/3845] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\Bridge.cpp.obj
FAILED: tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/Bridge.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Lower\CMakeFiles\FortranLower.dir\Bridge.cpp.obj /Fdtools\flang\lib\Lower\CMakeFiles\FortranLower.dir\FortranLower.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower\Bridge.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\xtree(435): fatal error C1060: compiler is out of heap space
[58/3845] Building CXX object tools\flang\lib\FrontendTool\CMakeFiles\flangFrontendTool.dir\ExecuteCompilerInvocation.cpp.obj
FAILED: tools/flang/lib/FrontendTool/CMakeFiles/flangFrontendTool.dir/ExecuteCompilerInvocation.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DCLANG_BUILD_STATIC -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\FrontendTool -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\FrontendTool -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\FrontendTool\CMakeFiles\flangFrontendTool.dir\ExecuteCompilerInvocation.cpp.obj /Fdtools\flang\lib\FrontendTool\CMakeFiles\flangFrontendTool.dir\flangFrontendTool.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\FrontendTool\ExecuteCompilerInvocation.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\variant(481): fatal error C1060: compiler is out of heap space
[59/3845] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\ConvertCall.cpp.obj
FAILED: tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/ConvertCall.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Lower\CMakeFiles\FortranLower.dir\ConvertCall.cpp.obj /Fdtools\flang\lib\Lower\CMakeFiles\FortranLower.dir\FortranLower.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower\ConvertCall.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\tuple(132): fatal error C1060: compiler is out of heap space
[60/3845] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\OpenMP\ClauseProcessor.cpp.obj
FAILED: tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/ClauseProcessor.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Lower\CMakeFiles\FortranLower.dir\OpenMP\ClauseProcessor.cpp.obj /Fdtools\flang\lib\Lower\CMakeFiles\FortranLower.dir\FortranLower.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower\OpenMP\ClauseProcessor.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\variant(479): fatal error C1060: compiler is out of heap space
[61/3845] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\OpenMP\Utils.cpp.obj
FAILED: tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/Utils.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Lower\CMakeFiles\FortranLower.dir\OpenMP\Utils.cpp.obj /Fdtools\flang\lib\Lower\CMakeFiles\FortranLower.dir\FortranLower.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower\OpenMP\Utils.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\type_traits(775): fatal error C1060: compiler is out of heap space
[62/3845] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\OpenMP\PrivateReductionUtils.cpp.obj
FAILED: tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/PrivateReductionUtils.cpp.obj 
sccache C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\Hostx64\x64\cl.exe  /nologo /TP -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Itools\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\include -Itools\flang\include -Iinclude -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\..\mlir\include -Itools\mlir\include -Itools\clang\include -IC:\ws\buildbot\premerge-monolithic-windows\llvm-project\llvm\..\clang\include /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -wd4251 -wd4275 -w14062 -we4238 /Gw /O2 /Ob2  -MD  /EHs-c- /GR- -UNDEBUG -std:c++17 /showIncludes /Fotools\flang\lib\Lower\CMakeFiles\FortranLower.dir\OpenMP\PrivateReductionUtils.cpp.obj /Fdtools\flang\lib\Lower\CMakeFiles\FortranLower.dir\FortranLower.pdb /FS -c C:\ws\buildbot\premerge-monolithic-windows\llvm-project\flang\lib\Lower\OpenMP\PrivateReductionUtils.cpp
C:\BuildTools\VC\Tools\MSVC\14.29.30133\include\variant(481): fatal error C1060: compiler is out of heap space
[63/3845] Building CXX object tools\flang\lib\Lower\CMakeFiles\FortranLower.dir\ConvertProcedureDesignator.cpp.obj

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

flang:fir-hlfir flang Flang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants