diff --git a/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h b/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h --- a/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h +++ b/mlir/include/mlir/Dialect/Transform/IR/TransformDialect.h @@ -18,20 +18,22 @@ namespace mlir { namespace transform { -#ifndef NDEBUG namespace detail { /// Asserts that the operations provided as template arguments implement the /// TransformOpInterface and MemoryEffectsOpInterface. This must be a dynamic /// assertion since interface implementations may be registered at runtime. -void checkImplementsTransformOpInterface(StringRef name, MLIRContext *context); +/// No-op if assertions are not enabled (but can be conditioned at the call-site +/// to avoid an opaque function call). +void assertImplementsTransformOpInterface(StringRef name, MLIRContext *context); /// Asserts that the type provided as template argument implements the /// TransformHandleTypeInterface. This must be a dynamic assertion since /// interface implementations may be registered at runtime. -void checkImplementsTransformHandleTypeInterface(TypeID typeID, - MLIRContext *context); +/// No-op if assertions are not enabled (but can be conditioned at the call-site +/// to avoid an opaque function call). +void assertImplementsTransformHandleTypeInterface(TypeID typeID, + MLIRContext *context); } // namespace detail -#endif // NDEBUG } // namespace transform } // namespace mlir @@ -195,7 +197,7 @@ if (!opName) { addOperations(); #ifndef NDEBUG - detail::checkImplementsTransformOpInterface(name, getContext()); + detail::assertImplementsTransformOpInterface(name, getContext()); #endif // NDEBUG return; } @@ -227,8 +229,8 @@ addTypes(); #ifndef NDEBUG - detail::checkImplementsTransformHandleTypeInterface(TypeID::get(), - getContext()); + detail::assertImplementsTransformHandleTypeInterface(TypeID::get(), + getContext()); #endif // NDEBUG } diff --git a/mlir/lib/Dialect/Transform/IR/TransformDialect.cpp b/mlir/lib/Dialect/Transform/IR/TransformDialect.cpp --- a/mlir/lib/Dialect/Transform/IR/TransformDialect.cpp +++ b/mlir/lib/Dialect/Transform/IR/TransformDialect.cpp @@ -18,14 +18,14 @@ #include "mlir/Dialect/Transform/IR/TransformDialect.cpp.inc" -#ifndef NDEBUG -void transform::detail::checkImplementsTransformOpInterface( +void transform::detail::assertImplementsTransformOpInterface( StringRef name, MLIRContext *context) { // Since the operation is being inserted into the Transform dialect and the // dialect does not implement the interface fallback, only check for the op // itself having the interface implementation. RegisteredOperationName opName = *RegisteredOperationName::lookup(name, context); + (void)opName; assert((opName.hasInterface() || opName.hasTrait()) && "non-terminator ops injected into the transform dialect must " @@ -35,9 +35,10 @@ "MemoryEffectsOpInterface"); } -void transform::detail::checkImplementsTransformHandleTypeInterface( +void transform::detail::assertImplementsTransformHandleTypeInterface( TypeID typeID, MLIRContext *context) { const auto &abstractType = AbstractType::lookup(typeID, context); + (void)abstractType; assert((abstractType.hasInterface( TransformHandleTypeInterface::getInterfaceID()) || abstractType.hasInterface( @@ -47,7 +48,6 @@ "expected Transform dialect type to implement one of the three " "interfaces"); } -#endif // NDEBUG namespace { struct PDLOperationTypeTransformHandleTypeInterfaceImpl