diff --git a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h --- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h +++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h @@ -81,8 +81,6 @@ /// Returns the MLIR context. MLIRContext &getContext(); - /// Returns the LLVM context. - llvm::LLVMContext &getLLVMContext(); /// Returns the LLVM dialect. LLVM::LLVMDialect *getDialect() { return llvmDialect; } @@ -396,9 +394,6 @@ /// Returns the LLVM dialect. LLVM::LLVMDialect &getDialect() const; - /// Returns the LLVM IR context. - llvm::LLVMContext &getContext() const; - /// Gets the MLIR type wrapping the LLVM integer type whose bit width is /// defined by the used type converter. LLVM::LLVMType getIndexType() const; diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td @@ -22,9 +22,6 @@ let hasRegionArgAttrVerify = 1; let extraClassDeclaration = [{ ~LLVMDialect(); - llvm::LLVMContext &getLLVMContext(); - llvm::Module &getLLVMModule(); - llvm::sys::SmartMutex &getLLVMContextMutex(); const llvm::DataLayout &getDataLayout(); private: diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -193,11 +193,6 @@ return *getDialect()->getContext(); } -/// Get the LLVM context. -llvm::LLVMContext &LLVMTypeConverter::getLLVMContext() { - return llvmDialect->getLLVMContext(); -} - LLVM::LLVMType LLVMTypeConverter::getIndexType() { return LLVM::LLVMType::getIntNTy(&getContext(), getIndexTypeBitwidth()); } @@ -844,10 +839,6 @@ return *typeConverter.getDialect(); } -llvm::LLVMContext &ConvertToLLVMPattern::getContext() const { - return typeConverter.getLLVMContext(); -} - LLVM::LLVMType ConvertToLLVMPattern::getIndexType() const { return typeConverter.getIndexType(); } 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 @@ -129,7 +129,8 @@ // TODO: this should use the MLIR data layout when it becomes available and // stop depending on translation. LLVM::LLVMDialect *dialect = typeConverter.getDialect(); - align = LLVM::TypeToLLVMIRTranslator(dialect->getLLVMContext()) + llvm::LLVMContext llvmContext; + align = LLVM::TypeToLLVMIRTranslator(llvmContext) .getPreferredAlignment(elementTy.cast(), dialect->getDataLayout()); return success(); diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -1672,14 +1672,12 @@ namespace LLVM { namespace detail { struct LLVMDialectImpl { - LLVMDialectImpl() : module("LLVMDialectModule", llvmContext) {} + LLVMDialectImpl() : layout("") {} - llvm::LLVMContext llvmContext; - llvm::Module module; - - /// A smart mutex to lock access to the llvm context. Unlike MLIR, LLVM is not - /// multi-threaded and requires locked access to prevent race conditions. - llvm::sys::SmartMutex mutex; + /// Default data layout to use. + // TODO: this should be moved to some Op equivalent to LLVM module and + // eventually replaced with a proper MLIR data layout. + llvm::DataLayout layout; }; } // end namespace detail } // end namespace LLVM @@ -1723,14 +1721,7 @@ #define GET_OP_CLASSES #include "mlir/Dialect/LLVMIR/LLVMOps.cpp.inc" -llvm::LLVMContext &LLVMDialect::getLLVMContext() { return impl->llvmContext; } -llvm::Module &LLVMDialect::getLLVMModule() { return impl->module; } -llvm::sys::SmartMutex &LLVMDialect::getLLVMContextMutex() { - return impl->mutex; -} -const llvm::DataLayout &LLVMDialect::getDataLayout() { - return impl->module.getDataLayout(); -} +const llvm::DataLayout &LLVMDialect::getDataLayout() { return impl->layout; } /// Parse a type registered to this dialect. Type LLVMDialect::parseType(DialectAsmParser &parser) const {