91 lines · plain
1; RUN: opt -S -passes=callsite-splitting -callsite-splitting-duplication-threshold=100000000 < %s | FileCheck -enable-var-scope %s2 3; Noduplicate calls should not be duplicated4; 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 %Top10 11Top:12 %tobool1 = icmp eq ptr %a_elt, null13 br i1 %tobool1, label %CallSiteBB, label %NextCond14 15NextCond:16 %cmp = icmp ne ptr %b_elt, null17 br i1 %cmp, label %CallSiteBB, label %End18 19CallSiteBB:20 %p = phi i1 [ false, %Top ], [ %c, %NextCond ]21 call void @noduplicate_callee(ptr %a_elt, i1 %p)22 br label %End23 24End:25 ret void26}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, null34 br i1 %tobool, label %then, label %endif35 36then:37 br label %endif38 39endif:40 call void @noduplicate_external(ptr %a_elt) #041 ret void42}43 44; Make sure an otherwise identical function is transformed45; 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 %Top51 52Top:53 %tobool1 = icmp eq ptr %a_elt, null54 br i1 %tobool1, label %CallSiteBB, label %NextCond55 56NextCond:57 %cmp = icmp ne ptr %b_elt, null58 br i1 %cmp, label %CallSiteBB, label %End59 60CallSiteBB:61 %p = phi i1 [ false, %Top ], [ %c, %NextCond ]62 call void @nonnoduplicate_callee(ptr %a_elt, i1 %p)63 br label %End64 65End:66 ret void67}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, null75 br i1 %tobool, label %then, label %endif76 77then:78 br label %endif79 80endif:81 call void @nonnoduplicate_external(ptr %a_elt)82 ret void83}84 85declare void @noduplicate_external(ptr) #086declare void @nonnoduplicate_external(ptr) #187 88attributes #0 = { noduplicate nounwind }89attributes #1 = { nounwind }90 91