Home | History | Annotate | Download | only in Inline
      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: opt < %s -inline -S | \
      7 ; RUN:   grep llvm.stacksave
      8 ; RUN: opt < %s -inline -S | 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 
     36