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