1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
2 ; RUN: opt < %s -passes=tailcallelim -verify-dom-info -S | FileCheck %s
4 ; the test was generated from the following C++ source:
8 ; int foo ( int count, S p1 ) {
12 ; // After TRE: temporarily variable created for passing byvalue parameter
13 ; // p1 could be used when zoo(p1) is called.
14 ; return foo(count+1, p1);
17 ; this test checks that value of ByValue operand AGG_TMP_I of call site foo()
18 ; is copied into temporarily variable AGG_TMP_I1(byVal value holder) and
19 ; later the value from AGG_TMP_I1 is copied into function argument P1 before
20 ; new iteration started.
22 %struct.S = type { i32, i32, float, %struct.B }
23 %struct.B = type { i32, float }
25 ; Function Attrs: uwtable
26 define dso_local i32 @_Z3fooi1S(i32 %count, ptr nocapture readonly byval(%struct.S) align 8 %p1) local_unnamed_addr #0 {
27 ; CHECK-LABEL: define {{[^@]+}}@_Z3fooi1S
28 ; CHECK-SAME: (i32 [[COUNT:%.*]], ptr nocapture byval([[STRUCT_S:%.*]]) align 8 [[P1:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
30 ; CHECK-NEXT: [[AGG_TMP_I1:%.*]] = alloca [[STRUCT_S]], align 8
31 ; CHECK-NEXT: [[AGG_TMP_I:%.*]] = alloca [[STRUCT_S]], align 8
32 ; CHECK-NEXT: [[AGG_TMP14:%.*]] = alloca [[STRUCT_S]], align 8
33 ; CHECK-NEXT: [[AGG_TMP:%.*]] = alloca [[STRUCT_S]], align 8
34 ; CHECK-NEXT: [[AGG_TMP1:%.*]] = alloca [[STRUCT_S]], align 8
35 ; CHECK-NEXT: br label [[TAILRECURSE:%.*]]
37 ; CHECK-NEXT: [[COUNT_TR:%.*]] = phi i32 [ [[COUNT]], [[ENTRY:%.*]] ], [ [[ADD:%.*]], [[IF_END:%.*]] ]
38 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[COUNT_TR]], 10
39 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END]]
41 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 dereferenceable(20) [[AGG_TMP]], ptr nonnull align 8 dereferenceable(20) [[P1]], i64 20, i1 false)
42 ; CHECK-NEXT: [[CALL:%.*]] = tail call i32 @_Z3zoo1S(ptr nonnull byval([[STRUCT_S]]) align 8 [[AGG_TMP]])
43 ; CHECK-NEXT: br label [[RETURN:%.*]]
45 ; CHECK-NEXT: [[ADD]] = add nsw i32 [[COUNT_TR]], 1
46 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 dereferenceable(20) [[AGG_TMP1]], ptr nonnull align 8 dereferenceable(20) [[P1]], i64 20, i1 false)
47 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 20, ptr nonnull [[AGG_TMP14]])
48 ; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 20, ptr nonnull [[AGG_TMP_I]])
49 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 dereferenceable(20) [[AGG_TMP14]], ptr nonnull align 8 dereferenceable(20) [[AGG_TMP1]], i64 20, i1 false)
50 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 dereferenceable(20) [[AGG_TMP_I]], ptr nonnull align 8 dereferenceable(20) [[AGG_TMP14]], i64 20, i1 false)
51 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[AGG_TMP_I1]], ptr align 8 [[AGG_TMP_I]], i64 20, i1 false)
52 ; CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[P1]], ptr align 8 [[AGG_TMP_I1]], i64 20, i1 false)
53 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 20, ptr nonnull [[AGG_TMP14]])
54 ; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 20, ptr nonnull [[AGG_TMP_I]])
55 ; CHECK-NEXT: br label [[TAILRECURSE]]
57 ; CHECK-NEXT: ret i32 [[CALL]]
60 %agg.tmp.i = alloca %struct.S, align 8
61 %agg.tmp14 = alloca %struct.S, align 8
62 %agg.tmp = alloca %struct.S, align 8
63 %agg.tmp1 = alloca %struct.S, align 8
64 %cmp = icmp sgt i32 %count, 10
65 br i1 %cmp, label %if.then, label %if.end
67 if.then: ; preds = %entry
68 call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 dereferenceable(20) %agg.tmp, ptr nonnull align 8 dereferenceable(20) %p1, i64 20, i1 false)
69 %call = call i32 @_Z3zoo1S(ptr nonnull byval(%struct.S) align 8 %agg.tmp)
72 if.end: ; preds = %entry
73 %add = add nsw i32 %count, 1
74 call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 dereferenceable(20) %agg.tmp1, ptr nonnull align 8 dereferenceable(20) %p1, i64 20, i1 false)
75 call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %agg.tmp14)
76 call void @llvm.lifetime.start.p0(i64 20, ptr nonnull %agg.tmp.i)
77 call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 dereferenceable(20) %agg.tmp14, ptr nonnull align 8 dereferenceable(20) %agg.tmp1, i64 20, i1 false)
78 call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 dereferenceable(20) %agg.tmp.i, ptr nonnull align 8 dereferenceable(20) %agg.tmp14, i64 20, i1 false)
79 %call.i = call i32 @_Z3fooi1S(i32 %add, ptr nonnull byval(%struct.S) align 8 %agg.tmp.i)
80 call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %agg.tmp14)
81 call void @llvm.lifetime.end.p0(i64 20, ptr nonnull %agg.tmp.i)
84 return: ; preds = %if.end, %if.then
85 %retval.0 = phi i32 [ %call, %if.then ], [ %call.i, %if.end ]
89 declare dso_local i32 @_Z3zoo1S(ptr byval(%struct.S) align 8) local_unnamed_addr #1
91 ; Function Attrs: argmemonly nounwind willreturn
92 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2
94 ; Function Attrs: argmemonly nounwind willreturn
95 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2
97 ; Function Attrs: argmemonly nounwind willreturn
98 declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2
100 attributes #0 = { uwtable }
101 attributes #1 = { uwtable }
102 attributes #2 = { argmemonly nounwind willreturn }