[Mlir-commits] [mlir] e98e599 - Revert "Foo"

Alex Zinenko llvmlistbot at llvm.org
Fri Aug 4 06:30:20 PDT 2023


Author: Alex Zinenko
Date: 2023-08-04T13:30:12Z
New Revision: e98e59955e0bff22c3c4bb7a0a34b88c016f8cff

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

LOG: Revert "Foo"

This reverts commit 3c9aa10c57cf0833ff108ecf9ffbb512bd96cc89.

No proper description of the commit.

Added: 
    

Modified: 
    mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h
    mlir/include/mlir/Conversion/LLVMCommon/Pattern.h
    mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h
    mlir/include/mlir/Conversion/MemRefToLLVM/AllocLikeConversion.h
    mlir/include/mlir/Dialect/GPU/IR/GPUBase.td
    mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
    mlir/lib/Conversion/LLVMCommon/Pattern.cpp
    mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
    mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
    mlir/lib/Dialect/GPU/IR/GPUDialect.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h b/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h
index b6e10b29fbb20c..bc45fcd84e0982 100644
--- a/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h
+++ b/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h
@@ -14,7 +14,6 @@
 #ifndef MLIR_CONVERSION_LLVMCOMMON_LOWERINGOPTIONS_H
 #define MLIR_CONVERSION_LLVMCOMMON_LOWERINGOPTIONS_H
 
-#include "mlir/IR/BuiltinTypes.h"
 #include "llvm/IR/DataLayout.h"
 
 namespace mlir {
@@ -67,9 +66,6 @@ class LowerToLLVMOptions {
   /// Get the index bitwidth.
   unsigned getIndexBitwidth() const { return indexBitwidth; }
 
-  /// Hook to customize the conversion of MemRefType to LLVMType.
-  llvm::function_ref<Type(MemRefType)> memrefIndexTypeConverter = nullptr;
-
 private:
   unsigned indexBitwidth;
 };

diff  --git a/mlir/include/mlir/Conversion/LLVMCommon/Pattern.h b/mlir/include/mlir/Conversion/LLVMCommon/Pattern.h
index 52bba8b0e97ef5..0aee13818df4d5 100644
--- a/mlir/include/mlir/Conversion/LLVMCommon/Pattern.h
+++ b/mlir/include/mlir/Conversion/LLVMCommon/Pattern.h
@@ -50,11 +50,6 @@ class ConvertToLLVMPattern : public ConversionPattern {
   /// defined by the used type converter.
   Type getIndexType() const;
 
-  /// Gets the MLIR type wrapping the LLVM integer type whose bit width is
-  /// defined by the used type converter and matching the index type needed for
-  /// MemRefType `t`.
-  Type getIndexTypeMatchingMemRef(MemRefType t) const;
-
   /// Gets the MLIR type wrapping the LLVM integer type whose bit width
   /// corresponds to that of a LLVM pointer type.
   Type getIntPtrType(unsigned addressSpace = 0) const;

diff  --git a/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h b/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h
index 970fde18ad7bad..79a68e875f045e 100644
--- a/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h
+++ b/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h
@@ -132,20 +132,14 @@ class LLVMTypeConverter : public TypeConverter {
   /// integer type with the size configured for this type converter.
   Type getIndexType();
 
-  /// Gets the LLVM representation of the index type that matches the MemRefType
-  /// `t`. The returned type is an integer type with the size configured for
-  /// this type converter.
-  Type getIndexTypeMatchingMemRef(MemRefType t);
-
-  /// Returns true if using opaque pointers was enabled in the lowering
-  /// options.
+  /// Returns true if using opaque pointers was enabled in the lowering options.
   bool useOpaquePointers() const { return getOptions().useOpaquePointers; }
 
   /// Creates an LLVM pointer type with the given element type and address
   /// space.
-  /// This function is meant to be used in code supporting both typed and
-  /// opaque pointers, as it will create an opaque pointer with the given
-  /// address space if opaque pointers are enabled in the lowering options.
+  /// This function is meant to be used in code supporting both typed and opaque
+  /// pointers, as it will create an opaque pointer with the given address space
+  /// if opaque pointers are enabled in the lowering options.
   LLVM::LLVMPointerType getPointerType(Type elementType,
                                        unsigned addressSpace = 0);
 
@@ -176,13 +170,13 @@ class LLVMTypeConverter : public TypeConverter {
 
 private:
   /// Convert a function type.  The arguments and results are converted one by
-  /// one.  Additionally, if the function returns more than one value, pack
-  /// the results into an LLVM IR structure type so that the converted
-  /// function type returns at most one result.
+  /// one.  Additionally, if the function returns more than one value, pack the
+  /// results into an LLVM IR structure type so that the converted function type
+  /// returns at most one result.
   Type convertFunctionType(FunctionType type);
 
-  /// Convert the index type.  Uses llvmModule data layout to create an
-  /// integer of the pointer bitwidth.
+  /// Convert the index type.  Uses llvmModule data layout to create an integer
+  /// of the pointer bitwidth.
   Type convertIndexType(IndexType type);
 
   /// Convert an integer type `i*` to `!llvm<"i*">`.
@@ -190,13 +184,12 @@ class LLVMTypeConverter : public TypeConverter {
 
   /// Convert a floating point type: `f16` to `f16`, `f32` to
   /// `f32` and `f64` to `f64`.  `bf16` is not supported
-  /// by LLVM. 8-bit float types are converted to 8-bit integers as this is
-  /// how all LLVM backends that support them currently represent them.
+  /// by LLVM. 8-bit float types are converted to 8-bit integers as this is how
+  /// all LLVM backends that support them currently represent them.
   Type convertFloatType(FloatType type);
 
-  /// Convert complex number type: `complex<f16>` to `!llvm<"{ half, half
-  /// }">`, `complex<f32>` to `!llvm<"{ float, float }">`, and `complex<f64>`
-  /// to
+  /// Convert complex number type: `complex<f16>` to `!llvm<"{ half, half }">`,
+  /// `complex<f32>` to `!llvm<"{ float, float }">`, and `complex<f64>` to
   /// `!llvm<"{ double, double }">`. `complex<bf16>` is not supported.
   Type convertComplexType(ComplexType type);
 
@@ -204,10 +197,10 @@ class LLVMTypeConverter : public TypeConverter {
   Type convertMemRefType(MemRefType type);
 
   /// Convert a memref type into a list of LLVM IR types that will form the
-  /// memref descriptor. If `unpackAggregates` is true the `sizes` and
-  /// `strides` arrays in the descriptors are unpacked to individual
-  /// index-typed elements, else they are are kept as rank-sized arrays of
-  /// index type. In particular, the list will contain:
+  /// memref descriptor. If `unpackAggregates` is true the `sizes` and `strides`
+  /// arrays in the descriptors are unpacked to individual index-typed elements,
+  /// else they are are kept as rank-sized arrays of index type. In particular,
+  /// the list will contain:
   /// - two pointers to the memref element type, followed by
   /// - an index-typed offset, followed by
   /// - (if unpackAggregates = true)
@@ -227,9 +220,9 @@ class LLVMTypeConverter : public TypeConverter {
   SmallVector<Type, 5> getMemRefDescriptorFields(MemRefType type,
                                                  bool unpackAggregates);
 
-  /// Convert an unranked memref type into a list of non-aggregate LLVM IR
-  /// types that will form the unranked memref descriptor. In particular, this
-  /// list contains:
+  /// Convert an unranked memref type into a list of non-aggregate LLVM IR types
+  /// that will form the unranked memref descriptor. In particular, this list
+  /// contains:
   /// - an integer rank, followed by
   /// - a pointer to the memref descriptor struct.
   /// For example, memref<*xf32> is converted to the following list:

diff  --git a/mlir/include/mlir/Conversion/MemRefToLLVM/AllocLikeConversion.h b/mlir/include/mlir/Conversion/MemRefToLLVM/AllocLikeConversion.h
index b35b77ccee6371..495c4d63986f80 100644
--- a/mlir/include/mlir/Conversion/MemRefToLLVM/AllocLikeConversion.h
+++ b/mlir/include/mlir/Conversion/MemRefToLLVM/AllocLikeConversion.h
@@ -43,8 +43,7 @@ struct AllocationOpLLVMLowering : public ConvertToLLVMPattern {
     MemRefType memRefType = op.getType();
     Value alignment;
     if (auto alignmentAttr = op.getAlignment()) {
-      Type indexType =
-          ConvertToLLVMPattern::getIndexTypeMatchingMemRef(memRefType);
+      Type indexType = getIndexType();
       alignment =
           createIndexAttrConstant(rewriter, loc, indexType, *alignmentAttr);
     } else if (!memRefType.getElementType().isSignlessIntOrIndexOrFloat()) {

diff  --git a/mlir/include/mlir/Dialect/GPU/IR/GPUBase.td b/mlir/include/mlir/Dialect/GPU/IR/GPUBase.td
index f779c0cb4592f4..842e63aff7bd9f 100644
--- a/mlir/include/mlir/Dialect/GPU/IR/GPUBase.td
+++ b/mlir/include/mlir/Dialect/GPU/IR/GPUBase.td
@@ -52,14 +52,6 @@ def GPU_Dialect : Dialect {
     /// Returns the numeric value used to identify the private memory address
     /// space.
     static AddressSpace getPrivateAddressSpace() { return AddressSpace::Private; }
-
-    /// Return true if the given MemRefType has an address space that is a 
-    /// gpu::AddressSpaceAttr attribute with value 'workgroup`.
-    static bool hasSharedMemoryAddressSpace(MemRefType type);
-
-    /// Return true if the given Attribute has matches is a gpu::AddressSpaceAttr
-    /// attribute with value 'workgroup`.
-    static bool isSharedMemoryAddressSpace(Attribute type);
   }];
 
   let dependentDialects = ["arith::ArithDialect"];

diff  --git a/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp b/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
index 0a197b9ab01004..9993c093badc16 100644
--- a/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
+++ b/mlir/lib/Conversion/GPUCommon/GPUToLLVMConversion.cpp
@@ -67,7 +67,7 @@ class ConvertOpToGpuRuntimeCallPattern : public ConvertOpToLLVMPattern<OpTy> {
 protected:
   Value getNumElements(ConversionPatternRewriter &rewriter, Location loc,
                        MemRefType type, MemRefDescriptor desc) const {
-    Type indexType = ConvertToLLVMPattern::getIndexTypeMatchingMemRef(type);
+    Type indexType = ConvertToLLVMPattern::getIndexType();
     return type.hasStaticShape()
                ? ConvertToLLVMPattern::createIndexAttrConstant(
                      rewriter, loc, indexType, type.getNumElements())
@@ -654,16 +654,10 @@ class ConvertSDDMMOpToGpuRuntimeCallPattern
 
 } // namespace
 
-static IntegerType getIndexTypeForMemRef(MemRefType t) {
-  int64_t numBits = gpu::GPUDialect::hasSharedMemoryAddressSpace(t) ? 32 : 64;
-  return IntegerType::get(t.getContext(), numBits);
-}
-
 void GpuToLLVMConversionPass::runOnOperation() {
   LowerToLLVMOptions options(&getContext());
   options.useOpaquePointers = useOpaquePointers;
   options.useBarePtrCallConv = hostBarePtrCallConv;
-  options.memrefIndexTypeConverter = getIndexTypeForMemRef;
 
   LLVMTypeConverter converter(&getContext(), options);
   RewritePatternSet patterns(&getContext());

diff  --git a/mlir/lib/Conversion/LLVMCommon/Pattern.cpp b/mlir/lib/Conversion/LLVMCommon/Pattern.cpp
index 72c6c93734fd10..1699172eb9dab3 100644
--- a/mlir/lib/Conversion/LLVMCommon/Pattern.cpp
+++ b/mlir/lib/Conversion/LLVMCommon/Pattern.cpp
@@ -19,20 +19,6 @@ using namespace mlir;
 // ConvertToLLVMPattern
 //===----------------------------------------------------------------------===//
 
-static Value convertToDesiredIndexType(OpBuilder &b, Location loc, Value src,
-                                       Type desiredIndexType) {
-  assert(src.getType().isIntOrIndex() && !src.getType().isIndex() &&
-         "expected int type");
-  assert(desiredIndexType.isIntOrIndex() && !desiredIndexType.isIndex() &&
-         "expected int type");
-  if (src.getType() == desiredIndexType)
-    return src;
-  if (src.getType().getIntOrFloatBitWidth() <
-      desiredIndexType.getIntOrFloatBitWidth())
-    return b.create<LLVM::SExtOp>(loc, desiredIndexType, src);
-  return b.create<LLVM::TruncOp>(loc, desiredIndexType, src);
-}
-
 ConvertToLLVMPattern::ConvertToLLVMPattern(StringRef rootOpName,
                                            MLIRContext *context,
                                            LLVMTypeConverter &typeConverter,
@@ -52,10 +38,6 @@ Type ConvertToLLVMPattern::getIndexType() const {
   return getTypeConverter()->getIndexType();
 }
 
-Type ConvertToLLVMPattern::getIndexTypeMatchingMemRef(MemRefType t) const {
-  return getTypeConverter()->getIndexTypeMatchingMemRef(t);
-}
-
 Type ConvertToLLVMPattern::getIntPtrType(unsigned addressSpace) const {
   return IntegerType::get(&getTypeConverter()->getContext(),
                           getTypeConverter()->getPointerBitwidth(addressSpace));
@@ -92,7 +74,7 @@ Value ConvertToLLVMPattern::getStridedElementPtr(
   Value base =
       memRefDescriptor.bufferPtr(rewriter, loc, *getTypeConverter(), type);
 
-  Type indexType = getIndexTypeMatchingMemRef(type);
+  Type indexType = getIndexType();
   Value index;
   for (int i = 0, e = indices.size(); i < e; ++i) {
     Value increment = indices[i];
@@ -101,11 +83,8 @@ Value ConvertToLLVMPattern::getStridedElementPtr(
           ShapedType::isDynamic(strides[i])
               ? memRefDescriptor.stride(rewriter, loc, i)
               : createIndexAttrConstant(rewriter, loc, indexType, strides[i]);
-      increment =
-          convertToDesiredIndexType(rewriter, loc, increment, indexType);
       increment = rewriter.create<LLVM::MulOp>(loc, increment, stride);
     }
-    increment = convertToDesiredIndexType(rewriter, loc, increment, indexType);
     index =
         index ? rewriter.create<LLVM::AddOp>(loc, index, increment) : increment;
   }
@@ -148,7 +127,7 @@ void ConvertToLLVMPattern::getMemRefDescriptorSizes(
 
   sizes.reserve(memRefType.getRank());
   unsigned dynamicIndex = 0;
-  Type indexType = getIndexTypeMatchingMemRef(memRefType);
+  Type indexType = getIndexType();
   for (int64_t size : memRefType.getShape()) {
     sizes.push_back(
         size == ShapedType::kDynamic
@@ -215,7 +194,7 @@ Value ConvertToLLVMPattern::getNumElements(
              static_cast<ssize_t>(dynamicSizes.size()) &&
          "dynamicSizes size doesn't match dynamic sizes count in memref shape");
 
-  Type indexType = getIndexTypeMatchingMemRef(memRefType);
+  Type indexType = getIndexType();
   Value numElements = memRefType.getRank() == 0
                           ? createIndexAttrConstant(rewriter, loc, indexType, 1)
                           : nullptr;
@@ -254,7 +233,7 @@ MemRefDescriptor ConvertToLLVMPattern::createMemRefDescriptor(
   memRefDescriptor.setAlignedPtr(rewriter, loc, alignedPtr);
 
   // Field 3: Offset in aligned pointer.
-  Type indexType = getIndexTypeMatchingMemRef(memRefType);
+  Type indexType = getIndexType();
   memRefDescriptor.setOffset(
       rewriter, loc, createIndexAttrConstant(rewriter, loc, indexType, 0));
 

diff  --git a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
index c63be57dd850ff..9e03e2ffbacf83 100644
--- a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
+++ b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp
@@ -174,11 +174,6 @@ Type LLVMTypeConverter::getIndexType() {
   return IntegerType::get(&getContext(), getIndexTypeBitwidth());
 }
 
-Type LLVMTypeConverter::getIndexTypeMatchingMemRef(MemRefType t) {
-  return options.memrefIndexTypeConverter ? options.memrefIndexTypeConverter(t)
-                                          : getIndexType();
-}
-
 LLVM::LLVMPointerType
 LLVMTypeConverter::getPointerType(Type elementType, unsigned int addressSpace) {
   if (useOpaquePointers())
@@ -344,7 +339,7 @@ LLVMTypeConverter::getMemRefDescriptorFields(MemRefType type,
   }
   auto ptrTy = getPointerType(elementType, *addressSpace);
 
-  Type indexTy = getIndexTypeMatchingMemRef(type);
+  auto indexTy = getIndexType();
 
   SmallVector<Type, 5> results = {ptrTy, ptrTy, indexTy};
   auto rank = type.getRank();
@@ -363,8 +358,7 @@ unsigned LLVMTypeConverter::getMemRefDescriptorSize(MemRefType type,
   // Compute the descriptor size given that of its components indicated above.
   unsigned space = *getMemRefAddressSpace(type);
   return 2 * llvm::divideCeil(getPointerBitwidth(space), 8) +
-         (1 + 2 * type.getRank()) *
-             layout.getTypeSize(getIndexTypeMatchingMemRef(type));
+         (1 + 2 * type.getRank()) * layout.getTypeSize(getIndexType());
 }
 
 /// Converts MemRefType to LLVMType. A MemRefType is converted to a struct that

diff  --git a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
index 1c2cd86c53706f..55372b9c9c1248 100644
--- a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
+++ b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp
@@ -160,7 +160,7 @@ struct ReallocOpLoweringBase : public AllocationOpLLVMLowering {
     auto computeNumElements =
         [&](MemRefType type, function_ref<Value()> getDynamicSize) -> Value {
       // Compute number of elements.
-      Type indexType = ConvertToLLVMPattern::getIndexTypeMatchingMemRef(type);
+      Type indexType = ConvertToLLVMPattern::getIndexType();
       Value numElements =
           type.isDynamicDim(0)
               ? getDynamicSize()
@@ -483,8 +483,7 @@ struct DimOpLowering : public ConvertOpToLLVMPattern<memref::DimOp> {
     // The size value that we have to extract can be obtained using GEPop with
     // `dimOp.index() + 1` index argument.
     Value idxPlusOne = rewriter.create<LLVM::AddOp>(
-        loc,
-        createIndexAttrConstant(rewriter, loc, adaptor.getIndex().getType(), 1),
+        loc, createIndexAttrConstant(rewriter, loc, getIndexType(), 1),
         adaptor.getIndex());
     Value sizePtr = rewriter.create<LLVM::GEPOp>(
         loc, indexPtrTy, getTypeConverter()->getIndexType(), offsetPtr,
@@ -511,7 +510,7 @@ struct DimOpLowering : public ConvertOpToLLVMPattern<memref::DimOp> {
 
     // Take advantage if index is constant.
     MemRefType memRefType = cast<MemRefType>(operandType);
-    Type indexType = getIndexTypeMatchingMemRef(memRefType);
+    Type indexType = getIndexType();
     if (std::optional<int64_t> index = getConstantDimIndex(dimOp)) {
       int64_t i = *index;
       if (i >= 0 && i < memRefType.getRank()) {
@@ -1361,7 +1360,7 @@ struct MemRefReshapeOpLowering
       assert(targetMemRefType.getLayout().isIdentity() &&
              "Identity layout map is a precondition of a valid reshape op");
 
-      Type indexType = getIndexTypeMatchingMemRef(targetMemRefType);
+      Type indexType = getIndexType();
       Value stride = nullptr;
       int64_t targetRank = targetMemRefType.getRank();
       for (auto i : llvm::reverse(llvm::seq<int64_t>(0, targetRank))) {
@@ -1456,8 +1455,7 @@ struct MemRefReshapeOpLowering
     Value targetStridesBase = UnrankedMemRefDescriptor::strideBasePtr(
         rewriter, loc, *getTypeConverter(), targetSizesBase, resultRank);
     Value shapeOperandPtr = shapeDesc.alignedPtr(rewriter, loc);
-    Value oneIndex =
-        createIndexAttrConstant(rewriter, loc, resultRank.getType(), 1);
+    Value oneIndex = createIndexAttrConstant(rewriter, loc, getIndexType(), 1);
     Value resultRankMinusOne =
         rewriter.create<LLVM::SubOp>(loc, resultRank, oneIndex);
 
@@ -1710,7 +1708,7 @@ struct ViewOpLowering : public ConvertOpToLLVMPattern<memref::ViewOp> {
 
     targetMemRef.setAlignedPtr(rewriter, loc, bitcastPtr);
 
-    auto indexType = targetMemRef.getIndexType();
+    Type indexType = getIndexType();
     // Field 3: The offset in the resulting type must be 0. This is
     // because of the type change: an offset on srcType* may not be
     // expressible as an offset on dstType*.
@@ -1867,7 +1865,7 @@ class ExtractStridedMetadataOpLowering
 
 } // namespace
 
-void mlir::populateFinalizeMemRefToLLVMConversionPatterns(
+static void populateModuleIndependentFinalizeMemRefToLLVMConversionPatterns(
     LLVMTypeConverter &converter, RewritePatternSet &patterns) {
   // clang-format off
   patterns.add<
@@ -1883,7 +1881,6 @@ void mlir::populateFinalizeMemRefToLLVMConversionPatterns(
       GetGlobalMemrefOpLowering,
       LoadOpLowering,
       MemRefCastOpLowering,
-      MemRefCopyOpLowering,
       MemorySpaceCastOpLowering,
       MemRefReinterpretCastOpLowering,
       MemRefReshapeOpLowering,
@@ -1896,6 +1893,15 @@ void mlir::populateFinalizeMemRefToLLVMConversionPatterns(
       TransposeOpLowering,
       ViewOpLowering>(converter);
   // clang-format on
+}
+
+void mlir::populateFinalizeMemRefToLLVMConversionPatterns(
+    LLVMTypeConverter &converter, RewritePatternSet &patterns) {
+  // clang-format off
+  patterns.add<
+      MemRefCopyOpLowering>(converter);
+  // clang-format on
+
   auto allocLowering = converter.getOptions().allocLowering;
   if (allocLowering == LowerToLLVMOptions::AllocLowering::AlignedAlloc)
     patterns.add<AlignedAllocOpLowering, AlignedReallocOpLowering,
@@ -1903,6 +1909,9 @@ void mlir::populateFinalizeMemRefToLLVMConversionPatterns(
   else if (allocLowering == LowerToLLVMOptions::AllocLowering::Malloc)
     patterns.add<AllocOpLowering, ReallocOpLowering, DeallocOpLowering>(
         converter);
+
+  populateModuleIndependentFinalizeMemRefToLLVMConversionPatterns(converter,
+                                                                  patterns);
 }
 
 namespace {
@@ -1931,6 +1940,12 @@ struct FinalizeMemRefToLLVMConversionPass
                                     &dataLayoutAnalysis);
     RewritePatternSet patterns(&getContext());
     populateFinalizeMemRefToLLVMConversionPatterns(typeConverter, patterns);
+    if (isa<ModuleOp>(getOperation())) {
+      populateFinalizeMemRefToLLVMConversionPatterns(typeConverter, patterns);
+    } else {
+      populateModuleIndependentFinalizeMemRefToLLVMConversionPatterns(
+          typeConverter, patterns);
+    }
     LLVMConversionTarget target(getContext());
     target.addLegalOp<func::FuncOp>();
     if (failed(applyPartialConversion(op, target, std::move(patterns))))

diff  --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
index cec2830e10b932..c9f378c181e36d 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -35,22 +35,6 @@ using namespace mlir::gpu;
 
 #include "mlir/Dialect/GPU/IR/GPUOpsDialect.cpp.inc"
 
-/// Return true if the given MemRefType has an address space that is a
-/// gpu::AddressSpaceAttr attribute with value 'workgroup`.
-bool gpu::GPUDialect::hasSharedMemoryAddressSpace(MemRefType type) {
-  return isSharedMemoryAddressSpace(type.getMemorySpace());
-}
-
-/// Return true if the given Attribute has matches is a gpu::AddressSpaceAttr
-/// attribute with value 'workgroup`.
-bool gpu::GPUDialect::isSharedMemoryAddressSpace(Attribute memorySpace) {
-  if (!memorySpace)
-    return false;
-  if (auto gpuAttr = llvm::dyn_cast<gpu::AddressSpaceAttr>(memorySpace))
-    return gpuAttr.getValue() == gpu::AddressSpace::Workgroup;
-  return false;
-}
-
 //===----------------------------------------------------------------------===//
 // GPU Device Mapping Attributes
 //===----------------------------------------------------------------------===//


        


More information about the Mlir-commits mailing list