[Mlir-commits] [llvm] [mlir] Introduce a "log level" support for DEBUG_TYPE (PR #150855)

Jacques Pienaar llvmlistbot at llvm.org
Mon Jul 28 04:16:23 PDT 2025


================
@@ -19,29 +19,65 @@
 namespace llvm {
 #ifndef NDEBUG
 
-// Output with given inputs and trailing newline. E.g.,
+// LDBG() is a macro that can be used as a raw_ostream for debugging.
+// It will stream the output to the dbgs() stream, with a prefix of the
+// debug type and the file and line number. A trailing newline is added to the
+// output automatically. If the streamed content contains a newline, the prefix
+// is added to each beginning of a new line. Nothing is printed if the debug
+// output is not enabled or the debug type does not match.
+//
+// An optional `level` argument can be provided to control the verbosity of the
+// output. The default level is 0, which is the most verbose. The level can be
+// set to 1, 2, 3, etc. to control the verbosity of the output.
+//
+// The `level` argument can be a literal integer, or a macro that evaluates to
+// an integer.
+//
+// E.g.,
 //   LDBG() << "Bitset contains: " << Bitset;
 // is equivalent to
-//   LLVM_DEBUG(dbgs() << DEBUG_TYPE << " [" << __FILE__ << ":" << __LINE__
-//              << "] " << "Bitset contains: " << Bitset << "\n");
-#define LDBG() DEBUGLOG_WITH_STREAM_AND_TYPE(llvm::dbgs(), DEBUG_TYPE)
+//   LLVM_DEBUG(dbgs() << "[" << DEBUG_TYPE << "] " << __FILE__ << ":" <<
+//   __LINE__ << " "
+//              << "Bitset contains: " << Bitset << "\n");
+#define LDBG(...) _GET_LDBG_MACRO(__VA_ARGS__)(__VA_ARGS__)
----------------
jpienaar wrote:

Good way to avoid relying on the C++20 va_opt :)

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


More information about the Mlir-commits mailing list