[X86] avx512-pmovxrm.ll - replace X32 checks with X86. NFC.
[llvm-project.git] / libunwind / test / libunwind_02.pass.cpp
blobea34cd54222c825974eebd67cccac35352310b63
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
10 // TODO: Figure out why this fails with Memory Sanitizer.
11 // XFAIL: msan
13 // This test fails on older llvm, when built with picolibc.
14 // XFAIL: clang-16 && LIBCXX-PICOLIBC-FIXME
16 #undef NDEBUG
17 #include <assert.h>
18 #include <stdlib.h>
19 #include <unwind.h>
21 #define EXPECTED_NUM_FRAMES 50
22 #define NUM_FRAMES_UPPER_BOUND 100
24 _Unwind_Reason_Code callback(_Unwind_Context *context, void *cnt) {
25 (void)context;
26 int *i = (int *)cnt;
27 ++*i;
28 if (*i > NUM_FRAMES_UPPER_BOUND) {
29 abort();
31 return _URC_NO_REASON;
34 void test_backtrace() {
35 int n = 0;
36 _Unwind_Backtrace(&callback, &n);
37 if (n < EXPECTED_NUM_FRAMES) {
38 abort();
42 int test(int i) {
43 if (i == 0) {
44 test_backtrace();
45 return 0;
46 } else {
47 return i + test(i - 1);
51 int main(int, char**) {
52 int total = test(50);
53 assert(total == 1275);
54 return 0;