1 ; Inlining in the presence of recursion presents special challenges that we
4 ; RUN: opt -passes=inline -S < %s | FileCheck %s
5 ; RUN: opt -passes='cgscc(inline)' -S < %s | FileCheck %s
7 define i32 @large_stack_callee(i32 %param) {
8 ; CHECK-LABEL: define i32 @large_stack_callee(
10 %yyy = alloca [100000 x i8]
11 call void @bar(ptr %yyy)
15 ; Test a recursive function which calls another function with a large stack. In
16 ; addition to not inlining the recursive call, we should also not inline the
17 ; large stack allocation into a potentially recursive frame.
18 define i32 @large_stack_recursive_caller(i32 %param) {
19 ; CHECK-LABEL: define i32 @large_stack_recursive_caller(
23 %t = call i32 @foo(i32 %param)
24 %cmp = icmp eq i32 %t, -1
25 br i1 %cmp, label %exit, label %cont
28 %r = call i32 @large_stack_recursive_caller(i32 %t)
29 ; CHECK: call i32 @large_stack_recursive_caller
30 %f = call i32 @large_stack_callee(i32 %r)
31 ; CHECK: call i32 @large_stack_callee
38 declare void @bar(ptr %in)
40 declare i32 @foo(i32 %param)
42 ; Check that when inlining a non-recursive path into a function's own body that
43 ; we get the re-mapping of instructions correct.
44 define i32 @test_recursive_inlining_remapping(i1 %init, ptr %addr) {
45 ; CHECK-LABEL: define i32 @test_recursive_inlining_remapping(
48 br i1 %init, label %store, label %load
51 ; CHECK: %[[N:.*]] = alloca i32
52 ; CHECK-NEXT: br i1 %init,
56 %v = call i32 @test_recursive_inlining_remapping(i1 false, ptr %n)
60 ; CHECK: store i32 0, ptr %[[N]]
61 ; CHECK-NEXT: %[[INLINED_LOAD:.*]] = load i32, ptr %[[N]]
62 ; CHECK-NEXT: ret i32 %[[INLINED_LOAD]]
67 %n.load = load i32, ptr %addr