Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang][acc] Implement MappableType interfaces for fir.box and fir.array #122495

Merged
merged 3 commits into from
Jan 14, 2025

Conversation

razvanlupusoru
Copy link
Contributor

The newly introduced MappableType interface in acc dialect was primarily intended to allow variables with non-materialized storage to be used in acc data clauses (previously everything was required to be pointer-like). One motivator for this was fir.box since it is possible to be passed to functions without a wrapping fir.ref and also it can be generated directly via operations like fir.embox - and unlike other variable representations in FIR, the underlying storage for it does not get materialized until LLVM codegen.

The new interface is being attached to both fir.box and fir.array. Strictly speaking, attaching to the latter is primarily for consistency since the MappableType interface requires implementation of utilities to compute byte size - and it made sense that a
fir.box<fir.array<10xi32>> and fir.array<10xi32> would have a consistently computable size. This decision may be revisited as MappableType interface evolves.

The new interface attachments are made in a new library named FIROpenACCSupport. The reason for this is to avoid circular dependencies since the implementation of this library is reusing code from lowering of OpenACC. More specifically, the types are defined in FIRDialect and FortranLower depends on it. Thus we cannot attach these interfaces in FIRDialect.

The newly introduced MappableType interface in `acc` dialect was
primarily intended to allow variables with non-materialized storage to
be used in acc data clauses (previously everything was required to be
`pointer-like`). One motivator for this was `fir.box` since it
is possible to be passed to functions without a wrapping `fir.ref` and
also it can be generated directly via operations like `fir.embox` -
and unlike other variable representations in FIR, the underlying
storage for it does not get materialized until LLVM codegen.

The new interface is being attached to both `fir.box` and `fir.array`.
Strictly speaking, attaching to the latter is primarily for consistency
since the MappableType interface requires implementation of utilities
to compute byte size - and it made sense that a
`fir.box<fir.array<10xi32>>` and `fir.array<10xi32>` would have a
consistently computable size. This decision may be revisited as
MappableType interface evolves.

The new interface attachments are made in a new library named
`FIROpenACCSupport`. The reason for this is to avoid circular
dependencies since the implementation of this library is reusing code
from lowering of OpenACC. More specifically, the types are defined in
`FIRDialect` and `FortranLower` depends on it. Thus we cannot attach
these interfaces in `FIRDialect`.
@llvmbot llvmbot added flang:driver flang Flang issues not falling into any other category flang:fir-hlfir openacc labels Jan 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 10, 2025

@llvm/pr-subscribers-flang-driver

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

Author: Razvan Lupusoru (razvanlupusoru)

Changes

The newly introduced MappableType interface in acc dialect was primarily intended to allow variables with non-materialized storage to be used in acc data clauses (previously everything was required to be pointer-like). One motivator for this was fir.box since it is possible to be passed to functions without a wrapping fir.ref and also it can be generated directly via operations like fir.embox - and unlike other variable representations in FIR, the underlying storage for it does not get materialized until LLVM codegen.

The new interface is being attached to both fir.box and fir.array. Strictly speaking, attaching to the latter is primarily for consistency since the MappableType interface requires implementation of utilities to compute byte size - and it made sense that a
fir.box&lt;fir.array&lt;10xi32&gt;&gt; and fir.array&lt;10xi32&gt; would have a consistently computable size. This decision may be revisited as MappableType interface evolves.

The new interface attachments are made in a new library named FIROpenACCSupport. The reason for this is to avoid circular dependencies since the implementation of this library is reusing code from lowering of OpenACC. More specifically, the types are defined in FIRDialect and FortranLower depends on it. Thus we cannot attach these interfaces in FIRDialect.


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

17 Files Affected:

  • (added) flang/include/flang/Optimizer/OpenACC/FIROpenACCTypeInterfaces.h (+43)
  • (added) flang/include/flang/Optimizer/OpenACC/RegisterOpenACCExtensions.h (+22)
  • (modified) flang/include/flang/Optimizer/Support/InitFIR.h (+2)
  • (modified) flang/lib/Frontend/CMakeLists.txt (+1)
  • (modified) flang/lib/Optimizer/CMakeLists.txt (+1)
  • (modified) flang/lib/Optimizer/Dialect/CMakeLists.txt (+1-1)
  • (added) flang/lib/Optimizer/OpenACC/CMakeLists.txt (+22)
  • (added) flang/lib/Optimizer/OpenACC/FIROpenACCTypeInterfaces.cpp (+221)
  • (added) flang/lib/Optimizer/OpenACC/RegisterOpenACCExtensions.cpp (+28)
  • (added) flang/test/Fir/OpenACC/openacc-mappable.fir (+25)
  • (modified) flang/test/lib/CMakeLists.txt (+1)
  • (added) flang/test/lib/OpenACC/CMakeLists.txt (+21)
  • (added) flang/test/lib/OpenACC/TestOpenACCInterfaces.cpp (+85)
  • (modified) flang/tools/fir-lsp-server/CMakeLists.txt (+1)
  • (modified) flang/tools/fir-opt/CMakeLists.txt (+2)
  • (modified) flang/tools/fir-opt/fir-opt.cpp (+2)
  • (modified) flang/tools/tco/CMakeLists.txt (+1)
diff --git a/flang/include/flang/Optimizer/OpenACC/FIROpenACCTypeInterfaces.h b/flang/include/flang/Optimizer/OpenACC/FIROpenACCTypeInterfaces.h
new file mode 100644
index 00000000000000..c1bea32a22361d
--- /dev/null
+++ b/flang/include/flang/Optimizer/OpenACC/FIROpenACCTypeInterfaces.h
@@ -0,0 +1,43 @@
+//===- FIROpenACCTypeInterfaces.h -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains external dialect interfaces for FIR.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FLANG_OPTIMIZER_OPENACC_FIROPENACCTYPEINTERFACES_H_
+#define FLANG_OPTIMIZER_OPENACC_FIROPENACCTYPEINTERFACES_H_
+
+#include "flang/Optimizer/Dialect/FIRType.h"
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+
+namespace fir::acc {
+
+template <typename T>
+struct OpenACCMappableModel
+    : public mlir::acc::MappableType::ExternalModel<OpenACCMappableModel<T>,
+                                                    T> {
+  mlir::TypedValue<mlir::acc::PointerLikeType> getVarPtr(::mlir::Type type,
+                                                         mlir::Value var) const;
+
+  std::optional<llvm::TypeSize>
+  getSizeInBytes(mlir::Type type, mlir::Value var, mlir::ValueRange accBounds,
+                 const mlir::DataLayout &dataLayout) const;
+
+  std::optional<int64_t>
+  getOffsetInBytes(mlir::Type type, mlir::Value var, mlir::ValueRange accBounds,
+                   const mlir::DataLayout &dataLayout) const;
+
+  llvm::SmallVector<mlir::Value>
+  generateAccBounds(mlir::Type type, mlir::Value var,
+                    mlir::OpBuilder &builder) const;
+};
+
+} // namespace fir::acc
+
+#endif // FLANG_OPTIMIZER_OPENACC_FIROPENACCTYPEINTERFACES_H_
diff --git a/flang/include/flang/Optimizer/OpenACC/RegisterOpenACCExtensions.h b/flang/include/flang/Optimizer/OpenACC/RegisterOpenACCExtensions.h
new file mode 100644
index 00000000000000..efaddd72ebbf2b
--- /dev/null
+++ b/flang/include/flang/Optimizer/OpenACC/RegisterOpenACCExtensions.h
@@ -0,0 +1,22 @@
+//===- RegisterOpenACCExtensions.h - OpenACC Extension Registration --===--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef FLANG_OPTIMIZER_OPENACC_REGISTEROPENACCEXTENSIONS_H_
+#define FLANG_OPTIMIZER_OPENACC_REGISTEROPENACCEXTENSIONS_H_
+
+namespace mlir {
+class DialectRegistry;
+} // namespace mlir
+
+namespace fir::acc {
+
+void registerOpenACCExtensions(mlir::DialectRegistry &registry);
+
+} // namespace fir::acc
+
+#endif // FLANG_OPTIMIZER_OPENACC_REGISTEROPENACCEXTENSIONS_H_
diff --git a/flang/include/flang/Optimizer/Support/InitFIR.h b/flang/include/flang/Optimizer/Support/InitFIR.h
index 1c61c367199923..94995ac6136edd 100644
--- a/flang/include/flang/Optimizer/Support/InitFIR.h
+++ b/flang/include/flang/Optimizer/Support/InitFIR.h
@@ -17,6 +17,7 @@
 #include "flang/Optimizer/Dialect/CUF/CUFToLLVMIRTranslation.h"
 #include "flang/Optimizer/Dialect/FIRDialect.h"
 #include "flang/Optimizer/HLFIR/HLFIRDialect.h"
+#include "flang/Optimizer/OpenACC/RegisterOpenACCExtensions.h"
 #include "mlir/Conversion/Passes.h"
 #include "mlir/Dialect/Affine/Passes.h"
 #include "mlir/Dialect/Complex/IR/Complex.h"
@@ -63,6 +64,7 @@ inline void addFIRExtensions(mlir::DialectRegistry &registry,
     addFIRInlinerExtension(registry);
   addFIRToLLVMIRExtension(registry);
   cuf::registerCUFDialectTranslation(registry);
+  fir::acc::registerOpenACCExtensions(registry);
 }
 
 inline void loadNonCodegenDialects(mlir::MLIRContext &context) {
diff --git a/flang/lib/Frontend/CMakeLists.txt b/flang/lib/Frontend/CMakeLists.txt
index e954800c3b88b0..f00566d7791575 100644
--- a/flang/lib/Frontend/CMakeLists.txt
+++ b/flang/lib/Frontend/CMakeLists.txt
@@ -38,6 +38,7 @@ add_flang_library(flangFrontend
   HLFIRDialect
   HLFIRTransforms
   flangPasses
+  FIROpenACCSupport
   FlangOpenMPTransforms
   MLIRTransforms
   MLIRBuiltinToLLVMIRTranslation
diff --git a/flang/lib/Optimizer/CMakeLists.txt b/flang/lib/Optimizer/CMakeLists.txt
index 5354d7181e6516..72aba51b858708 100644
--- a/flang/lib/Optimizer/CMakeLists.txt
+++ b/flang/lib/Optimizer/CMakeLists.txt
@@ -3,6 +3,7 @@ add_subdirectory(Builder)
 add_subdirectory(CodeGen)
 add_subdirectory(Dialect)
 add_subdirectory(HLFIR)
+add_subdirectory(OpenACC)
 add_subdirectory(OpenMP)
 add_subdirectory(Passes)
 add_subdirectory(Support)
diff --git a/flang/lib/Optimizer/Dialect/CMakeLists.txt b/flang/lib/Optimizer/Dialect/CMakeLists.txt
index a8235f841b879d..08caa15700d4ca 100644
--- a/flang/lib/Optimizer/Dialect/CMakeLists.txt
+++ b/flang/lib/Optimizer/Dialect/CMakeLists.txt
@@ -6,8 +6,8 @@ add_flang_library(FIRDialect
   FIRDialect.cpp
   FIROps.cpp
   FIRType.cpp
-  FortranVariableInterface.cpp
   FirAliasTagOpInterface.cpp
+  FortranVariableInterface.cpp
   Inliner.cpp
 
   DEPENDS
diff --git a/flang/lib/Optimizer/OpenACC/CMakeLists.txt b/flang/lib/Optimizer/OpenACC/CMakeLists.txt
new file mode 100644
index 00000000000000..ed673121353c16
--- /dev/null
+++ b/flang/lib/Optimizer/OpenACC/CMakeLists.txt
@@ -0,0 +1,22 @@
+get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
+
+add_flang_library(FIROpenACCSupport
+  FIROpenACCTypeInterfaces.cpp
+  RegisterOpenACCExtensions.cpp
+
+  DEPENDS
+  FIRBuilder
+  FIRDialect
+  FIRDialectSupport
+  FIRSupport
+  HLFIRDialect
+  MLIROpenACCDialect
+
+  LINK_LIBS
+  FIRBuilder
+  FIRDialect
+  FIRDialectSupport
+  FIRSupport
+  HLFIRDialect
+  MLIROpenACCDialect
+)
diff --git a/flang/lib/Optimizer/OpenACC/FIROpenACCTypeInterfaces.cpp b/flang/lib/Optimizer/OpenACC/FIROpenACCTypeInterfaces.cpp
new file mode 100644
index 00000000000000..ebcc54add0ed12
--- /dev/null
+++ b/flang/lib/Optimizer/OpenACC/FIROpenACCTypeInterfaces.cpp
@@ -0,0 +1,221 @@
+//===-- FIROpenACCTypeInterfaces.cpp --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Implementation of external dialect interfaces for FIR.
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Optimizer/OpenACC/FIROpenACCTypeInterfaces.h"
+#include "flang/Lower/DirectivesCommon.h"
+#include "flang/Optimizer/Builder/BoxValue.h"
+#include "flang/Optimizer/Builder/FIRBuilder.h"
+#include "flang/Optimizer/Builder/HLFIRTools.h"
+#include "flang/Optimizer/Dialect/FIROps.h"
+#include "flang/Optimizer/Dialect/FIROpsSupport.h"
+#include "flang/Optimizer/Dialect/FIRType.h"
+#include "flang/Optimizer/Dialect/Support/FIRContext.h"
+#include "flang/Optimizer/Dialect/Support/KindMapping.h"
+#include "mlir/Dialect/Arith/IR/Arith.h"
+#include "mlir/Dialect/OpenACC/OpenACC.h"
+#include "mlir/Support/LLVM.h"
+
+namespace fir::acc {
+
+static mlir::TypedValue<mlir::acc::PointerLikeType>
+getPtrFromVar(mlir::Value var) {
+  if (auto ptr =
+          mlir::dyn_cast<mlir::TypedValue<mlir::acc::PointerLikeType>>(var))
+    return ptr;
+
+  if (auto load = mlir::dyn_cast_if_present<fir::LoadOp>(var.getDefiningOp())) {
+    // All FIR reference types implement the PointerLikeType interface.
+    return mlir::cast<mlir::TypedValue<mlir::acc::PointerLikeType>>(
+        load.getMemref());
+  }
+
+  return {};
+}
+
+template <>
+mlir::TypedValue<mlir::acc::PointerLikeType>
+OpenACCMappableModel<fir::SequenceType>::getVarPtr(mlir::Type type,
+                                                   mlir::Value var) const {
+  return getPtrFromVar(var);
+}
+
+template <>
+mlir::TypedValue<mlir::acc::PointerLikeType>
+OpenACCMappableModel<fir::BaseBoxType>::getVarPtr(mlir::Type type,
+                                                  mlir::Value var) const {
+  return getPtrFromVar(var);
+}
+
+template <>
+std::optional<llvm::TypeSize>
+OpenACCMappableModel<fir::SequenceType>::getSizeInBytes(
+    mlir::Type type, mlir::Value var, mlir::ValueRange accBounds,
+    const mlir::DataLayout &dataLayout) const {
+  // TODO: Bounds operation affect the total size - add support to take them
+  // into account.
+  if (!accBounds.empty())
+    return {};
+
+  // Dynamic extents or unknown ranks generally do not have compile-time
+  // computable dimensions.
+  auto seqType = mlir::cast<fir::SequenceType>(type);
+  if (seqType.hasDynamicExtents() || seqType.hasUnknownShape())
+    return {};
+
+  // Without a defining op, cannot look up appropriate kindMapping for the
+  // current context.
+  if (!var.getDefiningOp())
+    return {};
+  auto kindMap = fir::getKindMapping(var.getDefiningOp());
+  auto sizeAndAlignment =
+      fir::getTypeSizeAndAlignment(var.getLoc(), type, dataLayout, kindMap);
+  if (!sizeAndAlignment.has_value())
+    return {};
+
+  return {llvm::TypeSize::getFixed(sizeAndAlignment->first)};
+}
+
+template <>
+std::optional<llvm::TypeSize>
+OpenACCMappableModel<fir::BaseBoxType>::getSizeInBytes(
+    mlir::Type type, mlir::Value var, mlir::ValueRange accBounds,
+    const mlir::DataLayout &dataLayout) const {
+  // If we have a box value instead of box reference, the intent is to
+  // get the size of the data not the box itself.
+  if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(var.getType())) {
+    if (auto mappableTy = mlir::dyn_cast<mlir::acc::MappableType>(
+            fir::unwrapRefType(boxTy.getEleTy()))) {
+      return mappableTy.getSizeInBytes(var, accBounds, dataLayout);
+    }
+  }
+  // Size for boxes is not computable until it gets materialized.
+  return {};
+}
+
+template <>
+std::optional<int64_t>
+OpenACCMappableModel<fir::SequenceType>::getOffsetInBytes(
+    mlir::Type type, mlir::Value var, mlir::ValueRange accBounds,
+    const mlir::DataLayout &dataLayout) const {
+  // TODO: Bounds operation affect the offset- add support to take them
+  // into account.
+  if (!accBounds.empty())
+    return {};
+
+  // Dynamic extents (aka descriptor-based arrays) - may have a offset.
+  // For example, a negative stride may mean a negative offset to compute the
+  // start of array.
+  auto seqType = mlir::cast<fir::SequenceType>(type);
+  if (seqType.hasDynamicExtents() || seqType.hasUnknownShape())
+    return {};
+
+  // We have non-dynamic extents - but if for some reason the size is not
+  // computable - assume offset is not either. Otherwise, it is an offset of
+  // zero.
+  if (getSizeInBytes(type, var, accBounds, dataLayout).has_value()) {
+    return {0};
+  }
+  return {};
+}
+
+template <>
+std::optional<int64_t> OpenACCMappableModel<fir::BaseBoxType>::getOffsetInBytes(
+    mlir::Type type, mlir::Value var, mlir::ValueRange accBounds,
+    const mlir::DataLayout &dataLayout) const {
+  // If we have a box value instead of box reference, the intent is to
+  // get the offset of the data not the offset of the box itself.
+  if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(var.getType())) {
+    if (auto mappableTy = mlir::dyn_cast<mlir::acc::MappableType>(
+            fir::unwrapRefType(boxTy.getEleTy()))) {
+      return mappableTy.getOffsetInBytes(var, accBounds, dataLayout);
+    }
+  }
+  // Until boxes get materialized, the offset is not evident because it is
+  // relative to the pointer being held.
+  return {};
+}
+
+template <>
+llvm::SmallVector<mlir::Value>
+OpenACCMappableModel<fir::SequenceType>::generateAccBounds(
+    mlir::Type type, mlir::Value var, mlir::OpBuilder &builder) const {
+  assert((mlir::isa<mlir::acc::PointerLikeType>(var.getType()) ||
+          mlir::isa<mlir::acc::MappableType>(var.getType())) &&
+         "must be pointer-like or mappable");
+
+  fir::FirOpBuilder firBuilder(builder, var.getDefiningOp());
+  auto seqType = mlir::cast<fir::SequenceType>(type);
+  mlir::Location loc = var.getLoc();
+
+  mlir::Value varPtr =
+      mlir::isa<mlir::acc::PointerLikeType>(var.getType())
+          ? var
+          : mlir::cast<mlir::acc::MappableType>(var.getType()).getVarPtr(var);
+
+  if (seqType.hasDynamicExtents() || seqType.hasUnknownShape()) {
+    if (auto boxAddr =
+            mlir::dyn_cast_if_present<fir::BoxAddrOp>(varPtr.getDefiningOp())) {
+      mlir::Value box = boxAddr.getVal();
+      auto res =
+          hlfir::translateToExtendedValue(loc, firBuilder, hlfir::Entity(box));
+      fir::ExtendedValue exv = res.first;
+      mlir::Value boxRef = box;
+      if (auto boxPtr = getPtrFromVar(box)) {
+        boxRef = boxPtr;
+      }
+      // TODO: Handle Fortran optional.
+      const mlir::Value isPresent;
+      Fortran::lower::AddrAndBoundsInfo info(box, boxRef, isPresent,
+                                             box.getType());
+      return Fortran::lower::genBoundsOpsFromBox<mlir::acc::DataBoundsOp,
+                                                 mlir::acc::DataBoundsType>(
+          firBuilder, loc, exv, info);
+    }
+    assert(false && "array with unknown dimension expected to have descriptor");
+    return {};
+  }
+
+  // TODO: Detect assumed-size case.
+  const bool isAssumedSize = false;
+  auto valToCheck = varPtr;
+  if (auto boxAddr =
+          mlir::dyn_cast_if_present<fir::BoxAddrOp>(varPtr.getDefiningOp())) {
+    valToCheck = boxAddr.getVal();
+  }
+  auto res = hlfir::translateToExtendedValue(loc, firBuilder,
+                                             hlfir::Entity(valToCheck));
+  fir::ExtendedValue exv = res.first;
+  return Fortran::lower::genBaseBoundsOps<mlir::acc::DataBoundsOp,
+                                          mlir::acc::DataBoundsType>(
+      firBuilder, loc, exv,
+      /*isAssumedSize=*/isAssumedSize);
+}
+
+template <>
+llvm::SmallVector<mlir::Value>
+OpenACCMappableModel<fir::BaseBoxType>::generateAccBounds(
+    mlir::Type type, mlir::Value var, mlir::OpBuilder &builder) const {
+  // If we have a box value instead of box reference, the intent is to
+  // get the bounds of the data not the bounds of the box itself.
+  if (auto boxTy = mlir::dyn_cast<fir::BaseBoxType>(var.getType())) {
+    if (auto mappableTy = mlir::dyn_cast<mlir::acc::MappableType>(
+            fir::unwrapRefType(boxTy.getEleTy()))) {
+      mlir::Value data = builder.create<fir::BoxAddrOp>(var.getLoc(), var);
+      return mappableTy.generateAccBounds(data, builder);
+    }
+  }
+  // Box references are not arrays - thus generating acc.bounds does not make
+  // sense.
+  return {};
+}
+
+} // namespace fir::acc
diff --git a/flang/lib/Optimizer/OpenACC/RegisterOpenACCExtensions.cpp b/flang/lib/Optimizer/OpenACC/RegisterOpenACCExtensions.cpp
new file mode 100644
index 00000000000000..34ea122f6b997d
--- /dev/null
+++ b/flang/lib/Optimizer/OpenACC/RegisterOpenACCExtensions.cpp
@@ -0,0 +1,28 @@
+//===-- RegisterOpenACCExtensions.cpp -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Registration for OpenACC extensions as applied to FIR dialect.
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Optimizer/OpenACC/RegisterOpenACCExtensions.h"
+#include "flang/Optimizer/Dialect/FIRDialect.h"
+#include "flang/Optimizer/Dialect/FIRType.h"
+#include "flang/Optimizer/OpenACC/FIROpenACCTypeInterfaces.h"
+
+namespace fir::acc {
+void registerOpenACCExtensions(mlir::DialectRegistry &registry) {
+  registry.addExtension(+[](mlir::MLIRContext *ctx,
+                            fir::FIROpsDialect *dialect) {
+    fir::SequenceType::attachInterface<OpenACCMappableModel<fir::SequenceType>>(
+        *ctx);
+    fir::BoxType::attachInterface<OpenACCMappableModel<fir::BaseBoxType>>(*ctx);
+  });
+}
+
+} // namespace fir::acc
diff --git a/flang/test/Fir/OpenACC/openacc-mappable.fir b/flang/test/Fir/OpenACC/openacc-mappable.fir
new file mode 100644
index 00000000000000..438cb29b991c7d
--- /dev/null
+++ b/flang/test/Fir/OpenACC/openacc-mappable.fir
@@ -0,0 +1,25 @@
+// Use --mlir-disable-threading so that the diagnostic printing is serialized.
+// RUN: fir-opt %s -pass-pipeline='builtin.module(test-fir-openacc-interfaces)' -split-input-file --mlir-disable-threading 2>&1 | FileCheck %s
+
+module attributes {dlti.dl_spec = #dlti.dl_spec<f16 = dense<16> : vector<2xi64>, f128 = dense<128> : vector<2xi64>, !llvm.ptr<270> = dense<32> : vector<4xi64>, f64 = dense<64> : vector<2xi64>, !llvm.ptr<271> = dense<32> : vector<4xi64>, !llvm.ptr<272> = dense<64> : vector<4xi64>, i64 = dense<64> : vector<2xi64>, i128 = dense<128> : vector<2xi64>, f80 = dense<128> : vector<2xi64>, !llvm.ptr = dense<64> : vector<4xi64>, i1 = dense<8> : vector<2xi64>, i8 = dense<8> : vector<2xi64>, i16 = dense<16> : vector<2xi64>, i32 = dense<32> : vector<2xi64>, "dlti.endianness" = "little", "dlti.stack_alignment" = 128 : i64>, fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"} {
+  func.func @_QPsub() {
+    %c2 = arith.constant 2 : index
+    %c10 = arith.constant 10 : index
+    %0 = fir.alloca !fir.array<10xf32> {bindc_name = "arr", uniq_name = "_QFsubEarr"}
+    %1 = fir.shape_shift %c2, %c10 : (index, index) -> !fir.shapeshift<1>
+    %2 = fir.declare %0(%1) {uniq_name = "_QFsubEarr"} : (!fir.ref<!fir.array<10xf32>>, !fir.shapeshift<1>) -> !fir.ref<!fir.array<10xf32>>
+    %3 = fir.embox %2(%1) : (!fir.ref<!fir.array<10xf32>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<10xf32>>
+    %4 = fir.box_addr %3 : (!fir.box<!fir.array<10xf32>>) -> !fir.ref<!fir.array<10xf32>>
+    %5 = acc.copyin var(%3 : !fir.box<!fir.array<10xf32>>) -> !fir.box<!fir.array<10xf32>> {name = "arr", structured = false}
+    %6 = acc.copyin varPtr(%4 : !fir.ref<!fir.array<10xf32>>) -> !fir.ref<!fir.array<10xf32>> {name = "arr", structured = false}
+    acc.enter_data dataOperands(%5, %6 : !fir.box<!fir.array<10xf32>>, !fir.ref<!fir.array<10xf32>>)
+    return
+  }
+}
+
+// CHECK: Visiting: %{{.*}} = acc.copyin var(%{{.*}} : !fir.box<!fir.array<10xf32>>) -> !fir.box<!fir.array<10xf32>> {name = "arr", structured = false}
+// CHECK: Mappable: !fir.box<!fir.array<10xf32>>
+// CHECK: Size: 40
+// CHECK: Visiting: %{{.*}} = acc.copyin varPtr(%{{.*}} : !fir.ref<!fir.array<10xf32>>) -> !fir.ref<!fir.array<10xf32>> {name = "arr", structured = false}
+// CHECK: Mappable: !fir.array<10xf32>
+// CHECK: Size: 40
diff --git a/flang/test/lib/CMakeLists.txt b/flang/test/lib/CMakeLists.txt
index fc6ef10fab1f5a..96f4c9513b11a5 100644
--- a/flang/test/lib/CMakeLists.txt
+++ b/flang/test/lib/CMakeLists.txt
@@ -1 +1,2 @@
 add_subdirectory(Analysis)
+add_subdirectory(OpenACC)
diff --git a/flang/test/lib/OpenACC/CMakeLists.txt b/flang/test/lib/OpenACC/CMakeLists.txt
new file mode 100644
index 00000000000000..54a81373d253fa
--- /dev/null
+++ b/flang/test/lib/OpenACC/CMakeLists.txt
@@ -0,0 +1,21 @@
+add_flang_library(FIRTestOpenACCInterfaces
+  TestOpenACCInterfaces.cpp
+
+  DEPENDS
+  FIRDialect
+  FIRBuilder
+  FIROpenACCSupport
+  FIRSupport
+  FIRTransforms
+  MLIROpenACCDialect
+
+  LINK_LIBS
+  FIRDialect
+  FIRBuilder
+  FIROpenACCSupport
+  FIRSupport
+  MLIRIR
+  MLIROpenACCDialect
+  MLIRSupport
+  MLIRFuncDialect
+)
diff --git a/flang/test/lib/OpenACC/TestOpenACCInterfaces.cpp b/flang/test/lib/OpenACC/TestOpenACCInterfaces.cpp
new file mode 100644
index 00000000000000..a01396748f4c2c
--- /dev/null
+++ b/flang/test/lib/OpenACC/TestOpenACCInterfaces.cpp
@@ -0,0 +1,85 @@
+//===- TestOpenACCInterfaces.cpp ------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--------------------------------...
[truncated]

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.

Few questions, LGTM otherwise!

@razvanlupusoru razvanlupusoru merged commit 01a0d21 into llvm:main Jan 14, 2025
8 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 14, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-libcxx running on linaro-flang-aarch64-libcxx while building flang at step 5 "build-unified-tree".

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

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
116.155 [152/7/7161] Creating library symlink lib/libHLFIRTransforms.so
116.690 [151/7/7162] Linking CXX shared library lib/libflangPasses.so.20.0git
116.695 [150/7/7163] Creating library symlink lib/libflangPasses.so
123.824 [150/6/7164] Linking CXX shared library lib/libFortranLower.so.20.0git
123.831 [149/6/7165] Creating library symlink lib/libFortranLower.so
125.926 [149/5/7166] Building CXX object tools/flang/tools/fir-opt/CMakeFiles/fir-opt.dir/fir-opt.cpp.o
145.075 [149/4/7167] Building CXX object tools/flang/lib/Optimizer/OpenACC/CMakeFiles/FIROpenACCSupport.dir/FIROpenACCTypeInterfaces.cpp.o
145.211 [148/4/7168] Linking CXX shared library lib/libFIROpenACCSupport.so.20.0git
145.217 [147/4/7169] Creating library symlink lib/libFIROpenACCSupport.so
145.348 [145/5/7170] Linking CXX shared library lib/libFIRTestOpenACCInterfaces.so.20.0git
FAILED: lib/libFIRTestOpenACCInterfaces.so.20.0git 
: && /usr/local/bin/c++ -fPIC -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG  -stdlib=libc++ -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libFIRTestOpenACCInterfaces.so.20.0git -o lib/libFIRTestOpenACCInterfaces.so.20.0git tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/lib:"  lib/libFIROpenACCSupport.so.20.0git  lib/libFIRBuilder.so.20.0git  lib/libFIRSupport.so.20.0git  lib/libFIRDialect.so.20.0git  lib/libMLIROpenACCDialect.so.20.0git  lib/libMLIROpenACCMPCommon.so.20.0git  lib/libMLIRLLVMDialect.so.20.0git  lib/libLLVMBitWriter.so.20.0git  lib/libLLVMAsmParser.so.20.0git  lib/libLLVMBitReader.so.20.0git  lib/libLLVMCore.so.20.0git  lib/libLLVMBinaryFormat.so.20.0git  lib/libMLIRFuncDialect.so.20.0git  lib/libMLIRMemRefDialect.so.20.0git  lib/libMLIRMemorySlotInterfaces.so.20.0git  lib/libMLIRArithUtils.so.20.0git  lib/libMLIRComplexDialect.so.20.0git  lib/libMLIRArithDialect.so.20.0git  lib/libMLIRDialect.so.20.0git  lib/libMLIRCastInterfaces.so.20.0git  lib/libMLIRInferIntRangeCommon.so.20.0git  lib/libMLIRDialectUtils.so.20.0git  lib/libMLIRShapedOpInterfaces.so.20.0git  lib/libMLIRUBDialect.so.20.0git  lib/libMLIRValueBoundsOpInterface.so.20.0git  lib/libMLIRDestinationStyleOpInterface.so.20.0git  lib/libMLIRAnalysis.so.20.0git  lib/libMLIRCallInterfaces.so.20.0git  lib/libMLIRControlFlowInterfaces.so.20.0git  lib/libMLIRInferTypeOpInterface.so.20.0git  lib/libMLIRSideEffectInterfaces.so.20.0git  lib/libMLIRDataLayoutInterfaces.so.20.0git  lib/libMLIRViewLikeInterface.so.20.0git  lib/libMLIRInferIntRangeInterface.so.20.0git  lib/libMLIRLoopLikeInterface.so.20.0git  lib/libMLIRFunctionInterfaces.so.20.0git  lib/libMLIRIR.so.20.0git  lib/libMLIRSupport.so.20.0git  lib/libMLIRPresburger.so.20.0git  lib/libLLVMSupport.so.20.0git  -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/lib && :
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o: in function `fir::test::registerTestFIROpenACCInterfacesPass()':
TestOpenACCInterfaces.cpp:(.text._ZN3fir4test36registerTestFIROpenACCInterfacesPassEv+0x28): undefined reference to `mlir::registerPass(std::__1::function<std::__1::unique_ptr<mlir::Pass, std::__1::default_delete<mlir::Pass> > ()> const&)'
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o: in function `mlir::Pass::~Pass()':
TestOpenACCInterfaces.cpp:(.text._ZN4mlir4PassD2Ev[_ZN4mlir4PassD2Ev]+0x10): undefined reference to `vtable for mlir::Pass'
/usr/bin/ld: TestOpenACCInterfaces.cpp:(.text._ZN4mlir4PassD2Ev[_ZN4mlir4PassD2Ev]+0x18): undefined reference to `vtable for mlir::Pass'
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o:(.data.rel.ro._ZTVN12_GLOBAL__N_124TestFIROpenACCInterfacesE+0x40): undefined reference to `mlir::Pass::initializeOptions(llvm::StringRef, llvm::function_ref<llvm::LogicalResult (llvm::Twine const&)>)'
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o:(.data.rel.ro._ZTVN12_GLOBAL__N_124TestFIROpenACCInterfacesE+0x68): undefined reference to `mlir::Pass::anchor()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
146.029 [145/4/7171] Linking CXX executable bin/fir-lsp-server
174.000 [145/3/7172] Building CXX object tools/flang/tools/bbc/CMakeFiles/bbc.dir/bbc.cpp.o
216.593 [145/2/7173] Building CXX object tools/flang/tools/tco/CMakeFiles/tco.dir/tco.cpp.o
273.985 [145/1/7174] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/FrontendActions.cpp.o
ninja: build stopped: subcommand failed.

@razvanlupusoru
Copy link
Contributor Author

LLVM Buildbot has detected a new failure on builder flang-aarch64-libcxx running on linaro-flang-aarch64-libcxx while building flang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/89/builds/14353
Here is the relevant piece of the build log for the reference

Step 5 (build-unified-tree) failure: build (failure)
...
116.155 [152/7/7161] Creating library symlink lib/libHLFIRTransforms.so
116.690 [151/7/7162] Linking CXX shared library lib/libflangPasses.so.20.0git
116.695 [150/7/7163] Creating library symlink lib/libflangPasses.so
123.824 [150/6/7164] Linking CXX shared library lib/libFortranLower.so.20.0git
123.831 [149/6/7165] Creating library symlink lib/libFortranLower.so
125.926 [149/5/7166] Building CXX object tools/flang/tools/fir-opt/CMakeFiles/fir-opt.dir/fir-opt.cpp.o
145.075 [149/4/7167] Building CXX object tools/flang/lib/Optimizer/OpenACC/CMakeFiles/FIROpenACCSupport.dir/FIROpenACCTypeInterfaces.cpp.o
145.211 [148/4/7168] Linking CXX shared library lib/libFIROpenACCSupport.so.20.0git
145.217 [147/4/7169] Creating library symlink lib/libFIROpenACCSupport.so
145.348 [145/5/7170] Linking CXX shared library lib/libFIRTestOpenACCInterfaces.so.20.0git
FAILED: lib/libFIRTestOpenACCInterfaces.so.20.0git 
: && /usr/local/bin/c++ -fPIC -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG  -stdlib=libc++ -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libFIRTestOpenACCInterfaces.so.20.0git -o lib/libFIRTestOpenACCInterfaces.so.20.0git tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/lib:"  lib/libFIROpenACCSupport.so.20.0git  lib/libFIRBuilder.so.20.0git  lib/libFIRSupport.so.20.0git  lib/libFIRDialect.so.20.0git  lib/libMLIROpenACCDialect.so.20.0git  lib/libMLIROpenACCMPCommon.so.20.0git  lib/libMLIRLLVMDialect.so.20.0git  lib/libLLVMBitWriter.so.20.0git  lib/libLLVMAsmParser.so.20.0git  lib/libLLVMBitReader.so.20.0git  lib/libLLVMCore.so.20.0git  lib/libLLVMBinaryFormat.so.20.0git  lib/libMLIRFuncDialect.so.20.0git  lib/libMLIRMemRefDialect.so.20.0git  lib/libMLIRMemorySlotInterfaces.so.20.0git  lib/libMLIRArithUtils.so.20.0git  lib/libMLIRComplexDialect.so.20.0git  lib/libMLIRArithDialect.so.20.0git  lib/libMLIRDialect.so.20.0git  lib/libMLIRCastInterfaces.so.20.0git  lib/libMLIRInferIntRangeCommon.so.20.0git  lib/libMLIRDialectUtils.so.20.0git  lib/libMLIRShapedOpInterfaces.so.20.0git  lib/libMLIRUBDialect.so.20.0git  lib/libMLIRValueBoundsOpInterface.so.20.0git  lib/libMLIRDestinationStyleOpInterface.so.20.0git  lib/libMLIRAnalysis.so.20.0git  lib/libMLIRCallInterfaces.so.20.0git  lib/libMLIRControlFlowInterfaces.so.20.0git  lib/libMLIRInferTypeOpInterface.so.20.0git  lib/libMLIRSideEffectInterfaces.so.20.0git  lib/libMLIRDataLayoutInterfaces.so.20.0git  lib/libMLIRViewLikeInterface.so.20.0git  lib/libMLIRInferIntRangeInterface.so.20.0git  lib/libMLIRLoopLikeInterface.so.20.0git  lib/libMLIRFunctionInterfaces.so.20.0git  lib/libMLIRIR.so.20.0git  lib/libMLIRSupport.so.20.0git  lib/libMLIRPresburger.so.20.0git  lib/libLLVMSupport.so.20.0git  -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/lib && :
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o: in function `fir::test::registerTestFIROpenACCInterfacesPass()':
TestOpenACCInterfaces.cpp:(.text._ZN3fir4test36registerTestFIROpenACCInterfacesPassEv+0x28): undefined reference to `mlir::registerPass(std::__1::function<std::__1::unique_ptr<mlir::Pass, std::__1::default_delete<mlir::Pass> > ()> const&)'
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o: in function `mlir::Pass::~Pass()':
TestOpenACCInterfaces.cpp:(.text._ZN4mlir4PassD2Ev[_ZN4mlir4PassD2Ev]+0x10): undefined reference to `vtable for mlir::Pass'
/usr/bin/ld: TestOpenACCInterfaces.cpp:(.text._ZN4mlir4PassD2Ev[_ZN4mlir4PassD2Ev]+0x18): undefined reference to `vtable for mlir::Pass'
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o:(.data.rel.ro._ZTVN12_GLOBAL__N_124TestFIROpenACCInterfacesE+0x40): undefined reference to `mlir::Pass::initializeOptions(llvm::StringRef, llvm::function_ref<llvm::LogicalResult (llvm::Twine const&)>)'
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o:(.data.rel.ro._ZTVN12_GLOBAL__N_124TestFIROpenACCInterfacesE+0x68): undefined reference to `mlir::Pass::anchor()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
146.029 [145/4/7171] Linking CXX executable bin/fir-lsp-server
174.000 [145/3/7172] Building CXX object tools/flang/tools/bbc/CMakeFiles/bbc.dir/bbc.cpp.o
216.593 [145/2/7173] Building CXX object tools/flang/tools/tco/CMakeFiles/tco.dir/tco.cpp.o
273.985 [145/1/7174] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/FrontendActions.cpp.o
ninja: build stopped: subcommand failed.

I suspect that there is a missing dependency on MLIRPass. I am working on resolving this.

razvanlupusoru pushed a commit to razvanlupusoru/llvm-project that referenced this pull request Jan 14, 2025
According to one of the LLVM builds:
llvm#122495 (comment)
The linking to various "mlir::Pass::" methods is failing. Ensure
dependency is properly setup.
@razvanlupusoru
Copy link
Contributor Author

I sent out a fix here: #122953

razvanlupusoru added a commit that referenced this pull request Jan 14, 2025
According to one of the LLVM builds:

#122495 (comment)
The linking to various "mlir::Pass::" methods is failing. Ensure
dependency is properly setup.
github-actions bot pushed a commit to arm/arm-toolchain that referenced this pull request Jan 14, 2025
…953)

According to one of the LLVM builds:

llvm/llvm-project#122495 (comment)
The linking to various "mlir::Pass::" methods is failing. Ensure
dependency is properly setup.
@razvanlupusoru
Copy link
Contributor Author

Here is another fix: #122960
This time to fix the bbc tool.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 14, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-sharedlibs running on linaro-flang-aarch64-sharedlibs while building flang at step 5 "build-unified-tree".

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

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
1987.625 [682/1/6849] Creating library symlink lib/libFortranLower.so
1989.814 [681/1/6850] Linking CXX shared library lib/libHLFIRTransforms.so.20.0git
1989.833 [680/1/6851] Creating library symlink lib/libHLFIRTransforms.so
1991.141 [679/1/6852] Linking CXX shared library lib/libflangPasses.so.20.0git
1991.156 [678/1/6853] Creating library symlink lib/libflangPasses.so
1992.262 [677/1/6854] Linking CXX shared library lib/libflangFrontend.so.20.0git
1992.282 [676/1/6855] Creating library symlink lib/libflangFrontend.so
1993.024 [675/1/6856] Linking CXX shared library lib/libflangFrontendTool.so.20.0git
1993.034 [674/1/6857] Creating library symlink lib/libflangFrontendTool.so
1993.845 [673/1/6858] Linking CXX executable bin/bbc
FAILED: bin/bbc 
: && /usr/local/bin/c++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/./lib  -Wl,--gc-sections tools/flang/tools/bbc/CMakeFiles/bbc.dir/bbc.cpp.o -o bin/bbc  -Wl,-rpath,"\$ORIGIN/../lib:/home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/lib:"  lib/libLLVMAArch64CodeGen.so.20.0git  lib/libLLVMAArch64Desc.so.20.0git  lib/libLLVMAArch64Info.so.20.0git  lib/libflangFrontend.so.20.0git  lib/libflangPasses.so.20.0git  lib/libFortranLower.so.20.0git  lib/libHLFIRTransforms.so.20.0git  lib/libFlangOpenMPTransforms.so.20.0git  lib/libFIRTransforms.so.20.0git  lib/libFortranSemantics.so.20.0git  lib/libFIRBuilder.so.20.0git  lib/libCUFDialect.so.20.0git  lib/libFIRSupport.so.20.0git  lib/libMLIRFuncAllExtensions.so.20.0git  lib/libMLIRFuncInlinerExtension.so.20.0git  lib/libMLIRFuncMeshShardingExtensions.so.20.0git  lib/libMLIRTensorAllExtensions.so.20.0git  lib/libMLIRTensorMeshShardingExtensions.so.20.0git  lib/libFortranEvaluate.so.20.0git  lib/libFortranParser.so.20.0git  lib/libFortranCommon.so.20.0git  lib/libHLFIRDialect.so.20.0git  lib/libFIRDialect.so.20.0git  lib/libCUFAttrs.so.20.0git  lib/libFIRDialectSupport.so.20.0git  lib/libMLIRAffineTransformOps.so.20.0git  lib/libMLIRAMDGPUTransforms.so.20.0git  lib/libMLIRAMDGPUUtils.so.20.0git  lib/libMLIRAMDGPUDialect.so.20.0git  lib/libMLIRArithValueBoundsOpInterfaceImpl.so.20.0git  lib/libMLIRArmNeonTransforms.so.20.0git  lib/libMLIRArmSMETransforms.so.20.0git  lib/libMLIRArmSMEDialect.so.20.0git  lib/libMLIRAsyncTransforms.so.20.0git  lib/libMLIRBufferizationPipelines.so.20.0git  lib/libMLIRBufferizationTransformOps.so.20.0git  lib/libMLIRControlFlowTransforms.so.20.0git  lib/libMLIRDLTITransformOps.so.20.0git  lib/libMLIREmitCTransforms.so.20.0git  lib/libMLIREmitCDialect.so.20.0git  lib/libMLIRFuncTransformOps.so.20.0git  lib/libMLIRGPUTransformOps.so.20.0git  lib/libMLIRGPUPipelines.so.20.0git  lib/libMLIRIndexToLLVM.so.20.0git  lib/libMLIRNVVMToLLVM.so.20.0git  lib/libMLIRVCIXDialect.so.20.0git  lib/libMLIRMathTransforms.so.20.0git  lib/libMLIRMemRefTransformOps.so.20.0git  lib/libMLIRMLProgramTransforms.so.20.0git  lib/libMLIRMLProgramDialect.so.20.0git  lib/libMLIRMPIDialect.so.20.0git  lib/libMLIRNVGPUUtils.so.20.0git  lib/libMLIRNVGPUTransformOps.so.20.0git  lib/libMLIRNVGPUToNVVM.so.20.0git  lib/libMLIRNVGPUTransforms.so.20.0git  lib/libMLIROpenACCTransforms.so.20.0git  lib/libMLIROpenMPDialect.so.20.0git  lib/libMLIRPolynomialDialect.so.20.0git  lib/libMLIRPtrDialect.so.20.0git  lib/libMLIRQuantTransforms.so.20.0git  lib/libMLIRSCFTransformOps.so.20.0git  lib/libMLIRShapeOpsTransforms.so.20.0git  lib/libMLIRShapeDialect.so.20.0git  lib/libMLIRSparseTensorPipelines.so.20.0git  lib/libMLIRAffineToStandard.so.20.0git  lib/libMLIRSCFToControlFlow.so.20.0git  lib/libMLIRGPUToNVVMTransforms.so.20.0git  lib/libMLIRGPUToGPURuntimeTransforms.so.20.0git  lib/libMLIRGPUTransforms.so.20.0git  lib/libMLIRAsyncToLLVM.so.20.0git  lib/libMLIRAsyncDialect.so.20.0git  lib/libMLIRFuncToLLVM.so.20.0git  lib/libMLIRArithToLLVM.so.20.0git  lib/libMLIRControlFlowToLLVM.so.20.0git  lib/libMLIRConvertToLLVMPass.so.20.0git  lib/libMLIRConvertToLLVMInterface.so.20.0git  lib/libMLIRMathToLLVM.so.20.0git  lib/libMLIRReconcileUnrealizedCasts.so.20.0git  lib/libMLIRComplexToLLVM.so.20.0git  lib/libMLIRComplexToLibm.so.20.0git  lib/libMLIRComplexToStandard.so.20.0git  lib/libMLIRMathToLibm.so.20.0git  lib/libMLIRMemRefToLLVM.so.20.0git  lib/libMLIRVectorToLLVMPass.so.20.0git  lib/libMLIRAMXTransforms.so.20.0git  lib/libMLIRAMXDialect.so.20.0git  lib/libMLIRArmNeonDialect.so.20.0git  lib/libMLIRArmSVETransforms.so.20.0git  lib/libMLIRArmSVEDialect.so.20.0git  lib/libMLIRSparseTensorTransformOps.so.20.0git  lib/libMLIRLinalgTransformOps.so.20.0git  lib/libMLIRSparseTensorTransforms.so.20.0git  lib/libMLIRLinalgTransforms.so.20.0git  lib/libMLIRIndexDialect.so.20.0git  lib/libMLIRMemRefTransforms.so.20.0git  lib/libMLIRArithTransforms.so.20.0git  lib/libMLIRFuncTransforms.so.20.0git  lib/libMLIRNVGPUDialect.so.20.0git  lib/libMLIRMeshTransforms.so.20.0git  lib/libMLIRSCFTransforms.so.20.0git  lib/libMLIRBufferizationTransforms.so.20.0git  lib/libMLIRSparseTensorUtils.so.20.0git  lib/libMLIRSPIRVModuleCombiner.so.20.0git  lib/libMLIRSPIRVTransforms.so.20.0git  lib/libMLIRSPIRVConversion.so.20.0git  lib/libMLIRSPIRVUtils.so.20.0git  lib/libMLIRTensorInferTypeOpInterfaceImpl.so.20.0git  lib/libMLIRTensorTilingInterfaceImpl.so.20.0git  lib/libMLIRLinalgUtils.so.20.0git  lib/libMLIRTensorTransformOps.so.20.0git  lib/libMLIRTensorTransforms.so.20.0git  lib/libMLIRAffineTransforms.so.20.0git  lib/libMLIRSCFUtils.so.20.0git  lib/libMLIRTilingInterface.so.20.0git  lib/libMLIRTensorUtils.so.20.0git  lib/libMLIRTosaShardingInterfaceImpl.so.20.0git  lib/libMLIRShardingInterface.so.20.0git  lib/libMLIRMeshDialect.so.20.0git  lib/libMLIRTosaTransforms.so.20.0git  lib/libMLIRTransformDebugExtension.so.20.0git  lib/libMLIRTransformDialectIRDLExtension.so.20.0git  lib/libMLIRIRDL.so.20.0git  lib/libMLIRTransformLoopExtension.so.20.0git  lib/libMLIRTransformPDLExtension.so.20.0git  lib/libMLIRTransformDialectTransforms.so.20.0git  lib/libMLIRVectorTransformOps.so.20.0git  lib/libMLIRTransformDialect.so.20.0git  lib/libMLIRTransformDialectInterfaces.so.20.0git  lib/libMLIRTransformDialectUtils.so.20.0git  lib/libMLIRVectorToSCF.so.20.0git  lib/libMLIRVectorToLLVM.so.20.0git  lib/libMLIRVectorTransforms.so.20.0git  lib/libMLIRGPUUtils.so.20.0git  lib/libMLIRLinalgDialect.so.20.0git  lib/libMLIRBufferizationDialect.so.20.0git  lib/libMLIRMathDialect.so.20.0git  lib/libMLIRSparseTensorDialect.so.20.0git  lib/libMLIRMemRefUtils.so.20.0git  lib/libMLIRArithAttrToLLVMConversion.so.20.0git  lib/libMLIRX86VectorTransforms.so.20.0git  lib/libMLIRVectorUtils.so.20.0git  lib/libMLIRX86VectorDialect.so.20.0git  lib/libMLIRLLVMCommonConversion.so.20.0git  lib/libMLIRXeGPUTransforms.so.20.0git  lib/libMLIRAffineUtils.so.20.0git  lib/libMLIRAffineAnalysis.so.20.0git  lib/libMLIRSCFDialect.so.20.0git  lib/libMLIRControlFlowDialect.so.20.0git  lib/libMLIRXeGPUDialect.so.20.0git  lib/libMLIRVectorDialect.so.20.0git  lib/libMLIRMaskableOpInterface.so.20.0git  lib/libMLIRMaskingOpInterface.so.20.0git  lib/libMLIRSPIRVTarget.so.20.0git  lib/libMLIRSPIRVSerialization.so.20.0git  lib/libMLIRSPIRVDialect.so.20.0git  lib/libMLIRSPIRVBinaryUtils.so.20.0git  lib/libMLIRNVVMTarget.so.20.0git  lib/libMLIRNVVMToLLVMIRTranslation.so.20.0git  lib/libMLIRROCDLTarget.so.20.0git  lib/libMLIRGPUDialect.so.20.0git  lib/libMLIRTargetLLVM.so.20.0git  lib/libMLIRExecutionEngineUtils.so.20.0git  lib/libLLVMPasses.so.20.0git  lib/libLLVMipo.so.20.0git  lib/libLLVMLinker.so.20.0git  lib/libMLIRROCDLToLLVMIRTranslation.so.20.0git  lib/libMLIRROCDLDialect.so.20.0git  lib/libMLIRTargetLLVMIRExport.so.20.0git  lib/libMLIRDLTIDialect.so.20.0git  lib/libMLIRLLVMIRTransforms.so.20.0git  lib/libMLIRNVVMDialect.so.20.0git  lib/libMLIRTransforms.so.20.0git  lib/libMLIRRuntimeVerifiableOpInterface.so.20.0git  lib/libMLIRTranslateLib.so.20.0git  lib/libMLIRParser.so.20.0git  lib/libMLIRBytecodeReader.so.20.0git  lib/libMLIRAsmParser.so.20.0git  lib/libMLIRTestDynDialect.so.20.0git  lib/libMLIRTosaTestPasses.so.20.0git  lib/libMLIRFuncDialect.so.20.0git  lib/libMLIRTosaDialect.so.20.0git  lib/libMLIRQuantUtils.so.20.0git  lib/libMLIRQuantDialect.so.20.0git  lib/libMLIRTensorDialect.so.20.0git  lib/libMLIRAffineDialect.so.20.0git  lib/libMLIRParallelCombiningOpInterface.so.20.0git  lib/libMLIRVectorInterfaces.so.20.0git  lib/libMLIRTransformUtils.so.20.0git  lib/libMLIRSubsetOpInterface.so.20.0git  lib/libMLIRRewrite.so.20.0git  lib/libMLIRRewritePDL.so.20.0git  lib/libMLIRPDLToPDLInterp.so.20.0git  lib/libMLIRPDLInterpDialect.so.20.0git  lib/libMLIRPDLDialect.so.20.0git  lib/libMLIRPass.so.20.0git  lib/libLLVMTarget.so.20.0git  lib/libMLIROpenACCDialect.so.20.0git  lib/libMLIRLLVMDialect.so.20.0git  lib/libLLVMBitWriter.so.20.0git  lib/libMLIRMemRefDialect.so.20.0git  lib/libMLIRArithUtils.so.20.0git  lib/libMLIRComplexDialect.so.20.0git  lib/libMLIRArithDialect.so.20.0git  lib/libMLIRUBDialect.so.20.0git  lib/libMLIRCastInterfaces.so.20.0git  lib/libMLIRInferIntRangeCommon.so.20.0git  lib/libMLIRDialectUtils.so.20.0git  lib/libMLIRShapedOpInterfaces.so.20.0git  lib/libMLIRValueBoundsOpInterface.so.20.0git  lib/libMLIRAnalysis.so.20.0git  lib/libMLIRCallInterfaces.so.20.0git  lib/libMLIRControlFlowInterfaces.so.20.0git  lib/libMLIRInferTypeOpInterface.so.20.0git  lib/libMLIRSideEffectInterfaces.so.20.0git  lib/libMLIRPresburger.so.20.0git  lib/libMLIRLoopLikeInterface.so.20.0git  lib/libMLIRInferIntRangeInterface.so.20.0git  lib/libMLIRFunctionInterfaces.so.20.0git  lib/libMLIRDataLayoutInterfaces.so.20.0git  lib/libMLIRDestinationStyleOpInterface.so.20.0git  lib/libMLIRViewLikeInterface.so.20.0git  lib/libMLIRDialect.so.20.0git  lib/libMLIRMemorySlotInterfaces.so.20.0git  lib/libMLIROpenACCMPCommon.so.20.0git  lib/libMLIRIR.so.20.0git  lib/libMLIRSupport.so.20.0git  lib/libLLVMFrontendOpenMP.so.20.0git  lib/libLLVMFrontendOffloading.so.20.0git  lib/libLLVMTransformUtils.so.20.0git  lib/libLLVMMCParser.so.20.0git  lib/libLLVMIRReader.so.20.0git  lib/libLLVMAsmParser.so.20.0git  lib/libLLVMBitReader.so.20.0git  lib/libLLVMCore.so.20.0git  lib/libLLVMMC.so.20.0git  lib/libLLVMBinaryFormat.so.20.0git  lib/libLLVMTargetParser.so.20.0git  lib/libLLVMSupport.so.20.0git  -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/lib && :
/usr/bin/ld: tools/flang/tools/bbc/CMakeFiles/bbc.dir/bbc.cpp.o: undefined reference to symbol '_ZN3fir3acc25registerOpenACCExtensionsERN4mlir15DialectRegistryE'
/usr/bin/ld: /home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/./lib/libFIROpenACCSupport.so.20.0git: error adding symbols: DSO missing from command line
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 14, 2025

LLVM Buildbot has detected a new failure on builder flang-aarch64-latest-gcc running on linaro-flang-aarch64-latest-gcc while building flang at step 5 "build-unified-tree".

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

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
339.748 [160/7/7169] Linking CXX shared library lib/libflangPasses.so.20.0git
339.763 [159/7/7170] Creating library symlink lib/libflangPasses.so
339.984 [159/6/7171] Building CXX object tools/flang/tools/fir-opt/CMakeFiles/fir-opt.dir/fir-opt.cpp.o
341.383 [159/5/7172] Building CXX object tools/flang/tools/tco/CMakeFiles/tco.dir/tco.cpp.o
346.283 [159/4/7173] Linking CXX shared library lib/libFortranLower.so.20.0git
346.297 [158/4/7174] Creating library symlink lib/libFortranLower.so
371.177 [158/3/7175] Building CXX object tools/flang/lib/Optimizer/OpenACC/CMakeFiles/FIROpenACCSupport.dir/FIROpenACCTypeInterfaces.cpp.o
371.443 [157/3/7176] Linking CXX shared library lib/libFIROpenACCSupport.so.20.0git
371.452 [156/3/7177] Creating library symlink lib/libFIROpenACCSupport.so
371.658 [153/5/7178] Linking CXX shared library lib/libFIRTestOpenACCInterfaces.so.20.0git
FAILED: lib/libFIRTestOpenACCInterfaces.so.20.0git 
: && /usr/local/bin/c++ -fPIC -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-copy -Wno-ctad-maybe-unsupported -fno-strict-aliasing -fno-semantic-interposition -O3 -DNDEBUG -fno-semantic-interposition  -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libFIRTestOpenACCInterfaces.so.20.0git -o lib/libFIRTestOpenACCInterfaces.so.20.0git tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/lib:"  lib/libFIROpenACCSupport.so.20.0git  lib/libFIRBuilder.so.20.0git  lib/libFIRSupport.so.20.0git  lib/libFIRDialect.so.20.0git  lib/libMLIROpenACCDialect.so.20.0git  lib/libMLIROpenACCMPCommon.so.20.0git  lib/libMLIRLLVMDialect.so.20.0git  lib/libLLVMBitWriter.so.20.0git  lib/libLLVMAsmParser.so.20.0git  lib/libLLVMBitReader.so.20.0git  lib/libLLVMCore.so.20.0git  lib/libLLVMBinaryFormat.so.20.0git  lib/libMLIRFuncDialect.so.20.0git  lib/libMLIRMemRefDialect.so.20.0git  lib/libMLIRMemorySlotInterfaces.so.20.0git  lib/libMLIRArithUtils.so.20.0git  lib/libMLIRComplexDialect.so.20.0git  lib/libMLIRArithDialect.so.20.0git  lib/libMLIRDialect.so.20.0git  lib/libMLIRCastInterfaces.so.20.0git  lib/libMLIRInferIntRangeCommon.so.20.0git  lib/libMLIRDialectUtils.so.20.0git  lib/libMLIRShapedOpInterfaces.so.20.0git  lib/libMLIRUBDialect.so.20.0git  lib/libMLIRValueBoundsOpInterface.so.20.0git  lib/libMLIRDestinationStyleOpInterface.so.20.0git  lib/libMLIRAnalysis.so.20.0git  lib/libMLIRCallInterfaces.so.20.0git  lib/libMLIRControlFlowInterfaces.so.20.0git  lib/libMLIRInferTypeOpInterface.so.20.0git  lib/libMLIRSideEffectInterfaces.so.20.0git  lib/libMLIRDataLayoutInterfaces.so.20.0git  lib/libMLIRViewLikeInterface.so.20.0git  lib/libMLIRInferIntRangeInterface.so.20.0git  lib/libMLIRLoopLikeInterface.so.20.0git  lib/libMLIRFunctionInterfaces.so.20.0git  lib/libMLIRIR.so.20.0git  lib/libMLIRSupport.so.20.0git  lib/libMLIRPresburger.so.20.0git  lib/libLLVMSupport.so.20.0git  -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/lib && :
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o: in function `(anonymous namespace)::TestFIROpenACCInterfaces::~TestFIROpenACCInterfaces()':
TestOpenACCInterfaces.cpp:(.text._ZN12_GLOBAL__N_124TestFIROpenACCInterfacesD2Ev+0x14): undefined reference to `vtable for mlir::Pass'
/usr/bin/ld: TestOpenACCInterfaces.cpp:(.text._ZN12_GLOBAL__N_124TestFIROpenACCInterfacesD2Ev+0x18): undefined reference to `vtable for mlir::Pass'
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o: in function `(anonymous namespace)::TestFIROpenACCInterfaces::~TestFIROpenACCInterfaces()':
TestOpenACCInterfaces.cpp:(.text._ZN12_GLOBAL__N_124TestFIROpenACCInterfacesD0Ev+0x14): undefined reference to `vtable for mlir::Pass'
/usr/bin/ld: TestOpenACCInterfaces.cpp:(.text._ZN12_GLOBAL__N_124TestFIROpenACCInterfacesD0Ev+0x18): undefined reference to `vtable for mlir::Pass'
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o: in function `fir::test::registerTestFIROpenACCInterfacesPass()':
TestOpenACCInterfaces.cpp:(.text._ZN3fir4test36registerTestFIROpenACCInterfacesPassEv+0x40): undefined reference to `mlir::registerPass(std::function<std::unique_ptr<mlir::Pass, std::default_delete<mlir::Pass> > ()> const&)'
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o:(.data.rel.ro._ZTVN12_GLOBAL__N_124TestFIROpenACCInterfacesE+0x40): undefined reference to `mlir::Pass::initializeOptions(llvm::StringRef, llvm::function_ref<llvm::LogicalResult (llvm::Twine const&)>)'
/usr/bin/ld: tools/flang/test/lib/OpenACC/CMakeFiles/FIRTestOpenACCInterfaces.dir/TestOpenACCInterfaces.cpp.o:(.data.rel.ro._ZTVN12_GLOBAL__N_124TestFIROpenACCInterfacesE+0x68): undefined reference to `mlir::Pass::anchor()'
collect2: error: ld returned 1 exit status
372.638 [153/4/7179] Linking CXX executable bin/tco
372.643 [153/3/7180] Linking CXX executable bin/fir-lsp-server
395.716 [153/2/7181] Building CXX object tools/flang/tools/bbc/CMakeFiles/bbc.dir/bbc.cpp.o
475.925 [153/1/7182] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/FrontendActions.cpp.o
ninja: build stopped: subcommand failed.

paulhuggett pushed a commit to paulhuggett/llvm-project that referenced this pull request Jan 16, 2025
…ray (llvm#122495)

The newly introduced MappableType interface in `acc` dialect was
primarily intended to allow variables with non-materialized storage to
be used in acc data clauses (previously everything was required to be
`pointer-like`). One motivator for this was `fir.box` since it is
possible to be passed to functions without a wrapping `fir.ref` and also
it can be generated directly via operations like `fir.embox` - and
unlike other variable representations in FIR, the underlying storage for
it does not get materialized until LLVM codegen.

The new interface is being attached to both `fir.box` and `fir.array`.
Strictly speaking, attaching to the latter is primarily for consistency
since the MappableType interface requires implementation of utilities to
compute byte size - and it made sense that a
`fir.box<fir.array<10xi32>>` and `fir.array<10xi32>` would have a
consistently computable size. This decision may be revisited as
MappableType interface evolves.

The new interface attachments are made in a new library named
`FIROpenACCSupport`. The reason for this is to avoid circular
dependencies since the implementation of this library is reusing code
from lowering of OpenACC. More specifically, the types are defined in
`FIRDialect` and `FortranLower` depends on it. Thus we cannot attach
these interfaces in `FIRDialect`.
paulhuggett pushed a commit to paulhuggett/llvm-project that referenced this pull request Jan 16, 2025
According to one of the LLVM builds:

llvm#122495 (comment)
The linking to various "mlir::Pass::" methods is failing. Ensure
dependency is properly setup.
DKLoehr pushed a commit to DKLoehr/llvm-project that referenced this pull request Jan 17, 2025
…ray (llvm#122495)

The newly introduced MappableType interface in `acc` dialect was
primarily intended to allow variables with non-materialized storage to
be used in acc data clauses (previously everything was required to be
`pointer-like`). One motivator for this was `fir.box` since it is
possible to be passed to functions without a wrapping `fir.ref` and also
it can be generated directly via operations like `fir.embox` - and
unlike other variable representations in FIR, the underlying storage for
it does not get materialized until LLVM codegen.

The new interface is being attached to both `fir.box` and `fir.array`.
Strictly speaking, attaching to the latter is primarily for consistency
since the MappableType interface requires implementation of utilities to
compute byte size - and it made sense that a
`fir.box<fir.array<10xi32>>` and `fir.array<10xi32>` would have a
consistently computable size. This decision may be revisited as
MappableType interface evolves.

The new interface attachments are made in a new library named
`FIROpenACCSupport`. The reason for this is to avoid circular
dependencies since the implementation of this library is reusing code
from lowering of OpenACC. More specifically, the types are defined in
`FIRDialect` and `FortranLower` depends on it. Thus we cannot attach
these interfaces in `FIRDialect`.
DKLoehr pushed a commit to DKLoehr/llvm-project that referenced this pull request Jan 17, 2025
According to one of the LLVM builds:

llvm#122495 (comment)
The linking to various "mlir::Pass::" methods is failing. Ensure
dependency is properly setup.
@pawosm-arm
Copy link
Contributor

This commit causes regression, #123377

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:driver flang:fir-hlfir flang Flang issues not falling into any other category openacc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants