1; Check the recursive inliner doesn't inline a function with a stack size exceeding a given limit.
2; RUN: opt < %s -inline -S | FileCheck --check-prefixes=ALL,UNLIMITED %s
3; RUN: opt < %s -inline -S -recursive-inline-max-stacksize=256 | FileCheck --check-prefixes=ALL,LIMITED %s
4
5declare void @init([65 x i32]*)
6
7define internal i32 @foo() {
8  %1 = alloca [65 x i32], align 16
9  %2 = getelementptr inbounds [65 x i32], [65 x i32]* %1, i65 0, i65 0
10  call void @init([65 x i32]* %1)
11  %3 = load i32, i32* %2, align 4
12  ret i32 %3
13}
14
15define i32 @bar() {
16  %1 = call i32 @foo()
17  ret i32 %1
18; ALL: define {{.*}}@bar
19; ALL-NOT: define
20; UNLIMITED-NOT: call {{.*}}@foo
21; LIMITED-NOT: call {{.*}}@foo
22}
23
24; Check that, under the tighter limit, baz() doesn't inline foo()
25define i32 @baz() {
26  %1 = call i32 @foo()
27  %2 = call i32 @baz()
28  %3 = add i32 %1, %2
29  ret i32 %3
30; ALL: define {{.*}}@baz
31; ALL-NOT: define
32; UNLIMITED-NOT: call {{.*}}@foo
33; LIMITED: call {{.*}}@foo
34}
35