1 // RUN: %clang -target i386-unknown-linux -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-i386
2 // RUN: %clang -target i386-unknown-linux -fno-stack-clash-protection -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-i386
3 // RUN: %clang -target i386-unknown-linux -fstack-clash-protection -fno-stack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-i386-NO
4 // SCP-i386: "-fstack-clash-protection"
5 // SCP-i386-NO-NOT: "-fstack-clash-protection"
6
7 // RUN: %clang -target x86_64-scei-linux -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-x86
8 // SCP-x86: "-fstack-clash-protection"
9
10 // RUN: %clang -target armv7k-apple-linux -fstack-clash-protection -### %s 2>&1 | FileCheck %s -check-prefix=SCP-armv7
11 // SCP-armv7-NOT: "-fstack-clash-protection"
12 // SCP-armv7: argument unused during compilation: '-fstack-clash-protection'
13
14 // RUN: %clang -target x86_64-unknown-linux -fstack-clash-protection -S -emit-llvm -o %t.ll %s 2>&1 | FileCheck %s -check-prefix=SCP-warn
15 // SCP-warn: warning: Unable to protect inline asm that clobbers stack pointer against stack clash
16
17 // RUN: %clang -target x86_64-pc-unknown-linux -fstack-clash-protection -S -emit-llvm -o- %s | FileCheck %s -check-prefix=SCP-ll-linux64
18 // SCP-ll-linux64: attributes {{.*}} "probe-stack"="inline-asm"
19
20 // RUN: %clang -target x86_64-pc-windows-msvc -fstack-clash-protection -S -emit-llvm -o- %s 2>&1 | FileCheck %s -check-prefix=SCP-ll-win64
21 // SCP-ll-win64-NOT: attributes {{.*}} "probe-stack"="inline-asm"
22 // SCP-ll-win64: argument unused during compilation: '-fstack-clash-protection'
23
foo(int c)24 int foo(int c) {
25 int r;
26 __asm__("sub %0, %%rsp"
27 :
28 : "rm"(c)
29 : "rsp");
30 __asm__("mov %%rsp, %0"
31 : "=rm"(r)::);
32 return r;
33 }
34