[OpenMP] Use the assertion formatting from assert.h
authorJoseph Huber <jhuber6@vols.utk.edu>
Fri, 29 Oct 2021 19:49:56 +0000 (15:49 -0400)
committerJoseph Huber <jhuber6@vols.utk.edu>
Fri, 29 Oct 2021 20:44:01 +0000 (16:44 -0400)
This patch changes the `assert_assume` function used for internal
assumptions in the device runtime to use a more standard formatting for
the assumption message.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D112842

openmp/libomptarget/DeviceRTL/include/Debug.h
openmp/libomptarget/DeviceRTL/src/Debug.cpp

index 6aa801d..4f34187 100644 (file)
 #ifndef OMPTARGET_DEVICERTL_DEBUG_H
 #define OMPTARGET_DEVICERTL_DEBUG_H
 
+#include "Configuration.h"
+
 /// Assertion
 ///
 /// {
 extern "C" {
-void __assert_assume(bool cond, const char *exp, const char *file, int line);
+void __assert_assume(bool condition);
 void __assert_fail(const char *assertion, const char *file, unsigned line,
                    const char *function);
 }
 
-#define ASSERT(e) __assert_assume(e, #e, __FILE__, __LINE__)
+#define ASSERT(expr)                                                           \
+  {                                                                            \
+    if (config::isDebugMode(config::DebugKind::Assertion) && !expr)            \
+      __assert_fail(#expr, __FILE__, __LINE__, __PRETTY_FUNCTION__);           \
+    else                                                                       \
+      __assert_assume(expr);                                                   \
+  }
 
 ///}
 
index 2f0e608..4fbd2be 100644 (file)
@@ -21,14 +21,7 @@ using namespace _OMP;
 #pragma omp declare target
 
 extern "C" {
-void __assert_assume(bool cond, const char *exp, const char *file, int line) {
-  if (!cond && config::isDebugMode(config::DebugKind::Assertion)) {
-    PRINTF("ASSERTION failed: %s at %s, line %d\n", exp, file, line);
-    __builtin_trap();
-  }
-
-  __builtin_assume(cond);
-}
+void __assert_assume(bool condition) { __builtin_assume(condition); }
 
 void __assert_fail(const char *assertion, const char *file, unsigned line,
                    const char *function) {