1; RUN: opt -S -callsite-splitting -callsite-splitting-duplication-threshold=100000000 < %s | FileCheck -enable-var-scope %s 2 3; Convergent calls should not be duplicated in this case 4; CHECK-LABEL: define void @convergent_caller( 5; CHECK: call void @convergent_callee( 6; CHECK-NOT: call void @convergent_callee( 7define void @convergent_caller(i1 %c, i8* %a_elt, i8* %b_elt) #0 { 8entry: 9 br label %Top 10 11Top: 12 %tobool1 = icmp eq i8* %a_elt, null 13 br i1 %tobool1, label %CallSiteBB, label %NextCond 14 15NextCond: 16 %cmp = icmp ne i8* %b_elt, null 17 br i1 %cmp, label %CallSiteBB, label %End 18 19CallSiteBB: 20 %p = phi i1 [ false, %Top ], [ %c, %NextCond ] 21 call void @convergent_callee(i8* %a_elt, i1 %p) 22 br label %End 23 24End: 25 ret void 26} 27 28; CHECK-LABEL: define void @convergent_callee( 29; CHECK: call void @convergent_external( 30; CHECK-NOT: call void @convergent_external( 31define void @convergent_callee(i8* %a_elt, i1 %c) #0 { 32entry: 33 %tobool = icmp ne i8* %a_elt, null 34 br i1 %tobool, label %then, label %endif 35 36then: 37 br label %endif 38 39endif: 40 call void @convergent_external(i8* %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 @nonconvergent_callee( 47; CHECK: call void @nonconvergent_callee( 48define void @reference_caller(i1 %c, i8* %a_elt, i8* %b_elt) #1 { 49entry: 50 br label %Top 51 52Top: 53 %tobool1 = icmp eq i8* %a_elt, null 54 br i1 %tobool1, label %CallSiteBB, label %NextCond 55 56NextCond: 57 %cmp = icmp ne i8* %b_elt, null 58 br i1 %cmp, label %CallSiteBB, label %End 59 60CallSiteBB: 61 %p = phi i1 [ false, %Top ], [ %c, %NextCond ] 62 call void @nonconvergent_callee(i8* %a_elt, i1 %p) 63 br label %End 64 65End: 66 ret void 67} 68 69; CHECK-LABEL: define void @nonconvergent_callee( 70; CHECK: call void @nonconvergent_external( 71; CHECK-NOT: call void @nonconvergent_external( 72define void @nonconvergent_callee(i8* %a_elt, i1 %c) #1 { 73entry: 74 %tobool = icmp ne i8* %a_elt, null 75 br i1 %tobool, label %then, label %endif 76 77then: 78 br label %endif 79 80endif: 81 call void @nonconvergent_external(i8* %a_elt) 82 ret void 83} 84 85declare void @convergent_external(i8*) #0 86declare void @nonconvergent_external(i8*) #1 87 88attributes #0 = { convergent nounwind } 89attributes #1 = { nounwind } 90