[OpenMP] Use the assertion formatting from assert.h

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

GitOrigin-RevId: 2c6a4e5678c286c8b1129d66ccf24a828a6a0414
diff --git a/libomptarget/DeviceRTL/include/Debug.h b/libomptarget/DeviceRTL/include/Debug.h
index 6aa801d..4f34187 100644
--- a/libomptarget/DeviceRTL/include/Debug.h
+++ b/libomptarget/DeviceRTL/include/Debug.h
@@ -12,16 +12,24 @@
 #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);                                                   \
+  }
 
 ///}
 
diff --git a/libomptarget/DeviceRTL/src/Debug.cpp b/libomptarget/DeviceRTL/src/Debug.cpp
index 2f0e608..4fbd2be 100644
--- a/libomptarget/DeviceRTL/src/Debug.cpp
+++ b/libomptarget/DeviceRTL/src/Debug.cpp
@@ -21,14 +21,7 @@
 #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) {