aboutsummaryrefslogtreecommitdiff
path: root/llvm/include
diff options
context:
space:
mode:
authorNicolas Vasilache <nico.vasilache@amd.com>2025-07-04 10:52:53 +0200
committerNicolas Vasilache <nico.vasilache@amd.com>2025-07-04 11:59:57 +0200
commit3a632bd7deadf2150d2fb64e732cf9c52ce6c83e (patch)
tree318aaccff0978deedab523d46c462b161e78c836 /llvm/include
parent2b8f82b2bad6b2ada988fb2b874d676aa748a35b (diff)
downloadllvm-users/nico/python-2.zip
llvm-users/nico/python-2.tar.gz
llvm-users/nico/python-2.tar.bz2
[mlir][python] Add debug helpersusers/nico/python-2
This PR lets users provide --debug-only flags with python decorators. This greatly simplifies the debugging experience in python. Co-authored-by: Tres <tpopp@users.noreply.github.com>
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/Support/Debug.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/llvm/include/llvm/Support/Debug.h b/llvm/include/llvm/Support/Debug.h
index 924d7b2..6720ef5c 100644
--- a/llvm/include/llvm/Support/Debug.h
+++ b/llvm/include/llvm/Support/Debug.h
@@ -54,6 +54,28 @@ void setCurrentDebugType(const char *Type);
///
void setCurrentDebugTypes(const char **Types, unsigned Count);
+/// appendDebugType - Set the current debug type, as if the
+/// -debug-only=CurX,CurY,NewZ option were specified when called with NewZ.
+/// The previous state is tracked, so popAppendedDebugTypes can be called to
+/// restore the previous state. Note that DebugFlag also needs to be set to true
+/// for debug output to be produced.
+///
+void appendDebugType(const char *Type);
+
+/// appendDebugTypes - Set the current debug type, as if the
+/// -debug-only=CurX,CurY,NewX,NewY option were specified when called with
+/// [NewX, NewY]. The previous state is tracked, so popAppendedDebugTypes can be
+/// called to restore the previous state. Note that DebugFlag also needs to be
+/// set to true debug output to be produced.
+///
+void appendDebugTypes(const char **Types, unsigned Count);
+
+/// popAppendedDebugTypes - Restores CurDebugType to the state before the last
+/// call to appendDebugType(s). Asserts and returns if the previous state was
+/// empty or was reset by setCurrentDebugType(s).
+///
+void popAppendedDebugTypes();
+
/// DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug
/// information. If the '-debug' option is specified on the commandline, and if
/// this is a debug build, then the code specified as the option to the macro
@@ -77,6 +99,19 @@ void setCurrentDebugTypes(const char **Types, unsigned Count);
#define DEBUG_WITH_TYPE(TYPE, ...) \
do { \
} while (false)
+#define appendDebugType(X) \
+ do { \
+ (void)(X); \
+ } while (false)
+#define appendDebugTypes(X, N) \
+ do { \
+ (void)(X); \
+ (void)(N); \
+ } while (false)
+#define popAppendedDebugTypes() \
+ do { \
+ ; \
+ } while (false)
#endif
/// This boolean is set to true if the '-debug' command line option