1 //===--- Debug.cpp -------- Debug utilities ----------------------- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file contains debug utilities
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "Debug.h"
14 #include "Configuration.h"
15 
16 using namespace _OMP;
17 
18 #pragma omp declare target
19 
20 extern "C" {
21 void __assert_assume(bool cond, const char *exp, const char *file, int line) {
22   if (!cond && config::isDebugMode(config::DebugLevel::Assertion)) {
23     PRINTF("ASSERTION failed: %s at %s, line %d\n", exp, file, line);
24     __builtin_trap();
25   }
26 
27   __builtin_assume(cond);
28 }
29 
30 void __assert_fail(const char *assertion, const char *file, unsigned line,
31                    const char *function) {
32   PRINTF("%s:%u: %s: Assertion `%s' failed.\n", file, line, function,
33          assertion);
34   __builtin_trap();
35 }
36 }
37 
38 #pragma omp end declare target
39