Commit b266bcb1 authored by Huber, Joseph's avatar Huber, Joseph
Browse files

[OpenMP] Implement __assert_fail in the new device runtime

This patch implements the `__assert_fail` function in the new device
runtime. This allows users and developers to use the standars assert
function inside of the device.

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D109886
parent c30d7730
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
/// {
extern "C" {
void __assert_assume(bool cond, const char *exp, const char *file, int line);
void __assert_fail(const char *assertion, const char *file, unsigned line,
                   const char *function);
}

#define ASSERT(e) __assert_assume(e, #e, __FILE__, __LINE__)
+7 −0
Original line number Diff line number Diff line
@@ -26,6 +26,13 @@ void __assert_assume(bool cond, const char *exp, const char *file, int line) {

  __builtin_assume(cond);
}

void __assert_fail(const char *assertion, const char *file, unsigned line,
                   const char *function) {
  PRINTF("%s:%u: %s: Assertion `%s' failed.\n", file, line, function,
         assertion);
  __builtin_trap();
}
}

#pragma omp end declare target