1 ; Inlining in the presence of recursion presents special challenges that we
4 ; RUN: opt -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 %r = bitcast [100000 x i8]* %yyy to i8*
12 call void @bar(i8* %r)
16 ; Test a recursive function which calls another function with a large stack. In
17 ; addition to not inlining the recursive call, we should also not inline the
18 ; large stack allocation into a potentially recursive frame.
19 define i32 @large_stack_recursive_caller(i32 %param) {
20 ; CHECK-LABEL: define i32 @large_stack_recursive_caller(
24 %t = call i32 @foo(i32 %param)
25 %cmp = icmp eq i32 %t, -1
26 br i1 %cmp, label %exit, label %cont
29 %r = call i32 @large_stack_recursive_caller(i32 %t)
30 ; CHECK: call i32 @large_stack_recursive_caller
31 %f = call i32 @large_stack_callee(i32 %r)
32 ; CHECK: call i32 @large_stack_callee
39 declare void @bar(i8* %in)
41 declare i32 @foo(i32 %param)
43 ; Check that when inlining a non-recursive path into a function's own body that
44 ; we get the re-mapping of instructions correct.
45 define i32 @test_recursive_inlining_remapping(i1 %init, i8* %addr) {
46 ; CHECK-LABEL: define i32 @test_recursive_inlining_remapping(
49 br i1 %init, label %store, label %load
52 ; CHECK: %[[N:.*]] = alloca i32
53 ; CHECK-NEXT: br i1 %init,
57 %cast = bitcast i32* %n to i8*
58 %v = call i32 @test_recursive_inlining_remapping(i1 false, i8* %cast)
62 ; CHECK: store i32 0, i32* %[[N]]
63 ; CHECK-NEXT: %[[CAST:.*]] = bitcast i32* %[[N]] to i8*
64 ; CHECK-NEXT: %[[INLINED_LOAD:.*]] = load i32, i32* %[[N]]
65 ; CHECK-NEXT: ret i32 %[[INLINED_LOAD]]
70 %castback = bitcast i8* %addr to i32*
71 %n.load = load i32, i32* %castback