[Mlir-commits] [mlir] 07aaa35 - [mlir][test] Fix IR/AttributeTest.cpp compilation on Solaris

Rainer Orth llvmlistbot at llvm.org
Thu Aug 4 09:56:29 PDT 2022


Author: Rainer Orth
Date: 2022-08-04T18:56:05+02:00
New Revision: 07aaa35f74d845a20d48e644671dce150ebf7748

URL: https://github.com/llvm/llvm-project/commit/07aaa35f74d845a20d48e644671dce150ebf7748
DIFF: https://github.com/llvm/llvm-project/commit/07aaa35f74d845a20d48e644671dce150ebf7748.diff

LOG: [mlir][test] Fix IR/AttributeTest.cpp compilation on Solaris

The `IR/AttributeTest.cpp` test fails to compile on Solaris:

  /vol/llvm/src/llvm-project/local/mlir/unittests/IR/AttributeTest.cpp:223:36: error: no matching function for call to 'allocate'
        AttrT::get(type, "resource", UnmanagedAsmResourceBlob::allocate(data));
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /vol/llvm/src/llvm-project/local/mlir/unittests/IR/AttributeTest.cpp:237:3: note: in instantiation of function template specialization 'checkNativeAccess<mlir::detail::DenseResourceElementsAttrBase<int8_t>, char>' requested here
    checkNativeAccess<AttrT, T>(builder.getContext(), llvm::makeArrayRef(data),
    ^
  /vol/llvm/src/llvm-project/local/mlir/unittests/IR/AttributeTest.cpp:258:3: note: in instantiation of function template specialization 'checkNativeIntAccess<mlir::detail::DenseResourceElementsAttrBase<int8_t>, char>' requested here
    checkNativeIntAccess<DenseI8ResourceElementsAttr, int8_t>(builder, 8);
    ^
  /vol/llvm/src/llvm-project/local/mlir/include/mlir/IR/AsmState.h:221:3: note: candidate template ignored: requirement '!std::is_same<char, char>::value' was not satisfied [with T = char]
    allocate(ArrayRef<T> data, bool dataIsMutable = false) {
    ^
  /vol/llvm/src/llvm-project/local/mlir/include/mlir/IR/AsmState.h:214:26: note: candidate function not viable: requires at least 2 arguments, but 1 was provided
    static AsmResourceBlob allocate(ArrayRef<char> data, size_t align,
                           ^

I suspect this happens because `char` is `signed` by default on Solaris.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D131148

Added: 
    

Modified: 
    mlir/unittests/IR/AttributeTest.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/unittests/IR/AttributeTest.cpp b/mlir/unittests/IR/AttributeTest.cpp
index 8250afd3cb971..098ce3849a606 100644
--- a/mlir/unittests/IR/AttributeTest.cpp
+++ b/mlir/unittests/IR/AttributeTest.cpp
@@ -219,8 +219,8 @@ template <typename AttrT, typename T>
 static void checkNativeAccess(MLIRContext *ctx, ArrayRef<T> data,
                               Type elementType) {
   auto type = RankedTensorType::get(data.size(), elementType);
-  auto attr =
-      AttrT::get(type, "resource", UnmanagedAsmResourceBlob::allocate(data));
+  auto attr = AttrT::get(type, "resource",
+                         UnmanagedAsmResourceBlob::allocate(data, alignof(T)));
 
   // Check that we can access and iterate the data properly.
   Optional<ArrayRef<T>> attrData = attr.tryGetAsArrayRef();


        


More information about the Mlir-commits mailing list