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 @@ -25,10 +25,6 @@ let name = "llvm"; let cppNamespace = "::mlir::LLVM"; - /// FIXME: at the moment this is a dependency of the translation to LLVM IR, - /// not really one of this dialect per-se. - let dependentDialects = ["omp::OpenMPDialect"]; - let hasRegionArgAttrVerify = 1; let hasOperationAttrVerify = 1; let extraClassDeclaration = [{ diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h --- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h +++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h @@ -123,7 +123,9 @@ /// Builder for LLVM IR generation of OpenMP constructs. std::unique_ptr ompBuilder; - /// Precomputed pointer to OpenMP dialect. + /// Precomputed pointer to OpenMP dialect. Note this can be nullptr if the + /// OpenMP dialect hasn't been loaded (it is always loaded if there are OpenMP + /// operations in the module though). const Dialect *ompDialect; /// Mappings between llvm.mlir.global definitions and corresponding globals. diff --git a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt --- a/mlir/lib/Dialect/LLVMIR/CMakeLists.txt +++ b/mlir/lib/Dialect/LLVMIR/CMakeLists.txt @@ -18,12 +18,10 @@ BitReader BitWriter Core - FrontendOpenMP LINK_LIBS PUBLIC MLIRCallInterfaces MLIRControlFlowInterfaces - MLIROpenMP MLIRIR MLIRSideEffectInterfaces MLIRSupport diff --git a/mlir/lib/Target/CMakeLists.txt b/mlir/lib/Target/CMakeLists.txt --- a/mlir/lib/Target/CMakeLists.txt +++ b/mlir/lib/Target/CMakeLists.txt @@ -51,6 +51,7 @@ IRReader LINK_LIBS PUBLIC + MLIROpenMP MLIRTargetLLVMIRModuleTranslation ) diff --git a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp --- a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp @@ -41,6 +41,8 @@ llvmModule->print(output, nullptr); return success(); }, - [](DialectRegistry ®istry) { registry.insert(); }); + [](DialectRegistry ®istry) { + registry.insert(); + }); } } // namespace mlir diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -302,7 +302,7 @@ : mlirModule(module), llvmModule(std::move(llvmModule)), debugTranslation( std::make_unique(module, *this->llvmModule)), - ompDialect(module->getContext()->getOrLoadDialect()), + ompDialect(module->getContext()->getLoadedDialect("omp")), typeTranslator(this->llvmModule->getContext()) { assert(satisfiesLLVMModule(mlirModule) && "mlirModule should honor LLVM's module semantics."); @@ -639,9 +639,8 @@ return success(); } - if (opInst.getDialect() == ompDialect) { + if (ompDialect && opInst.getDialect() == ompDialect) return convertOmpOperation(opInst, builder); - } return opInst.emitError("unsupported or non-LLVM operation: ") << opInst.getName();