From 0c03ae90f30fe2433d34b6766b5a1daef8e16e4b Mon Sep 17 00:00:00 2001 From: Roman Levenstein Date: Tue, 5 Mar 2024 11:25:38 -0800 Subject: [PATCH] Support -debug-glow-only even in release builds Reviewed By: junhanh Differential Revision: D54523800 fbshipit-source-id: d267fd4466afea2bd24f1b1cf97f4c22099cced4 --- include/glow/Support/Debug.h | 6 +++--- lib/Optimizer/IROptimizer/IROptimizer.cpp | 2 -- lib/Support/Debug.cpp | 4 ++-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/glow/Support/Debug.h b/include/glow/Support/Debug.h index 28af230f59..0ae74c71dc 100644 --- a/include/glow/Support/Debug.h +++ b/include/glow/Support/Debug.h @@ -18,15 +18,15 @@ namespace glow { -#ifndef NDEBUG +#if !defined(NDEBUG) && !defined(DISABLE_DEBUG_GLOW) /// \returns true if \p type matches the activated debug type. -bool isCurrentDebugType(const char *type); +bool isGlowCurrentDebugType(const char *type); /// Macro to perform debug actions when TYPE is activated. #define DEBUG_GLOW_WITH_TYPE(TYPE, X) \ do { \ - if (glow::DebugFlag || glow::isCurrentDebugType(TYPE)) { \ + if (glow::DebugFlag || glow::isGlowCurrentDebugType(TYPE)) { \ X; \ } \ } while (false) diff --git a/lib/Optimizer/IROptimizer/IROptimizer.cpp b/lib/Optimizer/IROptimizer/IROptimizer.cpp index 5147e92bb4..99b473bcbb 100644 --- a/lib/Optimizer/IROptimizer/IROptimizer.cpp +++ b/lib/Optimizer/IROptimizer/IROptimizer.cpp @@ -160,12 +160,10 @@ class LiveIntervalsInstructionNumbering { }; } // namespace -#ifndef NDEBUG llvm::raw_ostream &operator<<(llvm::raw_ostream &os, const Interval &I) { os << I.str(); return os; } -#endif /// Set of intervals for a single memory buffer. If there is only one write into /// a memory buffer, it would contain a single interval. If there are multiple diff --git a/lib/Support/Debug.cpp b/lib/Support/Debug.cpp index 318f621fcb..d44732a3c5 100755 --- a/lib/Support/Debug.cpp +++ b/lib/Support/Debug.cpp @@ -41,8 +41,8 @@ namespace glow { /// Exported boolean set by -debug-glow option. bool DebugFlag = false; -#ifndef NDEBUG -bool isCurrentDebugType(const char *type) { +#if !defined(NDEBUG) && !defined(DISABLE_DEBUG_GLOW) +bool isGlowCurrentDebugType(const char *type) { return std::find(DebugGlowOnly.begin(), DebugGlowOnly.end(), type) != DebugGlowOnly.end(); }