Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / shadowcallstack / overflow.c
blobf9f64096fd1f8bd3d2cd91dc1f6b205a0b41022d
1 // Test that a stack overflow fails as expected
3 // RUN: %clang_noscs %s -o %t -DITERATIONS=3
4 // RUN: %run %t | FileCheck %s
5 // RUN: %clang_noscs %s -o %t -DITERATIONS=12
6 // RUN: %run %t | FileCheck -check-prefix=OVERFLOW_SUCCESS %s
8 // RUN: %clang_scs %s -o %t -DITERATIONS=3
9 // RUN: %run %t | FileCheck %s
11 // On aarch64 we just load the return address from the shadow call stack so we
12 // do not expect to see the output from print_and_exit.
13 // RUN: %clang_scs %s -o %t -DITERATIONS=12
14 // RUN: %run %t | FileCheck %S/overflow.c
16 #include <stdio.h>
17 #include <stdlib.h>
19 #include "minimal_runtime.h"
21 void print_and_exit(void) {
22 // CHECK-NOT: Stack overflow successful.
23 // OVERFLOW_SUCCESS: Stack overflow successful.
24 scs_fputs_stdout("Stack overflow successful.\n");
25 exit(0);
28 int scs_main(void)
30 void *addrs[4];
31 for (int i = 0; i < ITERATIONS; i++)
32 addrs[i] = &print_and_exit;
34 scs_fputs_stdout("Returning.\n");
36 return 0;