1 ; RUN: opt -S -callsite-splitting -callsite-splitting-duplication-threshold=100000000 < %s | FileCheck -enable-var-scope %s
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(
7 define void @convergent_caller(i1 %c, i8* %a_elt, i8* %b_elt) #0 {
12 %tobool1 = icmp eq i8* %a_elt, null
13 br i1 %tobool1, label %CallSiteBB, label %NextCond
16 %cmp = icmp ne i8* %b_elt, null
17 br i1 %cmp, label %CallSiteBB, label %End
20 %p = phi i1 [ false, %Top ], [ %c, %NextCond ]
21 call void @convergent_callee(i8* %a_elt, i1 %p)
28 ; CHECK-LABEL: define void @convergent_callee(
29 ; CHECK: call void @convergent_external(
30 ; CHECK-NOT: call void @convergent_external(
31 define void @convergent_callee(i8* %a_elt, i1 %c) #0 {
33 %tobool = icmp ne i8* %a_elt, null
34 br i1 %tobool, label %then, label %endif
40 call void @convergent_external(i8* %a_elt) #0
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(
48 define void @reference_caller(i1 %c, i8* %a_elt, i8* %b_elt) #1 {
53 %tobool1 = icmp eq i8* %a_elt, null
54 br i1 %tobool1, label %CallSiteBB, label %NextCond
57 %cmp = icmp ne i8* %b_elt, null
58 br i1 %cmp, label %CallSiteBB, label %End
61 %p = phi i1 [ false, %Top ], [ %c, %NextCond ]
62 call void @nonconvergent_callee(i8* %a_elt, i1 %p)
69 ; CHECK-LABEL: define void @nonconvergent_callee(
70 ; CHECK: call void @nonconvergent_external(
71 ; CHECK-NOT: call void @nonconvergent_external(
72 define void @nonconvergent_callee(i8* %a_elt, i1 %c) #1 {
74 %tobool = icmp ne i8* %a_elt, null
75 br i1 %tobool, label %then, label %endif
81 call void @nonconvergent_external(i8* %a_elt)
85 declare void @convergent_external(i8*) #0
86 declare void @nonconvergent_external(i8*) #1
88 attributes #0 = { convergent nounwind }
89 attributes #1 = { nounwind }