This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Remove llvm::LLVMContext and llvm::Module from mlir::LLVMDialectImpl
ClosedPublic

Authored by ftynse on Aug 6 2020, 9:32 AM.

Details

Summary

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.

Diff Detail

Event Timeline

ftynse created this revision.Aug 6 2020, 9:32 AM
Herald added a project: Restricted Project. · View Herald Transcript
ftynse requested review of this revision.Aug 6 2020, 9:32 AM
rriddle accepted this revision.Aug 6 2020, 11:38 AM
This revision is now accepted and ready to land.Aug 6 2020, 11:38 AM
This revision was landed with ongoing or failed builds.Aug 7 2020, 5:30 AM
This revision was automatically updated to reflect the committed changes.