[Mlir-commits] [mlir] 0b7c184 - Add assertion in PatternRewriter::create<> to defend the same way as OpBuilder::create<> against missing dialect registration (NFC)
Mehdi Amini
llvmlistbot at llvm.org
Tue Aug 25 23:57:40 PDT 2020
Author: Mehdi Amini
Date: 2020-08-26T06:57:23Z
New Revision: 0b7c184c2d8f8ecf7daf89e9e58a80c6426c2835
URL: https://github.com/llvm/llvm-project/commit/0b7c184c2d8f8ecf7daf89e9e58a80c6426c2835
DIFF: https://github.com/llvm/llvm-project/commit/0b7c184c2d8f8ecf7daf89e9e58a80c6426c2835.diff
LOG: Add assertion in PatternRewriter::create<> to defend the same way as OpBuilder::create<> against missing dialect registration (NFC)
The code would have failed a few line later, but that way the error
message is more clear/friendly to debug.
Added:
Modified:
mlir/include/mlir/IR/PatternMatch.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h
index 46dd96408ba7..ea8f410460c5 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -252,6 +252,9 @@ class PatternRewriter : public OpBuilder, public OpBuilder::Listener {
template <typename OpTy, typename... Args>
OpTy create(Location location, Args... args) {
OperationState state(location, OpTy::getOperationName());
+ if (!state.name.getAbstractOperation())
+ llvm::report_fatal_error("Building op `" + state.name.getStringRef() +
+ "` but it isn't registered in this MLIRContext");
OpTy::build(*this, state, args...);
auto *op = createOperation(state);
auto result = dyn_cast<OpTy>(op);
More information about the Mlir-commits
mailing list