From 5d783ab3bd88482b6d266748d1322cd7500d9a77 Mon Sep 17 00:00:00 2001 From: Jacques Pienaar Date: Mon, 15 Apr 2019 16:32:00 -0700 Subject: [PATCH] Abort via report_fatal_error if dialect has been registered. Fixes test in opt mode. Closes: tensorflow/mlir#17. -- PiperOrigin-RevId: 243711043 --- mlir/lib/IR/MLIRContext.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp index 2abf784..7df61ea 100644 --- a/mlir/lib/IR/MLIRContext.cpp +++ b/mlir/lib/IR/MLIRContext.cpp @@ -703,11 +703,14 @@ void Dialect::registerDialect(MLIRContext *context) { // Lock access to the context registry. llvm::sys::SmartScopedWriter registryLock(impl.contextMutex); - assert(llvm::none_of(impl.dialects, - [this](std::unique_ptr &dialect) { - return dialect->getNamespace() == getNamespace(); - }) && - "a dialect with the given namespace has already been registered"); + // Abort if dialect with namespace has already been registered. + if (llvm::any_of(impl.dialects, [this](std::unique_ptr &dialect) { + return dialect->getNamespace() == getNamespace(); + })) { + llvm::report_fatal_error("a dialect with namespace '" + + Twine(getNamespace()) + + "' has already been registered"); + } impl.dialects.push_back(std::unique_ptr(this)); } -- 2.7.4