1 ; Check the inliner doesn't inline a function with a stack size exceeding a given limit.
2 ; RUN: opt < %s -passes=inline -S | FileCheck --check-prefixes=ALL,UNLIMITED %s
3 ; RUN: opt < %s -passes=inline -S -inline-max-stacksize=256 | FileCheck --check-prefixes=ALL,LIMITED %s
5 declare void @init(ptr)
7 define internal i32 @foo() {
8 %1 = alloca [65 x i32], align 16
9 call void @init(ptr %1)
10 %2 = load i32, ptr %1, align 4
14 define i32 @barNoAttr() {
17 ; ALL: define {{.*}}@barNoAttr
19 ; UNLIMITED-NOT: call {{.*}}@foo
20 ; LIMITED: call {{.*}}@foo
23 ; Check that, under the imposed limit, baz() inlines bar(), but not foo().
24 define i32 @bazNoAttr() {
25 %1 = call i32 @barNoAttr()
27 ; ALL: define {{.*}}@baz
28 ; UNLIMITED-NOT: call {{.*}}@barNoAttr
29 ; UNLIMITED-NOT: call {{.*}}@foo
30 ; LIMITED-NOT: call {{.*}}@barNoAttr
31 ; LIMITED: call {{.*}}@foo
34 ; Check that the function attribute prevents inlining of foo().
35 define i32 @barAttr() #0 {
38 ; ALL: define {{.*}}@barAttr
40 ; ALL: call {{.*}}@foo
43 ; Check that the commandline option overrides the function attribute.
44 define i32 @bazAttr() #1 {
45 %1 = call i32 @barAttr()
47 ; ALL: define {{.*}}@bazAttr
48 ; UNLIMITED-NOT: call {{.*}}@barAttr
49 ; UNLIMITED-NOT: call {{.*}}@foo
50 ; LIMITED: call {{.*}}@foo
53 attributes #0 = { "inline-max-stacksize"="256" }
54 attributes #1 = { "inline-max-stacksize"="512" }