[mlir] Remove llvm::LLVMContext and llvm::Module from mlir::LLVMDialectImpl
authorAlex Zinenko <zinenko@google.com>
Thu, 6 Aug 2020 16:16:14 +0000 (18:16 +0200)
committerAlex Zinenko <zinenko@google.com>
Fri, 7 Aug 2020 12:30:31 +0000 (14:30 +0200)
commit87a89e0f7753711ef5f2741a1494e7a44da99d21
tree9c5e2eddd0c7effaa706e993fa9028b81f307a97
parent16b02253778caf1723b63c8ee482bb68ccae0a90
[mlir] Remove llvm::LLVMContext and llvm::Module from mlir::LLVMDialectImpl

Original modeling of LLVM IR types in the MLIR LLVM dialect had been wrapping
LLVM IR types and therefore required the LLVMContext in which they were created
to outlive them, which was solved by placing the LLVMContext inside the dialect
and thus having the lifetime of MLIRContext. This has led to numerous issues
caused by the lack of thread-safety of LLVMContext and the need to re-create
LLVM IR modules, obtained by translating from MLIR, in different LLVM contexts
to enable parallel compilation. Similarly, llvm::Module had been introduced to
keep track of identified structure types that could not be modeled properly.

A recent series of commits changed the modeling of LLVM IR types in the MLIR
LLVM dialect so that it no longer wraps LLVM IR types and has no dependence on
LLVMContext and changed the ownership model of the translated LLVM IR modules.
Remove LLVMContext and LLVM modules from the implementation of MLIR LLVM
dialect and clean up the remaining uses.

The only part of LLVM IR that remains necessary for the LLVM dialect is the
data layout. It should be moved from the dialect level to the module level and
replaced with an MLIR-based representation to remove the dependency of the
LLVMDialect on LLVM IR library.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D85445
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
mlir/include/mlir/Dialect/LLVMIR/LLVMOpBase.td
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp