[mlir] Change ABI breaking use of NDEBUG to LLVM_ENABLE_ABI_BREAKING_CHECKS in DebugA...
authorMarkus Böck <markus.boeck02@gmail.com>
Wed, 3 Nov 2021 18:02:50 +0000 (19:02 +0100)
committerMarkus Böck <markus.boeck02@gmail.com>
Wed, 3 Nov 2021 18:03:04 +0000 (19:03 +0100)
A quick grep for NDEBUG in MLIR revealed a use in DebugActions.h that breaks ABI. This patch changes the use of NDEBUG to LLVM_ENABLE_ABI_BREAKING_CHECKS which has the advantage of being independent of whether clients build their own app in debug or release as it is purely dependant on how MLIR itself was built.

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

mlir/include/mlir/Support/DebugAction.h

index 352370cf48cef58d4f9091afa02b9bf16d4816f9..74f0f4c47b22e4c028f68b0e7ddb0dc775499455 100644 (file)
@@ -90,7 +90,7 @@ public:
   /// Register the given action handler with the manager.
   void registerActionHandler(std::unique_ptr<HandlerBase> handler) {
     // The manager is always disabled if built without debug.
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
     actionHandlers.emplace_back(std::move(handler));
 #endif
   }
@@ -109,7 +109,7 @@ public:
   template <typename ActionType, typename... Args>
   bool shouldExecute(Args &&... args) {
     // The manager is always disabled if built without debug.
-#ifdef NDEBUG
+#if !LLVM_ENABLE_ABI_BREAKING_CHECKS
     return true;
 #else
     // Invoke the `shouldExecute` method on the provided handler.
@@ -127,7 +127,7 @@ public:
 
 private:
 // The manager is always disabled if built without debug.
-#ifndef NDEBUG
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
   //===--------------------------------------------------------------------===//
   // Query to Handler Dispatch
   //===--------------------------------------------------------------------===//