diff --git a/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h b/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h --- a/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h +++ b/mlir/include/mlir/Conversion/LLVMCommon/LoweringOptions.h @@ -51,11 +51,6 @@ bool useGenericFunctions = false; - /// The data layout of the module to produce. This must be consistent with the - /// data layout used in the upper levels of the lowering pipeline. - // TODO: this should be replaced by MLIR data layout when one exists. - llvm::DataLayout dataLayout = llvm::DataLayout(""); - /// Set the index bitwidth to the given value. void overrideIndexBitwidth(unsigned bitwidth) { assert(bitwidth != kDeriveIndexBitwidthFromDataLayout && diff --git a/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h b/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h --- a/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h +++ b/mlir/include/mlir/Conversion/LLVMCommon/TypeConverter.h @@ -113,9 +113,6 @@ std::pair convertFunctionTypeCWrapper(FunctionType type) const; - /// Returns the data layout to use during and after conversion. - const llvm::DataLayout &getDataLayout() const { return options.dataLayout; } - /// Returns the data layout analysis to query during conversion. const DataLayoutAnalysis *getDataLayoutAnalysis() const { return dataLayoutAnalysis; diff --git a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp --- a/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp +++ b/mlir/lib/Conversion/FuncToLLVM/FuncToLLVM.cpp @@ -750,6 +750,10 @@ void runOnOperation() override { ModuleOp m = getOperation(); StringRef dataLayout; + // TODO: this datalayout string is actually unused by any of the code paths + // currently reachable from this pass. It is thus only verified here and + // propagated to the LLVM module. Ultimately, we should remove this and + // unify with DataLayoutAnalysis. auto dataLayoutAttr = llvm::dyn_cast_or_null( m->getAttr(LLVM::LLVMDialect::getDataLayoutAttrName())); if (dataLayoutAttr) @@ -770,7 +774,6 @@ options.useBarePtrCallConv = useBarePtrCallConv; if (indexBitwidth != kDeriveIndexBitwidthFromDataLayout) options.overrideIndexBitwidth(indexBitwidth); - options.dataLayout = llvm::DataLayout(dataLayout); options.useOpaquePointers = useOpaquePointers; LLVMTypeConverter typeConverter(&getContext(), options, diff --git a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp --- a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp +++ b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp @@ -213,7 +213,10 @@ } unsigned LLVMTypeConverter::getPointerBitwidth(unsigned addressSpace) const { - return options.dataLayout.getPointerSizeInBits(addressSpace); + // TODO: when the MLIR DataLayoutAnalysis is properly hooked, this should be + // updated to not use the default llvm::DataLayout(""). Until then, no code + // path exists that would use a non-default llvm::DataLayout. + return llvm::DataLayout("").getPointerSizeInBits(addressSpace); } Type LLVMTypeConverter::convertIndexType(IndexType type) const { diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -22,6 +22,7 @@ #include "mlir/IR/TypeUtilities.h" #include "mlir/Target/LLVMIR/TypeToLLVM.h" #include "mlir/Transforms/DialectConversion.h" +#include "llvm/IR/DataLayout.h" #include "llvm/Support/Casting.h" #include @@ -78,7 +79,7 @@ // stop depending on translation. llvm::LLVMContext llvmContext; align = LLVM::TypeToLLVMIRTranslator(llvmContext) - .getPreferredAlignment(elementTy, typeConverter.getDataLayout()); + .getPreferredAlignment(elementTy, llvm::DataLayout("")); return success(); } diff --git a/mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp b/mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp --- a/mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp +++ b/mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp @@ -44,11 +44,9 @@ if (getIndexBitwidth() != kDeriveIndexBitwidthFromDataLayout) options.overrideIndexBitwidth(getIndexBitwidth()); - // TODO: the following two options don't really make sense for + // TODO: the following option doesn't really make sense for // memref_to_llvm_type_converter specifically but we should have a single // to_llvm_type_converter. - if (getDataLayout().has_value()) - options.dataLayout = llvm::DataLayout(getDataLayout().value()); options.useBarePtrCallConv = getUseBarePtrCallConv(); return std::make_unique(getContext(), options);