[Openmp-commits] [openmp] 2c6a4e5 - [OpenMP] Use the assertion formatting from assert.h

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Fri Oct 29 13:44:07 PDT 2021


Author: Joseph Huber
Date: 2021-10-29T16:44:01-04:00
New Revision: 2c6a4e5678c286c8b1129d66ccf24a828a6a0414

URL: https://github.com/llvm/llvm-project/commit/2c6a4e5678c286c8b1129d66ccf24a828a6a0414
DIFF: https://github.com/llvm/llvm-project/commit/2c6a4e5678c286c8b1129d66ccf24a828a6a0414.diff

LOG: [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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/DeviceRTL/include/Debug.h b/openmp/libomptarget/DeviceRTL/include/Debug.h
index 6aa801d80bd7..4f3418766413 100644
--- a/openmp/libomptarget/DeviceRTL/include/Debug.h
+++ b/openmp/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/openmp/libomptarget/DeviceRTL/src/Debug.cpp b/openmp/libomptarget/DeviceRTL/src/Debug.cpp
index 2f0e608832a7..4fbd2be98fcb 100644
--- a/openmp/libomptarget/DeviceRTL/src/Debug.cpp
+++ b/openmp/libomptarget/DeviceRTL/src/Debug.cpp
@@ -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) {


        


More information about the Openmp-commits mailing list