1 ; RUN: opt %s -inline -S | grep {call.*fib} | count 4
2 ; First call to fib from fib is inlined, producing 2 instead of 1, total 3.
3 ; Second call to fib from fib is not inlined because new body of fib exceeds
4 ; inlining limit of 200. Plus call in main = 4 total.
7 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
8 target triple = "i386-apple-darwin9.6"
9 @"\01LC" = internal constant [5 x i8] c"%ld\0A\00" ; <[5 x i8]*> [#uses=1]
11 define i32 @fib(i32 %n) nounwind {
13 %n_addr = alloca i32 ; <i32*> [#uses=4]
14 %retval = alloca i32 ; <i32*> [#uses=2]
15 %0 = alloca i32 ; <i32*> [#uses=3]
16 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
17 store i32 %n, i32* %n_addr
18 %1 = load i32* %n_addr, align 4 ; <i32> [#uses=1]
19 %2 = icmp ule i32 %1, 1 ; <i1> [#uses=1]
20 br i1 %2, label %bb, label %bb1
23 store i32 1, i32* %0, align 4
27 %3 = load i32* %n_addr, align 4 ; <i32> [#uses=1]
28 %4 = sub i32 %3, 2 ; <i32> [#uses=1]
29 %5 = call i32 @fib(i32 %4) nounwind ; <i32> [#uses=1]
30 %6 = load i32* %n_addr, align 4 ; <i32> [#uses=1]
31 %7 = sub i32 %6, 1 ; <i32> [#uses=1]
32 %8 = call i32 @fib(i32 %7) nounwind ; <i32> [#uses=1]
33 %9 = add i32 %5, %8 ; <i32> [#uses=1]
34 store i32 %9, i32* %0, align 4
37 bb2: ; preds = %bb1, %bb
38 %10 = load i32* %0, align 4 ; <i32> [#uses=1]
39 store i32 %10, i32* %retval, align 4
42 return: ; preds = %bb2
43 %retval3 = load i32* %retval ; <i32> [#uses=1]
47 define i32 @main(i32 %argc, i8** %argv) nounwind {
49 %argc_addr = alloca i32 ; <i32*> [#uses=2]
50 %argv_addr = alloca i8** ; <i8***> [#uses=2]
51 %retval = alloca i32 ; <i32*> [#uses=2]
52 %N = alloca i32 ; <i32*> [#uses=2]
53 %0 = alloca i32 ; <i32*> [#uses=2]
54 %iftmp.0 = alloca i32 ; <i32*> [#uses=3]
55 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
56 store i32 %argc, i32* %argc_addr
57 store i8** %argv, i8*** %argv_addr
58 %1 = load i32* %argc_addr, align 4 ; <i32> [#uses=1]
59 %2 = icmp eq i32 %1, 2 ; <i1> [#uses=1]
60 br i1 %2, label %bb, label %bb1
63 %3 = load i8*** %argv_addr, align 4 ; <i8**> [#uses=1]
64 %4 = getelementptr i8** %3, i32 1 ; <i8**> [#uses=1]
65 %5 = load i8** %4, align 4 ; <i8*> [#uses=1]
66 %6 = call i32 @atoi(i8* %5) nounwind ; <i32> [#uses=1]
67 store i32 %6, i32* %iftmp.0, align 4
71 store i32 43, i32* %iftmp.0, align 4
74 bb2: ; preds = %bb1, %bb
75 %7 = load i32* %iftmp.0, align 4 ; <i32> [#uses=1]
76 store i32 %7, i32* %N, align 4
77 %8 = load i32* %N, align 4 ; <i32> [#uses=1]
78 %9 = call i32 @fib(i32 %8) nounwind ; <i32> [#uses=1]
79 %10 = call i32 (i8*, ...)* @printf(i8* getelementptr ([5 x i8]* @"\01LC", i32 0, i32 0), i32 %9) nounwind ; <i32> [#uses=0]
80 store i32 0, i32* %0, align 4
81 %11 = load i32* %0, align 4 ; <i32> [#uses=1]
82 store i32 %11, i32* %retval, align 4
85 return: ; preds = %bb2
86 %retval3 = load i32* %retval ; <i32> [#uses=1]
90 declare i32 @atoi(i8*)
92 declare i32 @printf(i8*, ...) nounwind