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 @@ -120,9 +120,6 @@ std::pair convertFunctionTypeCWrapper(FunctionType type); - /// Returns the data layout to use during and after conversion. - const llvm::DataLayout &getDataLayout() { 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 @@ -762,7 +762,6 @@ options.useBarePtrCallConv = useBarePtrCallConv; if (indexBitwidth != kDeriveIndexBitwidthFromDataLayout) options.overrideIndexBitwidth(indexBitwidth); - options.dataLayout = llvm::DataLayout(this->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 @@ -11,6 +11,7 @@ #include "mlir/Conversion/LLVMCommon/MemRefBuilder.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/LLVMIR/LLVMTypes.h" +#include "llvm/IR/DataLayout.h" #include using namespace mlir; @@ -182,7 +183,7 @@ } unsigned LLVMTypeConverter::getPointerBitwidth(unsigned addressSpace) { - return options.dataLayout.getPointerSizeInBits(addressSpace); + return llvm::DataLayout("").getPointerSizeInBits(addressSpace); } Type LLVMTypeConverter::convertIndexType(IndexType type) { 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(); }