[OpenMP] libomptarget: move debugging dumps under control of env var LIBOMPTARGET_DEBUG
Disable default debugging dumps for libomptarget and plugins and move dumps
under control of environment variable LIBOMPTARGET_DEBUG=<integer>. Dumps
are enabled when LIBOMPTARGET_DEBUG is set to a positive integer value.
Debugging dumps are available only in debug build; release build does not
support it.
Differential Revision: https://reviews.llvm.org/D33227
llvm-svn: 310841
diff --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp
index 8edc3f7..95e0e1e 100644
--- a/openmp/libomptarget/src/omptarget.cpp
+++ b/openmp/libomptarget/src/omptarget.cpp
@@ -27,7 +27,19 @@
// Header file global to this project
#include "omptarget.h"
-#define DP(...) DEBUGP("Libomptarget", __VA_ARGS__)
+#ifdef OMPTARGET_DEBUG
+static int DebugLevel = 0;
+
+#define DP(...) \
+ do { \
+ if (DebugLevel > 0) { \
+ DEBUGP("Libomptarget", __VA_ARGS__); \
+ } \
+ } while (false)
+#else // OMPTARGET_DEBUG
+#define DP(...) {}
+#endif // OMPTARGET_DEBUG
+
#define INF_REF_CNT (LONG_MAX>>1) // leave room for additions/subtractions
#define CONSIDERED_INF(x) (x > (INF_REF_CNT>>1))
@@ -281,6 +293,12 @@
};
void RTLsTy::LoadRTLs() {
+#ifdef OMPTARGET_DEBUG
+ if (char *envStr = getenv("LIBOMPTARGET_DEBUG")) {
+ DebugLevel = std::stoi(envStr);
+ }
+#endif // OMPTARGET_DEBUG
+
// Parse environment variable OMP_TARGET_OFFLOAD (if set)
char *envStr = getenv("OMP_TARGET_OFFLOAD");
if (envStr && !strcmp(envStr, "DISABLED")) {