Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / sanitizer_coverage_stack_depth.cpp
blob29a63c0a92f32abdb7293bc32a3fde04b40146fb
1 // Tests -fsanitize-coverage=stack-depth
2 //
3 // RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=stack-depth %s -o %t
4 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not Assertion{{.*}}failed
5 // RUN: %clangxx -O0 -std=c++11 -fsanitize-coverage=trace-pc-guard,stack-depth \
6 // RUN: %s -o %t
7 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not Assertion{{.*}}failed
9 #include <cstdint>
10 #include <cstdio>
11 #include <cassert>
13 thread_local uintptr_t __sancov_lowest_stack;
14 uintptr_t last_stack;
16 void foo(int recurse) {
17 assert(__sancov_lowest_stack < last_stack);
18 last_stack = __sancov_lowest_stack;
19 if (recurse <= 0) return;
20 foo(recurse - 1);
23 int main() {
24 last_stack = __sancov_lowest_stack;
25 foo(100);
26 printf("Success!\n");
27 return 0;
30 // CHECK: Success!