[Mlir-commits] [mlir] 5a6ff2b - Adjust assertion when casting to an unregistered operation

Mehdi Amini llvmlistbot at llvm.org
Tue Aug 25 23:57:38 PDT 2020


Author: Mehdi Amini
Date: 2020-08-26T06:57:22Z
New Revision: 5a6ff2bb3e6ce42817d6618d977428c394d1709d

URL: https://github.com/llvm/llvm-project/commit/5a6ff2bb3e6ce42817d6618d977428c394d1709d
DIFF: https://github.com/llvm/llvm-project/commit/5a6ff2bb3e6ce42817d6618d977428c394d1709d.diff

LOG: Adjust assertion when casting to an unregistered operation

This assertion does not achieve what it meant to do originally, as it
would fire only when applied to an unregistered operation, which is a
fairly rare circumstance (it needs a dialect or context allowing
unregistered operation in the input in the first place).
Instead we relax it to only fire when it should have matched but didn't
because of the misconfiguration.

Differential Revision: https://reviews.llvm.org/D86588

Added: 
    

Modified: 
    mlir/include/mlir/IR/OpDefinition.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 80fb2581cfae..db77935e1325 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -1257,9 +1257,12 @@ class Op : public OpState,
   static bool classof(Operation *op) {
     if (auto *abstractOp = op->getAbstractOperation())
       return TypeID::get<ConcreteType>() == abstractOp->typeID;
-    assert(op->getContext()->isOperationRegistered(
-               ConcreteType::getOperationName()) &&
-           "Casting attempt to an unregistered operation");
+#ifndef NDEBUG
+    if (op->getName().getStringRef() == ConcreteType::getOperationName())
+      llvm::report_fatal_error(
+          "classof on '" + ConcreteType::getOperationName() +
+          "' failed due to the operation not being registered");
+#endif
     return false;
   }
 


        


More information about the Mlir-commits mailing list