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 
6 // Ubsan does not store stacks.
7 // UNSUPPORTED: ubsan
8 
9 // FIXME: Fails for unknown reason.
10 // UNSUPPORTED: s390x
11 
12 #include <memory>
13 
14 __attribute__((noinline)) void a(unsigned v);
15 __attribute__((noinline)) void b(unsigned v);
16 
17 std::unique_ptr<int[]> p;
18 
19 __attribute__((noinline)) void a(unsigned v) {
20   int x;
21   v >>= 1;
22   if (!v) {
23     p.reset(new int[100]);
24     p[1] = x;
25     return;
26   }
27   if (v & 1)
28     b(v);
29   else
30     a(v);
31 }
32 
33 __attribute__((noinline)) void b(unsigned v) { return a(v); }
34 
35 int main(int argc, char *argv[]) {
36   for (unsigned i = 0; i < 100000; ++i)
37     a(i + (i << 16));
38   return 0;
39 }
40 
41 // COMPRESS: StackDepot released {{[0-9]+}}
42