1; RUN: opt < %s -partial-inliner -skip-partial-inlining-cost-analysis -S | FileCheck  %s
2; RUN: opt < %s -passes=partial-inliner -skip-partial-inlining-cost-analysis -S | FileCheck   %s
3
4%"class.base" = type { %"struct.base"* }
5%"struct.base" = type opaque
6
7@g = external local_unnamed_addr global i32, align 4
8
9; CHECK-LABEL: define{{.*}}@caller(
10; CHECK: call void @llvm.lifetime.start.p0i8(i64 -1, i8* %tmp.i)
11; CHECK-NEXT: call void @callee_unknown_use1.{{.*}}(i8* %tmp.i
12; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 -1, i8* %tmp.i)
13
14define i32 @callee_unknown_use1(i32 %arg) local_unnamed_addr #0 {
15; CHECK-LABEL:define{{.*}}@callee_unknown_use1.{{[0-9]}}
16; CHECK-NOT: alloca
17bb:
18  %tmp = alloca  i8, align 4
19  %tmp2 = load i32, i32* @g, align 4, !tbaa !2
20  %tmp3 = add nsw i32 %tmp2, 1
21  %tmp4 = icmp slt i32 %arg, 0
22  br i1 %tmp4, label %bb6, label %bb5
23
24bb5:                                              ; preds = %bb
25  call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %tmp) #2
26  store i32 %tmp3, i32* @g, align 4, !tbaa !2
27  %tmp11 = bitcast i8* %tmp to i32*
28  call void @bar(i32* nonnull %tmp11) #2
29  call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %tmp) #2
30  br label %bb6
31
32bb6:                                              ; preds = %bb5, %bb
33  %tmp7 = phi i32 [ 1, %bb5 ], [ 0, %bb ]
34  %tmp1 = bitcast i8* %tmp to i32*
35  ret i32 %tmp7
36}
37
38
39; Function Attrs: argmemonly nounwind
40declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
41
42declare void @bar(i32*) local_unnamed_addr #2
43declare void @bar2(i32*, i32*) local_unnamed_addr #1
44
45
46; Function Attrs: argmemonly nounwind
47declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
48
49; Function Attrs: nounwind uwtable
50define i32 @caller(i32 %arg) local_unnamed_addr #0 {
51bb:
52  %tmp = tail call i32 @callee_unknown_use1(i32 %arg)
53  ret i32 %tmp
54}
55
56attributes #0 = { nounwind uwtable}
57attributes #1 = { argmemonly nounwind }
58attributes #2 = { nounwind }
59
60!llvm.module.flags = !{!0}
61!llvm.ident = !{!1}
62
63!0 = !{i32 1, !"wchar_size", i32 4}
64!1 = !{!"clang version 5.0.0 (trunk 303574)"}
65!2 = !{!3, !3, i64 0}
66!3 = !{!"int", !4, i64 0}
67!4 = !{!"omnipotent char", !5, i64 0}
68!5 = !{!"Simple C/C++ TBAA"}
69
70
71
72