While inlining, clone llvm.dbg.func.start intrinsic and adjust
[oota-llvm.git] / test / Transforms / Inline / dynamic_alloca_test.ll
1 ; Test that functions with dynamic allocas get inlined in a case where
2 ; naively inlining it would result in a miscompilation.
3 ; Functions with dynamic allocas can only be inlined into functions that
4 ; already have dynamic allocas.
5
6 ; RUN: llvm-as < %s | opt -inline | llvm-dis | \
7 ; RUN:   grep llvm.stacksave
8 ; RUN: llvm-as < %s | opt -inline | llvm-dis | not grep callee
9
10
11 declare void @ext(i32*)
12
13 define internal void @callee(i32 %N) {
14         %P = alloca i32, i32 %N         ; <i32*> [#uses=1]
15         call void @ext( i32* %P )
16         ret void
17 }
18
19 define void @foo(i32 %N) {
20 ; <label>:0
21         %P = alloca i32, i32 %N         ; <i32*> [#uses=1]
22         call void @ext( i32* %P )
23         br label %Loop
24
25 Loop:           ; preds = %Loop, %0
26         %count = phi i32 [ 0, %0 ], [ %next, %Loop ]            ; <i32> [#uses=2]
27         %next = add i32 %count, 1               ; <i32> [#uses=1]
28         call void @callee( i32 %N )
29         %cond = icmp eq i32 %count, 100000              ; <i1> [#uses=1]
30         br i1 %cond, label %out, label %Loop
31
32 out:            ; preds = %Loop
33         ret void
34 }
35