1; RUN: opt -S -passes=callsite-splitting -callsite-splitting-duplication-threshold=100000000 < %s | FileCheck -enable-var-scope %s 2 3; Noduplicate calls should not be duplicated 4; CHECK-LABEL: define void @noduplicate_caller( 5; CHECK: call void @noduplicate_callee( 6; CHECK-NOT: call void @noduplicate_callee( 7define void @noduplicate_caller(i1 %c, ptr %a_elt, ptr %b_elt) #0 { 8entry: 9 br label %Top 10 11Top: 12 %tobool1 = icmp eq ptr %a_elt, null 13 br i1 %tobool1, label %CallSiteBB, label %NextCond 14 15NextCond: 16 %cmp = icmp ne ptr %b_elt, null 17 br i1 %cmp, label %CallSiteBB, label %End 18 19CallSiteBB: 20 %p = phi i1 [ false, %Top ], [ %c, %NextCond ] 21 call void @noduplicate_callee(ptr %a_elt, i1 %p) 22 br label %End 23 24End: 25 ret void 26} 27 28; CHECK-LABEL: define void @noduplicate_callee( 29; CHECK: call void @noduplicate_external( 30; CHECK-NOT: call void @noduplicate_external( 31define void @noduplicate_callee(ptr %a_elt, i1 %c) #0 { 32entry: 33 %tobool = icmp ne ptr %a_elt, null 34 br i1 %tobool, label %then, label %endif 35 36then: 37 br label %endif 38 39endif: 40 call void @noduplicate_external(ptr %a_elt) #0 41 ret void 42} 43 44; Make sure an otherwise identical function is transformed 45; CHECK-LABEL: define void @reference_caller( 46; CHECK: call void @nonnoduplicate_callee( 47; CHECK: call void @nonnoduplicate_callee( 48define void @reference_caller(i1 %c, ptr %a_elt, ptr %b_elt) #1 { 49entry: 50 br label %Top 51 52Top: 53 %tobool1 = icmp eq ptr %a_elt, null 54 br i1 %tobool1, label %CallSiteBB, label %NextCond 55 56NextCond: 57 %cmp = icmp ne ptr %b_elt, null 58 br i1 %cmp, label %CallSiteBB, label %End 59 60CallSiteBB: 61 %p = phi i1 [ false, %Top ], [ %c, %NextCond ] 62 call void @nonnoduplicate_callee(ptr %a_elt, i1 %p) 63 br label %End 64 65End: 66 ret void 67} 68 69; CHECK-LABEL: define void @nonnoduplicate_callee( 70; CHECK: call void @nonnoduplicate_external( 71; CHECK-NOT: call void @nonnoduplicate_external( 72define void @nonnoduplicate_callee(ptr %a_elt, i1 %c) #1 { 73entry: 74 %tobool = icmp ne ptr %a_elt, null 75 br i1 %tobool, label %then, label %endif 76 77then: 78 br label %endif 79 80endif: 81 call void @nonnoduplicate_external(ptr %a_elt) 82 ret void 83} 84 85declare void @noduplicate_external(ptr) #0 86declare void @nonnoduplicate_external(ptr) #1 87 88attributes #0 = { noduplicate nounwind } 89attributes #1 = { nounwind } 90 91