1 ; RUN: opt < %s -passes=callsite-splitting -verify-dom-info -S | FileCheck %s
4 ;CHECK-LABEL: Top.split:
5 ;CHECK: %ca1 = musttail call ptr @callee(ptr null, ptr %b)
6 ;CHECK: %cb2 = bitcast ptr %ca1 to ptr
8 ;CHECK-LABEL: TBB.split
9 ;CHECK: %ca3 = musttail call ptr @callee(ptr nonnull %a, ptr null)
10 ;CHECK: %cb4 = bitcast ptr %ca3 to ptr
12 define ptr @caller(ptr %a, ptr %b) {
14 %c = icmp eq ptr %a, null
15 br i1 %c, label %Tail, label %TBB
17 %c2 = icmp eq ptr %b, null
18 br i1 %c2, label %Tail, label %End
20 %ca = musttail call ptr @callee(ptr %a, ptr %b)
21 %cb = bitcast ptr %ca to ptr
27 define ptr @callee(ptr %a, ptr %b) noinline {
31 ;CHECK-LABEL: @no_cast_caller
32 ;CHECK-LABEL: Top.split:
33 ;CHECK: %ca1 = musttail call ptr @callee(ptr null, ptr %b)
35 ;CHECK-LABEL: TBB.split
36 ;CHECK: %ca2 = musttail call ptr @callee(ptr nonnull %a, ptr null)
38 define ptr @no_cast_caller(ptr %a, ptr %b) {
40 %c = icmp eq ptr %a, null
41 br i1 %c, label %Tail, label %TBB
43 %c2 = icmp eq ptr %b, null
44 br i1 %c2, label %Tail, label %End
46 %ca = musttail call ptr @callee(ptr %a, ptr %b)
52 ;CHECK-LABEL: @void_caller
53 ;CHECK-LABEL: Top.split:
54 ;CHECK: musttail call void @void_callee(ptr null, ptr %b)
56 ;CHECK-LABEL: TBB.split
57 ;CHECK: musttail call void @void_callee(ptr nonnull %a, ptr null)
59 define void @void_caller(ptr %a, ptr %b) {
61 %c = icmp eq ptr %a, null
62 br i1 %c, label %Tail, label %TBB
64 %c2 = icmp eq ptr %b, null
65 br i1 %c2, label %Tail, label %End
67 musttail call void @void_callee(ptr %a, ptr %b)
73 define void @void_callee(ptr %a, ptr %b) noinline {
77 ; Include a test with a larger CFG that exercises the DomTreeUpdater
78 ; machinery a bit more.
79 ;CHECK-LABEL: @larger_cfg_caller
80 ;CHECK-LABEL: Top.split:
81 ;CHECK: %r1 = musttail call ptr @callee(ptr null, ptr %b)
83 ;CHECK-LABEL: TBB.split
84 ;CHECK: %r2 = musttail call ptr @callee(ptr nonnull %a, ptr null)
86 define ptr @larger_cfg_caller(ptr %a, ptr %b) {
88 %cond1 = icmp eq ptr %a, null
89 br i1 %cond1, label %Tail, label %ExtraTest
92 %cond2 = icmp eq i8 %a0, 0
93 br i1 %cond2, label %TBB_pred, label %End
97 %cond3 = icmp eq ptr %b, null
98 br i1 %cond3, label %Tail, label %End
100 %r = musttail call ptr @callee(ptr %a, ptr %b)