Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / msan / backtrace.cpp
blob7a8e041b3396306131fd16709c0ce9b237f0f806
1 // RUN: %clangxx_msan -O0 %s -o %t && %run %t
3 #include <assert.h>
4 #include <execinfo.h>
5 #include <stdio.h>
6 #include <string.h>
7 #include <stdlib.h>
9 __attribute__((noinline))
10 void f() {
11 void *buf[10];
12 int sz = backtrace(buf, sizeof(buf) / sizeof(*buf));
13 assert(sz > 0);
14 for (int i = 0; i < sz; ++i)
15 if (!buf[i]) {
16 #if defined(__s390x__)
17 // backtrace() may return a bogus trailing NULL on s390x.
18 if (i == sz - 1)
19 continue;
20 #endif
21 exit(1);
23 char **s = backtrace_symbols(buf, sz);
24 assert(s != 0);
25 for (int i = 0; i < sz; ++i)
26 printf("%d\n", (int)strlen(s[i]));
29 int main(void) {
30 f();
31 return 0;