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][cuda] Allocate descriptor in managed memory when memref is a block argument #123829

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

clementval
Copy link
Contributor

When emboxing a memory reference that comes from a block argument, look for the cuda data attribute to place it in managed memory when needed.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir flang:codegen labels Jan 21, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 21, 2025

@llvm/pr-subscribers-flang-codegen

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

Author: Valentin Clement (バレンタイン クレメン) (clementval)

Changes

When emboxing a memory reference that comes from a block argument, look for the cuda data attribute to place it in managed memory when needed.


Full diff: /~https://github.com/llvm/llvm-project/pull/123829.diff

2 Files Affected:

  • (modified) flang/lib/Optimizer/CodeGen/CodeGen.cpp (+29-8)
  • (modified) flang/test/Fir/CUDA/cuda-code-gen.mlir (+17)
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index 5ba93fefab3f9e..43c0e2686a8c3b 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -1725,15 +1725,35 @@ struct EmboxOpConversion : public EmboxCommonConversion<fir::EmboxOp> {
   }
 };
 
-static bool isDeviceAllocation(mlir::Value val) {
+static bool isDeviceAllocation(mlir::Value val, mlir::Value adaptorVal) {
   if (auto loadOp = mlir::dyn_cast_or_null<fir::LoadOp>(val.getDefiningOp()))
-    return isDeviceAllocation(loadOp.getMemref());
+    return isDeviceAllocation(loadOp.getMemref(), {});
   if (auto boxAddrOp =
           mlir::dyn_cast_or_null<fir::BoxAddrOp>(val.getDefiningOp()))
-    return isDeviceAllocation(boxAddrOp.getVal());
+    return isDeviceAllocation(boxAddrOp.getVal(), {});
   if (auto convertOp =
           mlir::dyn_cast_or_null<fir::ConvertOp>(val.getDefiningOp()))
-    return isDeviceAllocation(convertOp.getValue());
+    return isDeviceAllocation(convertOp.getValue(), {});
+  if (!val.getDefiningOp() && adaptorVal) {
+    if (auto blockArg = llvm::cast<mlir::BlockArgument>(adaptorVal)) {
+      if (blockArg.getOwner() && blockArg.getOwner()->getParentOp() &&
+          blockArg.getOwner()->isEntryBlock()) {
+        if (auto func = mlir::dyn_cast_or_null<mlir::FunctionOpInterface>(
+                *blockArg.getOwner()->getParentOp())) {
+          auto argAttrs = func.getArgAttrs(blockArg.getArgNumber());
+          for (auto attr : argAttrs) {
+            if (attr.getName().getValue().ends_with(cuf::getDataAttrName())) {
+              auto dataAttr =
+                  mlir::dyn_cast<cuf::DataAttributeAttr>(attr.getValue());
+              if (dataAttr.getValue() != cuf::DataAttribute::Pinned &&
+                  dataAttr.getValue() != cuf::DataAttribute::Unified)
+                return true;
+            }
+          }
+        }
+      }
+    }
+  }
   if (auto callOp = mlir::dyn_cast_or_null<fir::CallOp>(val.getDefiningOp()))
     if (callOp.getCallee() &&
         (callOp.getCallee().value().getRootReference().getValue().starts_with(
@@ -1928,7 +1948,8 @@ struct XEmboxOpConversion : public EmboxCommonConversion<fir::cg::XEmboxOp> {
     if (fir::isDerivedTypeWithLenParams(boxTy))
       TODO(loc, "fir.embox codegen of derived with length parameters");
     mlir::Value result = placeInMemoryIfNotGlobalInit(
-        rewriter, loc, boxTy, dest, isDeviceAllocation(xbox.getMemref()));
+        rewriter, loc, boxTy, dest,
+        isDeviceAllocation(xbox.getMemref(), adaptor.getMemref()));
     rewriter.replaceOp(xbox, result);
     return mlir::success();
   }
@@ -2052,9 +2073,9 @@ struct XReboxOpConversion : public EmboxCommonConversion<fir::cg::XReboxOp> {
       dest = insertStride(rewriter, loc, dest, dim, std::get<1>(iter.value()));
     }
     dest = insertBaseAddress(rewriter, loc, dest, base);
-    mlir::Value result =
-        placeInMemoryIfNotGlobalInit(rewriter, rebox.getLoc(), destBoxTy, dest,
-                                     isDeviceAllocation(rebox.getBox()));
+    mlir::Value result = placeInMemoryIfNotGlobalInit(
+        rewriter, rebox.getLoc(), destBoxTy, dest,
+        isDeviceAllocation(rebox.getBox(), rebox.getBox()));
     rewriter.replaceOp(rebox, result);
     return mlir::success();
   }
diff --git a/flang/test/Fir/CUDA/cuda-code-gen.mlir b/flang/test/Fir/CUDA/cuda-code-gen.mlir
index 3ad28fa7bd5179..7ac89836a3ff16 100644
--- a/flang/test/Fir/CUDA/cuda-code-gen.mlir
+++ b/flang/test/Fir/CUDA/cuda-code-gen.mlir
@@ -170,3 +170,20 @@ module attributes {dlti.dl_spec = #dlti.dl_spec<!llvm.ptr<270> = dense<32> : vec
 
 // CHECK-LABEL: llvm.func @_QQmain()
 // CHECK-COUNT-3: llvm.call @_FortranACUFAllocDescriptor
+
+// -----
+
+module attributes {dlti.dl_spec = #dlti.dl_spec<!llvm.ptr<270> = dense<32> : vector<4xi64>, f128 = dense<128> : vector<2xi64>, f64 = dense<64> : vector<2xi64>, f16 = dense<16> : vector<2xi64>, i32 = dense<32> : vector<2xi64>, i64 = dense<64> : vector<2xi64>, !llvm.ptr<272> = dense<64> : vector<4xi64>, !llvm.ptr<271> = dense<32> : vector<4xi64>, f80 = dense<128> : vector<2xi64>, i128 = dense<128> : vector<2xi64>, i16 = dense<16> : vector<2xi64>, i8 = dense<8> : vector<2xi64>, !llvm.ptr = dense<64> : vector<4xi64>, i1 = dense<8> : vector<2xi64>, "dlti.endianness" = "little", "dlti.stack_alignment" = 128 : i64>, fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", gpu.container_module, 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", llvm.ident = "flang version 20.0.0 (git@github.com:clementval/llvm-project.git efc2415bcce8e8a9e73e77aa122c8aba1c1fbbd2)", llvm.target_triple = "x86_64-unknown-linux-gnu"} {
+  func.func @_QPouter(%arg0: !fir.ref<!fir.array<100x100xf64>> {cuf.data_attr = #cuf.cuda<device>, fir.bindc_name = "a"}) {
+    %c0_i32 = arith.constant 0 : i32
+    %c100 = arith.constant 100 : index
+    %0 = fir.alloca tuple<!fir.box<!fir.array<100x100xf64>>>
+    %1 = fir.coordinate_of %0, %c0_i32 : (!fir.ref<tuple<!fir.box<!fir.array<100x100xf64>>>>, i32) -> !fir.ref<!fir.box<!fir.array<100x100xf64>>>
+    %2 = fircg.ext_embox %arg0(%c100, %c100) : (!fir.ref<!fir.array<100x100xf64>>, index, index) -> !fir.box<!fir.array<100x100xf64>>
+    fir.store %2 to %1 : !fir.ref<!fir.box<!fir.array<100x100xf64>>>
+    return
+  }
+}
+
+// CHECK-LABEL: llvm.func @_QPouter
+// CHECK: _FortranACUFAllocDescriptor

@clementval clementval merged commit c26e1a2 into llvm:main Jan 22, 2025
12 checks passed
@clementval clementval deleted the cuf_block_args branch January 22, 2025 01:20
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 22, 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/14873

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
63.427 [164/3/7173] Linking CXX executable bin/fir-lsp-server
67.286 [164/2/7174] Linking CXX shared library lib/libFortranSemantics.so.20.0git
67.292 [163/2/7175] Creating library symlink lib/libFortranSemantics.so
67.427 [158/6/7176] Linking CXX executable tools/flang/unittests/Evaluate/logical.test
67.431 [158/5/7177] Linking CXX executable tools/flang/unittests/Evaluate/real.test
67.432 [158/4/7178] Linking CXX executable tools/flang/unittests/Evaluate/integer.test
67.604 [158/3/7179] Linking CXX executable tools/flang/unittests/Evaluate/folding.test
67.668 [158/2/7180] Linking CXX executable tools/flang/unittests/Evaluate/expression.test
124.113 [158/1/7181] Building CXX object tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGen.cpp.o
124.522 [157/1/7182] Linking CXX shared library lib/libFIRCodeGen.so.20.0git
FAILED: lib/libFIRCodeGen.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,libFIRCodeGen.so.20.0git -o lib/libFIRCodeGen.so.20.0git tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/BoxedProcedure.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CGOps.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGen.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGenOpenMP.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/FIROpPatterns.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/PreCGRewrite.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/TBAABuilder.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/Target.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/TargetRewrite.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/TypeConverter.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/lib:"  lib/libFIRAnalysis.so.20.0git  lib/libFIRBuilder.so.20.0git  lib/libFIRSupport.so.20.0git  lib/libMLIRMathToFuncs.so.20.0git  lib/libMLIRMathToROCDL.so.20.0git  lib/libFIRDialect.so.20.0git  lib/libFIRDialectSupport.so.20.0git  lib/libMLIROpenMPToLLVM.so.20.0git  lib/libMLIRBuiltinToLLVMIRTranslation.so.20.0git  lib/libMLIRLLVMToLLVMIRTranslation.so.20.0git  lib/libMLIROpenMPDialect.so.20.0git  lib/libLLVMAsmPrinter.so.20.0git  lib/libMLIROpenACCDialect.so.20.0git  lib/libMLIROpenACCMPCommon.so.20.0git  lib/libMLIRComplexToLLVM.so.20.0git  lib/libMLIRComplexToStandard.so.20.0git  lib/libMLIRMathToLLVM.so.20.0git  lib/libMLIRMathToLibm.so.20.0git  lib/libMLIRGPUToGPURuntimeTransforms.so.20.0git  lib/libMLIRVectorToLLVM.so.20.0git  lib/libMLIRVectorTransforms.so.20.0git  lib/libMLIRVectorUtils.so.20.0git  lib/libMLIRLinalgDialect.so.20.0git  lib/libMLIRMathDialect.so.20.0git  lib/libMLIRMemRefToLLVM.so.20.0git  lib/libMLIRMemRefUtils.so.20.0git  lib/libMLIRAsyncToLLVM.so.20.0git  lib/libMLIRFuncToLLVM.so.20.0git  lib/libMLIRArithToLLVM.so.20.0git  lib/libMLIRArithAttrToLLVMConversion.so.20.0git  lib/libMLIRArithTransforms.so.20.0git  lib/libMLIRBufferizationTransforms.so.20.0git  lib/libMLIRFuncTransforms.so.20.0git  lib/libMLIRControlFlowToLLVM.so.20.0git  lib/libMLIRConvertToLLVMPass.so.20.0git  lib/libMLIRLLVMCommonConversion.so.20.0git  lib/libMLIRConvertToLLVMInterface.so.20.0git  lib/libMLIRGPUTransforms.so.20.0git  lib/libMLIRVectorDialect.so.20.0git  lib/libMLIRMaskableOpInterface.so.20.0git  lib/libMLIRMaskingOpInterface.so.20.0git  lib/libMLIRVectorInterfaces.so.20.0git  lib/libMLIRAffineUtils.so.20.0git  lib/libMLIRAffineAnalysis.so.20.0git  lib/libMLIRSCFDialect.so.20.0git  lib/libMLIRControlFlowDialect.so.20.0git  lib/libMLIRGPUUtils.so.20.0git  lib/libMLIRAsyncDialect.so.20.0git  lib/libMLIRBufferizationDialect.so.20.0git  lib/libMLIRTensorDialect.so.20.0git  lib/libMLIRParallelCombiningOpInterface.so.20.0git  lib/libMLIRAffineDialect.so.20.0git  lib/libMLIRSparseTensorDialect.so.20.0git  lib/libMLIRIndexDialect.so.20.0git  lib/libMLIRNVVMTarget.so.20.0git  lib/libMLIRNVVMToLLVMIRTranslation.so.20.0git  lib/libMLIRSPIRVTarget.so.20.0git  lib/libMLIRSPIRVSerialization.so.20.0git  lib/libMLIRSPIRVDialect.so.20.0git  lib/libMLIRSPIRVBinaryUtils.so.20.0git  lib/libMLIRROCDLTarget.so.20.0git  lib/libMLIRGPUDialect.so.20.0git  lib/libMLIRMemRefDialect.so.20.0git  lib/libMLIRArithUtils.so.20.0git  lib/libMLIRComplexDialect.so.20.0git  lib/libMLIRArithDialect.so.20.0git  lib/libMLIRCastInterfaces.so.20.0git  lib/libMLIRInferIntRangeCommon.so.20.0git  lib/libMLIRUBDialect.so.20.0git  lib/libMLIRDialectUtils.so.20.0git  lib/libMLIRDialect.so.20.0git  lib/libMLIRShapedOpInterfaces.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/libLLVMTarget.so.20.0git  lib/libMLIRROCDLToLLVMIRTranslation.so.20.0git  lib/libMLIRTargetLLVMIRExport.so.20.0git  lib/libMLIRDLTIDialect.so.20.0git  lib/libMLIRLLVMIRTransforms.so.20.0git  lib/libMLIRTransforms.so.20.0git  lib/libMLIRTransformUtils.so.20.0git  lib/libMLIRSubsetOpInterface.so.20.0git  lib/libMLIRValueBoundsOpInterface.so.20.0git  lib/libMLIRDestinationStyleOpInterface.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/libMLIRRuntimeVerifiableOpInterface.so.20.0git  lib/libMLIRFuncDialect.so.20.0git  lib/libMLIRPass.so.20.0git  lib/libMLIRAnalysis.so.20.0git  lib/libMLIRLoopLikeInterface.so.20.0git  lib/libMLIRViewLikeInterface.so.20.0git  lib/libMLIRPresburger.so.20.0git  lib/libMLIRNVVMDialect.so.20.0git  lib/libMLIRInferIntRangeInterface.so.20.0git  lib/libMLIRTranslateLib.so.20.0git  lib/libMLIRParser.so.20.0git  lib/libMLIRBytecodeReader.so.20.0git  lib/libMLIRAsmParser.so.20.0git  lib/libLLVMFrontendOpenMP.so.20.0git  lib/libMLIRROCDLDialect.so.20.0git  lib/libMLIRLLVMDialect.so.20.0git  lib/libMLIRControlFlowInterfaces.so.20.0git  lib/libMLIRFunctionInterfaces.so.20.0git  lib/libMLIRInferTypeOpInterface.so.20.0git  lib/libMLIRCallInterfaces.so.20.0git  lib/libMLIRDataLayoutInterfaces.so.20.0git  lib/libMLIRMemorySlotInterfaces.so.20.0git  lib/libLLVMBitWriter.so.20.0git  lib/libMLIRSideEffectInterfaces.so.20.0git  lib/libMLIRIR.so.20.0git  lib/libMLIRSupport.so.20.0git  lib/libLLVMFrontendOffloading.so.20.0git  lib/libLLVMTransformUtils.so.20.0git  lib/libLLVMIRReader.so.20.0git  lib/libLLVMAsmParser.so.20.0git  lib/libLLVMBitReader.so.20.0git  lib/libLLVMCore.so.20.0git  lib/libLLVMRemarks.so.20.0git  lib/libLLVMMCParser.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-libcxx/build/lib && :
/usr/bin/ld: tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGen.cpp.o: in function `isDeviceAllocation(mlir::Value, mlir::Value)':
CodeGen.cpp:(.text._ZL18isDeviceAllocationN4mlir5ValueES0_+0x164): undefined reference to `cuf::DataAttributeAttr::getValue() const'
/usr/bin/ld: CodeGen.cpp:(.text._ZL18isDeviceAllocationN4mlir5ValueES0_+0x174): undefined reference to `cuf::DataAttributeAttr::getValue() const'
/usr/bin/ld: tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGen.cpp.o: in function `decltype(auto) llvm::dyn_cast<cuf::DataAttributeAttr, mlir::Attribute>(mlir::Attribute const&)':
CodeGen.cpp:(.text._ZN4llvm8dyn_castIN3cuf17DataAttributeAttrEN4mlir9AttributeEEEDcRKT0_[_ZN4llvm8dyn_castIN3cuf17DataAttributeAttrEN4mlir9AttributeEEEDcRKT0_]+0x18): undefined reference to `mlir::detail::TypeIDResolver<cuf::DataAttributeAttr, void>::id'
/usr/bin/ld: CodeGen.cpp:(.text._ZN4llvm8dyn_castIN3cuf17DataAttributeAttrEN4mlir9AttributeEEEDcRKT0_[_ZN4llvm8dyn_castIN3cuf17DataAttributeAttrEN4mlir9AttributeEEEDcRKT0_]+0x20): undefined reference to `mlir::detail::TypeIDResolver<cuf::DataAttributeAttr, void>::id'
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 22, 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/8953

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
177.081 [174/2/7180] Building CXX object third-party/benchmark/src/CMakeFiles/benchmark.dir/string_util.cc.o
177.151 [172/3/7181] Building CXX object third-party/benchmark/src/CMakeFiles/benchmark.dir/timers.cc.o
177.164 [170/4/7182] Building CXX object third-party/benchmark/src/CMakeFiles/benchmark_main.dir/benchmark_main.cc.o
177.181 [170/3/7183] Copying llvm-locstats into /home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/./bin
177.561 [170/2/7184] Linking CXX shared library lib/libbenchmark.so.0.0.0
177.582 [169/2/7185] Creating library symlink lib/libbenchmark.so.0 lib/libbenchmark.so
177.695 [168/2/7186] Linking CXX shared library lib/libbenchmark_main.so.0.0.0
177.723 [167/2/7187] Creating library symlink lib/libbenchmark_main.so.0 lib/libbenchmark_main.so
223.411 [167/1/7188] Building CXX object tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGen.cpp.o
224.353 [166/1/7189] Linking CXX shared library lib/libFIRCodeGen.so.20.0git
FAILED: lib/libFIRCodeGen.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,libFIRCodeGen.so.20.0git -o lib/libFIRCodeGen.so.20.0git tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/BoxedProcedure.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CGOps.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGen.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGenOpenMP.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/FIROpPatterns.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/PreCGRewrite.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/TBAABuilder.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/Target.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/TargetRewrite.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/TypeConverter.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/lib:"  lib/libFIRAnalysis.so.20.0git  lib/libFIRBuilder.so.20.0git  lib/libFIRSupport.so.20.0git  lib/libMLIRMathToFuncs.so.20.0git  lib/libMLIRMathToROCDL.so.20.0git  lib/libFIRDialect.so.20.0git  lib/libFIRDialectSupport.so.20.0git  lib/libMLIROpenMPToLLVM.so.20.0git  lib/libMLIRBuiltinToLLVMIRTranslation.so.20.0git  lib/libMLIRLLVMToLLVMIRTranslation.so.20.0git  lib/libMLIROpenMPDialect.so.20.0git  lib/libLLVMAsmPrinter.so.20.0git  lib/libMLIROpenACCDialect.so.20.0git  lib/libMLIROpenACCMPCommon.so.20.0git  lib/libMLIRComplexToLLVM.so.20.0git  lib/libMLIRComplexToStandard.so.20.0git  lib/libMLIRMathToLLVM.so.20.0git  lib/libMLIRMathToLibm.so.20.0git  lib/libMLIRGPUToGPURuntimeTransforms.so.20.0git  lib/libMLIRVectorToLLVM.so.20.0git  lib/libMLIRVectorTransforms.so.20.0git  lib/libMLIRVectorUtils.so.20.0git  lib/libMLIRLinalgDialect.so.20.0git  lib/libMLIRMathDialect.so.20.0git  lib/libMLIRMemRefToLLVM.so.20.0git  lib/libMLIRMemRefUtils.so.20.0git  lib/libMLIRAsyncToLLVM.so.20.0git  lib/libMLIRFuncToLLVM.so.20.0git  lib/libMLIRArithToLLVM.so.20.0git  lib/libMLIRArithAttrToLLVMConversion.so.20.0git  lib/libMLIRArithTransforms.so.20.0git  lib/libMLIRBufferizationTransforms.so.20.0git  lib/libMLIRFuncTransforms.so.20.0git  lib/libMLIRControlFlowToLLVM.so.20.0git  lib/libMLIRConvertToLLVMPass.so.20.0git  lib/libMLIRLLVMCommonConversion.so.20.0git  lib/libMLIRConvertToLLVMInterface.so.20.0git  lib/libMLIRGPUTransforms.so.20.0git  lib/libMLIRVectorDialect.so.20.0git  lib/libMLIRMaskableOpInterface.so.20.0git  lib/libMLIRMaskingOpInterface.so.20.0git  lib/libMLIRVectorInterfaces.so.20.0git  lib/libMLIRAffineUtils.so.20.0git  lib/libMLIRAffineAnalysis.so.20.0git  lib/libMLIRSCFDialect.so.20.0git  lib/libMLIRControlFlowDialect.so.20.0git  lib/libMLIRGPUUtils.so.20.0git  lib/libMLIRAsyncDialect.so.20.0git  lib/libMLIRBufferizationDialect.so.20.0git  lib/libMLIRTensorDialect.so.20.0git  lib/libMLIRParallelCombiningOpInterface.so.20.0git  lib/libMLIRAffineDialect.so.20.0git  lib/libMLIRSparseTensorDialect.so.20.0git  lib/libMLIRIndexDialect.so.20.0git  lib/libMLIRNVVMTarget.so.20.0git  lib/libMLIRNVVMToLLVMIRTranslation.so.20.0git  lib/libMLIRSPIRVTarget.so.20.0git  lib/libMLIRSPIRVSerialization.so.20.0git  lib/libMLIRSPIRVDialect.so.20.0git  lib/libMLIRSPIRVBinaryUtils.so.20.0git  lib/libMLIRROCDLTarget.so.20.0git  lib/libMLIRGPUDialect.so.20.0git  lib/libMLIRMemRefDialect.so.20.0git  lib/libMLIRArithUtils.so.20.0git  lib/libMLIRComplexDialect.so.20.0git  lib/libMLIRArithDialect.so.20.0git  lib/libMLIRCastInterfaces.so.20.0git  lib/libMLIRInferIntRangeCommon.so.20.0git  lib/libMLIRUBDialect.so.20.0git  lib/libMLIRDialectUtils.so.20.0git  lib/libMLIRDialect.so.20.0git  lib/libMLIRShapedOpInterfaces.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/libLLVMTarget.so.20.0git  lib/libMLIRROCDLToLLVMIRTranslation.so.20.0git  lib/libMLIRTargetLLVMIRExport.so.20.0git  lib/libMLIRDLTIDialect.so.20.0git  lib/libMLIRLLVMIRTransforms.so.20.0git  lib/libMLIRTransforms.so.20.0git  lib/libMLIRTransformUtils.so.20.0git  lib/libMLIRSubsetOpInterface.so.20.0git  lib/libMLIRValueBoundsOpInterface.so.20.0git  lib/libMLIRDestinationStyleOpInterface.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/libMLIRRuntimeVerifiableOpInterface.so.20.0git  lib/libMLIRFuncDialect.so.20.0git  lib/libMLIRPass.so.20.0git  lib/libMLIRAnalysis.so.20.0git  lib/libMLIRLoopLikeInterface.so.20.0git  lib/libMLIRViewLikeInterface.so.20.0git  lib/libMLIRPresburger.so.20.0git  lib/libMLIRNVVMDialect.so.20.0git  lib/libMLIRInferIntRangeInterface.so.20.0git  lib/libMLIRTranslateLib.so.20.0git  lib/libMLIRParser.so.20.0git  lib/libMLIRBytecodeReader.so.20.0git  lib/libMLIRAsmParser.so.20.0git  lib/libLLVMFrontendOpenMP.so.20.0git  lib/libMLIRROCDLDialect.so.20.0git  lib/libMLIRLLVMDialect.so.20.0git  lib/libMLIRControlFlowInterfaces.so.20.0git  lib/libMLIRFunctionInterfaces.so.20.0git  lib/libMLIRInferTypeOpInterface.so.20.0git  lib/libMLIRCallInterfaces.so.20.0git  lib/libMLIRDataLayoutInterfaces.so.20.0git  lib/libMLIRMemorySlotInterfaces.so.20.0git  lib/libLLVMBitWriter.so.20.0git  lib/libMLIRSideEffectInterfaces.so.20.0git  lib/libMLIRIR.so.20.0git  lib/libMLIRSupport.so.20.0git  lib/libLLVMFrontendOffloading.so.20.0git  lib/libLLVMTransformUtils.so.20.0git  lib/libLLVMIRReader.so.20.0git  lib/libLLVMAsmParser.so.20.0git  lib/libLLVMBitReader.so.20.0git  lib/libLLVMCore.so.20.0git  lib/libLLVMRemarks.so.20.0git  lib/libLLVMMCParser.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-latest-gcc/build/lib && :
/usr/bin/ld: tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGen.cpp.o: in function `isDeviceAllocation(mlir::Value, mlir::Value)':
CodeGen.cpp:(.text._ZL18isDeviceAllocationN4mlir5ValueES0_+0x290): undefined reference to `mlir::detail::TypeIDResolver<cuf::DataAttributeAttr, void>::id'
/usr/bin/ld: CodeGen.cpp:(.text._ZL18isDeviceAllocationN4mlir5ValueES0_+0x294): undefined reference to `mlir::detail::TypeIDResolver<cuf::DataAttributeAttr, void>::id'
/usr/bin/ld: CodeGen.cpp:(.text._ZL18isDeviceAllocationN4mlir5ValueES0_+0x330): undefined reference to `cuf::DataAttributeAttr::getValue() const'
/usr/bin/ld: CodeGen.cpp:(.text._ZL18isDeviceAllocationN4mlir5ValueES0_+0x340): undefined reference to `cuf::DataAttributeAttr::getValue() const'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jan 22, 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/9005

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
312.600 [424/2/7126] Linking CXX executable bin/llvm-opt-report
312.667 [417/8/7127] Generating ../../bin/llvm-otool
312.756 [417/7/7128] Building CXX object tools/llvm-pdbutil/CMakeFiles/llvm-pdbutil.dir/MinimalSymbolDumper.cpp.o
312.784 [417/6/7129] Building CXX object tools/llvm-pdbutil/CMakeFiles/llvm-pdbutil.dir/PrettyBuiltinDumper.cpp.o
312.801 [417/5/7130] Building CXX object tools/llvm-pdbutil/CMakeFiles/llvm-pdbutil.dir/PdbYaml.cpp.o
312.802 [417/4/7131] Building CXX object tools/llvm-pdbutil/CMakeFiles/llvm-pdbutil.dir/PrettyClassLayoutGraphicalDumper.cpp.o
312.837 [417/3/7132] Building CXX object tools/llvm-pdbutil/CMakeFiles/llvm-pdbutil.dir/PrettyClassDefinitionDumper.cpp.o
312.840 [417/2/7133] Building CXX object tools/llvm-pdbutil/CMakeFiles/llvm-pdbutil.dir/MinimalTypeDumper.cpp.o
477.446 [417/1/7134] Building CXX object tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGen.cpp.o
478.198 [416/1/7135] Linking CXX shared library lib/libFIRCodeGen.so.20.0git
FAILED: lib/libFIRCodeGen.so.20.0git 
: && /usr/local/bin/c++ -fPIC -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,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/./lib  -Wl,--gc-sections -shared -Wl,-soname,libFIRCodeGen.so.20.0git -o lib/libFIRCodeGen.so.20.0git tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/BoxedProcedure.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CGOps.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGen.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGenOpenMP.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/FIROpPatterns.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/PreCGRewrite.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/TBAABuilder.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/Target.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/TargetRewrite.cpp.o tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/TypeConverter.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:/home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/lib:"  lib/libFIRAnalysis.so.20.0git  lib/libFIRBuilder.so.20.0git  lib/libFIRSupport.so.20.0git  lib/libMLIRMathToFuncs.so.20.0git  lib/libMLIRMathToROCDL.so.20.0git  lib/libFIRDialect.so.20.0git  lib/libFIRDialectSupport.so.20.0git  lib/libMLIROpenMPToLLVM.so.20.0git  lib/libMLIRBuiltinToLLVMIRTranslation.so.20.0git  lib/libMLIRLLVMToLLVMIRTranslation.so.20.0git  lib/libMLIROpenMPDialect.so.20.0git  lib/libLLVMAsmPrinter.so.20.0git  lib/libMLIROpenACCDialect.so.20.0git  lib/libMLIROpenACCMPCommon.so.20.0git  lib/libMLIRComplexToLLVM.so.20.0git  lib/libMLIRComplexToStandard.so.20.0git  lib/libMLIRMathToLLVM.so.20.0git  lib/libMLIRMathToLibm.so.20.0git  lib/libMLIRGPUToGPURuntimeTransforms.so.20.0git  lib/libMLIRVectorToLLVM.so.20.0git  lib/libMLIRVectorTransforms.so.20.0git  lib/libMLIRVectorUtils.so.20.0git  lib/libMLIRLinalgDialect.so.20.0git  lib/libMLIRMathDialect.so.20.0git  lib/libMLIRMemRefToLLVM.so.20.0git  lib/libMLIRMemRefUtils.so.20.0git  lib/libMLIRAsyncToLLVM.so.20.0git  lib/libMLIRFuncToLLVM.so.20.0git  lib/libMLIRArithToLLVM.so.20.0git  lib/libMLIRArithAttrToLLVMConversion.so.20.0git  lib/libMLIRArithTransforms.so.20.0git  lib/libMLIRBufferizationTransforms.so.20.0git  lib/libMLIRFuncTransforms.so.20.0git  lib/libMLIRControlFlowToLLVM.so.20.0git  lib/libMLIRConvertToLLVMPass.so.20.0git  lib/libMLIRLLVMCommonConversion.so.20.0git  lib/libMLIRConvertToLLVMInterface.so.20.0git  lib/libMLIRGPUTransforms.so.20.0git  lib/libMLIRVectorDialect.so.20.0git  lib/libMLIRMaskableOpInterface.so.20.0git  lib/libMLIRMaskingOpInterface.so.20.0git  lib/libMLIRVectorInterfaces.so.20.0git  lib/libMLIRAffineUtils.so.20.0git  lib/libMLIRAffineAnalysis.so.20.0git  lib/libMLIRSCFDialect.so.20.0git  lib/libMLIRControlFlowDialect.so.20.0git  lib/libMLIRGPUUtils.so.20.0git  lib/libMLIRAsyncDialect.so.20.0git  lib/libMLIRBufferizationDialect.so.20.0git  lib/libMLIRTensorDialect.so.20.0git  lib/libMLIRParallelCombiningOpInterface.so.20.0git  lib/libMLIRAffineDialect.so.20.0git  lib/libMLIRSparseTensorDialect.so.20.0git  lib/libMLIRIndexDialect.so.20.0git  lib/libMLIRNVVMTarget.so.20.0git  lib/libMLIRNVVMToLLVMIRTranslation.so.20.0git  lib/libMLIRSPIRVTarget.so.20.0git  lib/libMLIRSPIRVSerialization.so.20.0git  lib/libMLIRSPIRVDialect.so.20.0git  lib/libMLIRSPIRVBinaryUtils.so.20.0git  lib/libMLIRROCDLTarget.so.20.0git  lib/libMLIRGPUDialect.so.20.0git  lib/libMLIRMemRefDialect.so.20.0git  lib/libMLIRArithUtils.so.20.0git  lib/libMLIRComplexDialect.so.20.0git  lib/libMLIRArithDialect.so.20.0git  lib/libMLIRCastInterfaces.so.20.0git  lib/libMLIRInferIntRangeCommon.so.20.0git  lib/libMLIRUBDialect.so.20.0git  lib/libMLIRDialectUtils.so.20.0git  lib/libMLIRDialect.so.20.0git  lib/libMLIRShapedOpInterfaces.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/libLLVMTarget.so.20.0git  lib/libMLIRROCDLToLLVMIRTranslation.so.20.0git  lib/libMLIRTargetLLVMIRExport.so.20.0git  lib/libMLIRDLTIDialect.so.20.0git  lib/libMLIRLLVMIRTransforms.so.20.0git  lib/libMLIRTransforms.so.20.0git  lib/libMLIRTransformUtils.so.20.0git  lib/libMLIRSubsetOpInterface.so.20.0git  lib/libMLIRValueBoundsOpInterface.so.20.0git  lib/libMLIRDestinationStyleOpInterface.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/libMLIRRuntimeVerifiableOpInterface.so.20.0git  lib/libMLIRFuncDialect.so.20.0git  lib/libMLIRPass.so.20.0git  lib/libMLIRAnalysis.so.20.0git  lib/libMLIRLoopLikeInterface.so.20.0git  lib/libMLIRViewLikeInterface.so.20.0git  lib/libMLIRPresburger.so.20.0git  lib/libMLIRNVVMDialect.so.20.0git  lib/libMLIRInferIntRangeInterface.so.20.0git  lib/libMLIRTranslateLib.so.20.0git  lib/libMLIRParser.so.20.0git  lib/libMLIRBytecodeReader.so.20.0git  lib/libMLIRAsmParser.so.20.0git  lib/libLLVMFrontendOpenMP.so.20.0git  lib/libMLIRROCDLDialect.so.20.0git  lib/libMLIRLLVMDialect.so.20.0git  lib/libMLIRControlFlowInterfaces.so.20.0git  lib/libMLIRFunctionInterfaces.so.20.0git  lib/libMLIRInferTypeOpInterface.so.20.0git  lib/libMLIRCallInterfaces.so.20.0git  lib/libMLIRDataLayoutInterfaces.so.20.0git  lib/libMLIRMemorySlotInterfaces.so.20.0git  lib/libLLVMBitWriter.so.20.0git  lib/libMLIRSideEffectInterfaces.so.20.0git  lib/libMLIRIR.so.20.0git  lib/libMLIRSupport.so.20.0git  lib/libLLVMFrontendOffloading.so.20.0git  lib/libLLVMTransformUtils.so.20.0git  lib/libLLVMIRReader.so.20.0git  lib/libLLVMAsmParser.so.20.0git  lib/libLLVMBitReader.so.20.0git  lib/libLLVMCore.so.20.0git  lib/libLLVMRemarks.so.20.0git  lib/libLLVMMCParser.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/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGen.cpp.o: in function `isDeviceAllocation(mlir::Value, mlir::Value)':
CodeGen.cpp:(.text._ZL18isDeviceAllocationN4mlir5ValueES0_+0x164): undefined reference to `cuf::DataAttributeAttr::getValue() const'
/usr/bin/ld: CodeGen.cpp:(.text._ZL18isDeviceAllocationN4mlir5ValueES0_+0x174): undefined reference to `cuf::DataAttributeAttr::getValue() const'
/usr/bin/ld: tools/flang/lib/Optimizer/CodeGen/CMakeFiles/FIRCodeGen.dir/CodeGen.cpp.o: in function `decltype(auto) llvm::dyn_cast<cuf::DataAttributeAttr, mlir::Attribute>(mlir::Attribute const&)':
CodeGen.cpp:(.text._ZN4llvm8dyn_castIN3cuf17DataAttributeAttrEN4mlir9AttributeEEEDcRKT0_[_ZN4llvm8dyn_castIN3cuf17DataAttributeAttrEN4mlir9AttributeEEEDcRKT0_]+0x18): undefined reference to `mlir::detail::TypeIDResolver<cuf::DataAttributeAttr, void>::id'
/usr/bin/ld: CodeGen.cpp:(.text._ZN4llvm8dyn_castIN3cuf17DataAttributeAttrEN4mlir9AttributeEEEDcRKT0_[_ZN4llvm8dyn_castIN3cuf17DataAttributeAttrEN4mlir9AttributeEEEDcRKT0_]+0x20): undefined reference to `mlir::detail::TypeIDResolver<cuf::DataAttributeAttr, void>::id'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:codegen 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.

4 participants