Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / compress_stack_depot.cpp
blob7ad0ff08df33dada1829f15ea0fcee2d2fbb6bec
1 // RUN: %clangxx %s -fsanitize-memory-track-origins=1 -o %t
2 // RUN: %env_tool_opts="compress_stack_depot=0:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --implicit-check-not="StackDepot released"
3 // RUN: %env_tool_opts="compress_stack_depot=-1:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --check-prefixes=COMPRESS
4 // RUN: %env_tool_opts="compress_stack_depot=-2:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --check-prefixes=COMPRESS
5 // RUN: %env_tool_opts="compress_stack_depot=1:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --check-prefixes=COMPRESS,THREAD
6 // RUN: %env_tool_opts="compress_stack_depot=2:malloc_context_size=128:verbosity=1" %run %t 2>&1 | FileCheck %s --check-prefixes=COMPRESS,THREAD
8 // Ubsan does not store stacks.
9 // UNSUPPORTED: ubsan
11 // FIXME: Fails for unknown reason.
12 // UNSUPPORTED: target=s390x{{.*}}
14 // Similar to D114934, something is broken with background thread on THUMB and Asan.
15 // XFAIL: target=thumb{{.*}} && asan
17 #include <sanitizer/common_interface_defs.h>
19 #include <memory>
21 __attribute__((noinline)) void a(unsigned v);
22 __attribute__((noinline)) void b(unsigned v);
24 std::unique_ptr<int[]> p;
26 __attribute__((noinline)) void a(unsigned v) {
27 int x;
28 v >>= 1;
29 if (!v) {
30 p.reset(new int[100]);
31 p[1] = x;
32 return;
34 if (v & 1)
35 b(v);
36 else
37 a(v);
40 __attribute__((noinline)) void b(unsigned v) { return a(v); }
42 int main(int argc, char *argv[]) {
43 for (unsigned i = 0; i < 100000; ++i)
44 a(i + (i << 16));
46 __sanitizer_sandbox_arguments args = {0};
47 __sanitizer_sandbox_on_notify(&args);
49 return 0;
52 // THREAD: StackDepot compression thread started
53 // COMPRESS: StackDepot released {{[0-9]+}}
54 // THREAD: StackDepot compression thread stopped