1*cee313d2SEric Christopher; RUN: opt < %s -partial-inliner -S -stats -pass-remarks=partial-inlining 2>&1 | FileCheck %s
2*cee313d2SEric Christopher; RUN: opt < %s -passes=partial-inliner -S -stats -pass-remarks=partial-inlining 2>&1 | FileCheck %s
3*cee313d2SEric Christopher
4*cee313d2SEric Christopher@stat = external global i32, align 4
5*cee313d2SEric Christopher
6*cee313d2SEric Christopherdefine i32 @inline_fail(i32 %count, ...) {
7*cee313d2SEric Christopherentry:
8*cee313d2SEric Christopher  %vargs = alloca i8*, align 8
9*cee313d2SEric Christopher  %vargs1 = bitcast i8** %vargs to i8*
10*cee313d2SEric Christopher  call void @llvm.va_start(i8* %vargs1)
11*cee313d2SEric Christopher  %stat1 = load i32, i32* @stat, align 4
12*cee313d2SEric Christopher  %cmp = icmp slt i32 %stat1, 0
13*cee313d2SEric Christopher  br i1 %cmp, label %bb2, label %bb1
14*cee313d2SEric Christopher
15*cee313d2SEric Christopherbb1:                                              ; preds = %entry
16*cee313d2SEric Christopher  %vg1 = add nsw i32 %stat1, 1
17*cee313d2SEric Christopher  store i32 %vg1, i32* @stat, align 4
18*cee313d2SEric Christopher  %va1 = va_arg i8** %vargs, i32
19*cee313d2SEric Christopher  call void @foo(i32 %count, i32 %va1) #2
20*cee313d2SEric Christopher  br label %bb2
21*cee313d2SEric Christopher
22*cee313d2SEric Christopherbb2:                                              ; preds = %bb1, %entry
23*cee313d2SEric Christopher  %res = phi i32 [ 1, %bb1 ], [ 0, %entry ]
24*cee313d2SEric Christopher  call void @llvm.va_end(i8* %vargs1)
25*cee313d2SEric Christopher  ret i32 %res
26*cee313d2SEric Christopher}
27*cee313d2SEric Christopher
28*cee313d2SEric Christopherdefine i32 @caller(i32 %arg) {
29*cee313d2SEric Christopherbb:
30*cee313d2SEric Christopher  %res = tail call i32 (i32, ...) @inline_fail(i32 %arg, i32 %arg)
31*cee313d2SEric Christopher  ret i32 %res
32*cee313d2SEric Christopher}
33*cee313d2SEric Christopher
34*cee313d2SEric Christopherdeclare void @foo(i32, i32)
35*cee313d2SEric Christopherdeclare void @llvm.va_start(i8*)
36*cee313d2SEric Christopherdeclare void @llvm.va_end(i8*)
37*cee313d2SEric Christopher
38*cee313d2SEric Christopher; Check that no remarks have been emitted, inline_fail has not been partial
39*cee313d2SEric Christopher; inlined, no code has been extracted and the partial-inlining counter
40*cee313d2SEric Christopher; has not been incremented.
41*cee313d2SEric Christopher
42*cee313d2SEric Christopher; CHECK-NOT: remark
43*cee313d2SEric Christopher; CHECK: tail call i32 (i32, ...) @inline_fail(i32 %arg, i32 %arg)
44*cee313d2SEric Christopher; CHECK-NOT: inline_fail.1_bb1
45*cee313d2SEric Christopher; CHECK-NOT: partial-inlining
46