[Mlir-commits] [llvm] [mlir] [MLIR] Add debug log to the pass manager (NFC) (PR #156205)
Mehdi Amini
llvmlistbot at llvm.org
Sat Sep 6 02:52:41 PDT 2025
================
@@ -19,31 +19,41 @@
namespace llvm {
#ifndef NDEBUG
-// 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.
-//
-// E.g.,
-// LDBG() << "Bitset contains: " << Bitset;
-// is somehow equivalent to
-// LLVM_DEBUG(dbgs() << "[" << DEBUG_TYPE << "] " << __FILE__ << ":" <<
-// __LINE__ << " "
-// << "Bitset contains: " << Bitset << "\n");
-//
+/// 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.
+///
+/// E.g.,
+/// LDBG() << "Bitset contains: " << Bitset;
+/// is somehow equivalent to
+/// LLVM_DEBUG(dbgs() << "[" << DEBUG_TYPE << "] " << __FILE__ << ":" <<
+/// __LINE__ << " "
+/// << "Bitset contains: " << Bitset << "\n");
+///
// An optional `level` argument can be provided to control the verbosity of the
-// output. The default level is 1, and is in increasing level of verbosity.
-//
-// The `level` argument can be a literal integer, or a macro that evaluates to
-// an integer.
-//
-// An optional `type` argument can be provided to control the debug type. The
-// default type is DEBUG_TYPE. The `type` argument can be a literal string, or a
-// macro that evaluates to a string.
+/// output. The default level is 1, and is in increasing level of verbosity.
+///
+/// The `level` argument can be a literal integer, or a macro that evaluates to
+/// an integer.
+///
+/// An optional `type` argument can be provided to control the debug type. The
+/// default type is DEBUG_TYPE. The `type` argument can be a literal string, or
+/// a macro that evaluates to a string.
#define LDBG(...) _GET_LDBG_MACRO(__VA_ARGS__)(__VA_ARGS__)
+/// LDBG_OS() 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.
+/// Note: this macro isn't guarded by a debug flag so it will always print in
+/// assert builds.
+#define LDBG_OS(...) _GET_LDBG_OS_MACRO(__VA_ARGS__)(__VA_ARGS__)
----------------
joker-eph wrote:
> LDBG_OS sets ShouldPrefixNextString and ShouldEmitNewLineOnDestruction. LLDB() does not.
Actually no they should match exactly on this.
The may differentiation is likely in 1:
1. LDBG() appears as returning a stream, but it's a macro, so it does not :) LDBG_OS() was actually returning a macro. The new form takes a lambda instead.
That is why 2 and 3 are behaving differently between the two.
https://github.com/llvm/llvm-project/pull/156205
More information about the Mlir-commits
mailing list