[Mlir-commits] [mlir] [mlir] Guard expensive string-based asserts behind EXPENSIVE_CHECKS (PR #93111)

Jeff Niu llvmlistbot at llvm.org
Wed May 22 17:42:57 PDT 2024


================
@@ -303,7 +300,7 @@ class AttributeInterface
 protected:
   /// Returns the impl interface instance for the given type.
   static typename InterfaceBase::Concept *getInterfaceFor(Attribute attr) {
-#ifndef NDEBUG
+#ifdef EXPENSIVE_CHECKS
----------------
Mogball wrote:

I'm open to your opinion on this! On one hand, I agree. I opened this PR simply for discussion (and to evaluate the impact on mojo). Practically no one builds with EXPENSIVE_CHECKS by default. However, compared to asserts in, say, `isa` or `cast`, this one is realllyyyy expensive. What if we had a separate flag that was also on by default but toggleable? The problem is that because this is in a header file, it's subject to the NDEBUG flag of whoever includes the file, not the LLVM binaries themselves. It would be nice to specifically toggle these ones and other "heavy" asserts in MLIR off.

https://github.com/llvm/llvm-project/pull/93111


More information about the Mlir-commits mailing list