xref: /llvm-project/llvm/test/CodeGen/X86/warn-stack.ll (revision b97527f14459ef89bc94d652fcf94ba91b61b34c)
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  call void @doit(ptr %buffer) nounwind
11  ret void
12}
13
14; CHECK: warning: <unknown>:0:0: stack frame size ([[STCK:[0-9]+]]) exceeds limit (80) in function 'warn'
15define void @warn() nounwind ssp "warn-stack-size"="80" {
16entry:
17  %buffer = alloca [80 x i8], align 1
18  call void @doit(ptr %buffer) nounwind
19  ret void
20}
21
22; Ensure that warn-stack-size also considers the size of the unsafe stack.
23; With safestack enabled the machine stack size is well below 80, but the
24; combined stack size of the machine stack and unsafe stack will exceed the
25; warning threshold
26
27; CHECK: warning: <unknown>:0:0: stack frame size ([[STCK:[0-9]+]]) exceeds limit (80) in function 'warn_safestack'
28define i32 @warn_safestack() nounwind ssp safestack "warn-stack-size"="80" {
29entry:
30  %var = alloca i32, align 4
31  %buffer = alloca [80 x i8], align 1
32  call void @doit(ptr %buffer) nounwind
33  call void @doit(ptr %var) nounwind
34  %val = load i32, ptr %var
35  ret i32 %val
36}
37declare void @doit(ptr)
38