1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -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, %struct.S* nocapture readonly byval(%struct.S) align 8 %p1) local_unnamed_addr #0 {
27 ; CHECK-LABEL: @_Z3fooi1S(
29 ; CHECK-NEXT: [[AGG_TMP_I1:%.*]] = alloca [[STRUCT_S:%.*]], align 8
30 ; CHECK-NEXT: [[AGG_TMP_I:%.*]] = alloca [[STRUCT_S]], align 8
31 ; CHECK-NEXT: [[AGG_TMP14:%.*]] = alloca [[STRUCT_S]], align 8
32 ; CHECK-NEXT: [[AGG_TMP:%.*]] = alloca [[STRUCT_S]], align 8
33 ; CHECK-NEXT: [[AGG_TMP1:%.*]] = alloca [[STRUCT_S]], align 8
34 ; CHECK-NEXT: br label [[TAILRECURSE:%.*]]
36 ; CHECK-NEXT: [[COUNT_TR:%.*]] = phi i32 [ [[COUNT:%.*]], [[ENTRY:%.*]] ], [ [[ADD:%.*]], [[IF_END:%.*]] ]
37 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[COUNT_TR]], 10
38 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_END]]
40 ; CHECK-NEXT: [[TMP0:%.*]] = bitcast %struct.S* [[AGG_TMP]] to i8*
41 ; CHECK-NEXT: [[TMP1:%.*]] = bitcast %struct.S* [[P1:%.*]] to i8*
42 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 dereferenceable(20) [[TMP0]], i8* nonnull align 8 dereferenceable(20) [[TMP1]], i64 20, i1 false)
43 ; CHECK-NEXT: [[CALL:%.*]] = tail call i32 @_Z3zoo1S(%struct.S* nonnull byval(%struct.S) align 8 [[AGG_TMP]])
44 ; CHECK-NEXT: br label [[RETURN:%.*]]
46 ; CHECK-NEXT: [[ADD]] = add nsw i32 [[COUNT_TR]], 1
47 ; CHECK-NEXT: [[TMP2:%.*]] = bitcast %struct.S* [[AGG_TMP1]] to i8*
48 ; CHECK-NEXT: [[TMP3:%.*]] = bitcast %struct.S* [[P1]] to i8*
49 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 dereferenceable(20) [[TMP2]], i8* nonnull align 8 dereferenceable(20) [[TMP3]], i64 20, i1 false)
50 ; CHECK-NEXT: [[AGG_TMP14_0__SROA_CAST:%.*]] = bitcast %struct.S* [[AGG_TMP14]] to i8*
51 ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 20, i8* nonnull [[AGG_TMP14_0__SROA_CAST]])
52 ; CHECK-NEXT: [[TMP4:%.*]] = bitcast %struct.S* [[AGG_TMP_I]] to i8*
53 ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 20, i8* nonnull [[TMP4]])
54 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 dereferenceable(20) [[AGG_TMP14_0__SROA_CAST]], i8* nonnull align 8 dereferenceable(20) [[TMP2]], i64 20, i1 false)
55 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 dereferenceable(20) [[TMP4]], i8* nonnull align 8 dereferenceable(20) [[AGG_TMP14_0__SROA_CAST]], i64 20, i1 false)
56 ; CHECK-NEXT: [[TMP5:%.*]] = bitcast %struct.S* [[AGG_TMP_I1]] to i8*
57 ; CHECK-NEXT: [[TMP6:%.*]] = bitcast %struct.S* [[AGG_TMP_I]] to i8*
58 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[TMP5]], i8* align 8 [[TMP6]], i64 20, i1 false)
59 ; CHECK-NEXT: [[TMP7:%.*]] = bitcast %struct.S* [[P1]] to i8*
60 ; CHECK-NEXT: [[TMP8:%.*]] = bitcast %struct.S* [[AGG_TMP_I1]] to i8*
61 ; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 [[TMP7]], i8* align 8 [[TMP8]], i64 20, i1 false)
62 ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 20, i8* nonnull [[AGG_TMP14_0__SROA_CAST]])
63 ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 20, i8* nonnull [[TMP4]])
64 ; CHECK-NEXT: br label [[TAILRECURSE]]
66 ; CHECK-NEXT: ret i32 [[CALL]]
69 %agg.tmp.i = alloca %struct.S, align 8
70 %agg.tmp14 = alloca %struct.S, align 8
71 %agg.tmp = alloca %struct.S, align 8
72 %agg.tmp1 = alloca %struct.S, align 8
73 %cmp = icmp sgt i32 %count, 10
74 br i1 %cmp, label %if.then, label %if.end
76 if.then: ; preds = %entry
77 %0 = bitcast %struct.S* %agg.tmp to i8*
78 %1 = bitcast %struct.S* %p1 to i8*
79 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 dereferenceable(20) %0, i8* nonnull align 8 dereferenceable(20) %1, i64 20, i1 false)
80 %call = call i32 @_Z3zoo1S(%struct.S* nonnull byval(%struct.S) align 8 %agg.tmp)
83 if.end: ; preds = %entry
84 %add = add nsw i32 %count, 1
85 %2 = bitcast %struct.S* %agg.tmp1 to i8*
86 %3 = bitcast %struct.S* %p1 to i8*
87 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 dereferenceable(20) %2, i8* nonnull align 8 dereferenceable(20) %3, i64 20, i1 false)
88 %agg.tmp14.0..sroa_cast = bitcast %struct.S* %agg.tmp14 to i8*
89 call void @llvm.lifetime.start.p0i8(i64 20, i8* nonnull %agg.tmp14.0..sroa_cast)
90 %4 = bitcast %struct.S* %agg.tmp.i to i8*
91 call void @llvm.lifetime.start.p0i8(i64 20, i8* nonnull %4)
92 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 dereferenceable(20) %agg.tmp14.0..sroa_cast, i8* nonnull align 8 dereferenceable(20) %2, i64 20, i1 false)
93 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull align 8 dereferenceable(20) %4, i8* nonnull align 8 dereferenceable(20) %agg.tmp14.0..sroa_cast, i64 20, i1 false)
94 %call.i = call i32 @_Z3fooi1S(i32 %add, %struct.S* nonnull byval(%struct.S) align 8 %agg.tmp.i)
95 call void @llvm.lifetime.end.p0i8(i64 20, i8* nonnull %agg.tmp14.0..sroa_cast)
96 call void @llvm.lifetime.end.p0i8(i64 20, i8* nonnull %4)
99 return: ; preds = %if.end, %if.then
100 %retval.0 = phi i32 [ %call, %if.then ], [ %call.i, %if.end ]
104 declare dso_local i32 @_Z3zoo1S(%struct.S* byval(%struct.S) align 8) local_unnamed_addr #1
106 ; Function Attrs: argmemonly nounwind willreturn
107 declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #2
109 ; Function Attrs: argmemonly nounwind willreturn
110 declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #2
112 ; Function Attrs: argmemonly nounwind willreturn
113 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg) #2
115 attributes #0 = { uwtable }
116 attributes #1 = { uwtable }
117 attributes #2 = { argmemonly nounwind willreturn }