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