1; RUN: llc -mtriple x86_64-apple-macosx10.8.0 < %s 2>&1 >/dev/null | FileCheck %s
2; Check the internal option that warns when the stack frame size exceeds the
3; given amount.
4; <rdar://13987214>
5
6; CHECK-NOT: nowarn
7define void @nowarn() nounwind ssp "warn-stack-size"="80" {
8entry:
9  %buffer = alloca [12 x i8], align 1
10  %arraydecay = getelementptr inbounds [12 x i8], [12 x i8]* %buffer, i64 0, i64 0
11  call void @doit(i8* %arraydecay) nounwind
12  ret void
13}
14
15; CHECK: warning: stack frame size (88) exceeds limit (80) in function 'warn'
16define void @warn() nounwind ssp "warn-stack-size"="80" {
17entry:
18  %buffer = alloca [80 x i8], align 1
19  %arraydecay = getelementptr inbounds [80 x i8], [80 x i8]* %buffer, i64 0, i64 0
20  call void @doit(i8* %arraydecay) nounwind
21  ret void
22}
23
24; Ensure that warn-stack-size also considers the size of the unsafe stack.
25; With safestack enabled the machine stack size is well below 80, but the
26; combined stack size of the machine stack and unsafe stack will exceed the
27; warning threshold
28
29; CHECK: warning: stack frame size (120) exceeds limit (80) in function 'warn_safestack'
30define void @warn_safestack() nounwind ssp safestack "warn-stack-size"="80" {
31entry:
32  %buffer = alloca [80 x i8], align 1
33  %arraydecay = getelementptr inbounds [80 x i8], [80 x i8]* %buffer, i64 0, i64 0
34  call void @doit(i8* %arraydecay) nounwind
35  ret void
36}
37declare void @doit(i8*)
38