1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -callsite-splitting -S -o - < %s | FileCheck %s
4 ; Check that we can split the critical edge between Top and CallSiteBB, and
5 ; rewrite the first callbr's indirect destination correctly.
7 define void @caller() {
8 ; CHECK-LABEL: @caller(
10 ; CHECK-NEXT: callbr void asm sideeffect "", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@caller, [[TOP_SPLIT:%.*]]))
11 ; CHECK-NEXT: to label [[NEXTCOND:%.*]] [label %Top.split]
12 ; CHECK-LABEL: Top.split:
13 ; CHECK-NEXT: call void @callee(i1 false)
14 ; CHECK-NEXT: br label [[CALLSITEBB:%.*]]
15 ; CHECK-LABEL: NextCond:
16 ; CHECK-NEXT: br label [[NEXTCOND_SPLIT:%.*]]
17 ; CHECK-LABEL: NextCond.split:
18 ; CHECK-NEXT: call void @callee(i1 true)
19 ; CHECK-NEXT: br label [[CALLSITEBB]]
20 ; CHECK-LABEL: CallSiteBB:
21 ; CHECK-NEXT: [[PHI:%.*]] = phi i1 [ false, [[TOP_SPLIT]] ], [ true, [[NEXTCOND_SPLIT]] ]
22 ; CHECK-NEXT: callbr void asm sideeffect "", "r,X,~{dirflag},~{fpsr},~{flags}"(i1 [[PHI]], i8* blockaddress(@caller, [[END2:%.*]]))
23 ; CHECK-NEXT: to label [[END:%.*]] [label %End2]
25 ; CHECK-NEXT: ret void
27 ; CHECK-NEXT: ret void
30 callbr void asm sideeffect "", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@caller, %CallSiteBB))
31 to label %NextCond [label %CallSiteBB]
37 %phi = phi i1 [0, %Top],[1, %NextCond]
38 call void @callee(i1 %phi)
39 callbr void asm sideeffect "", "r,X,~{dirflag},~{fpsr},~{flags}"(i1 %phi, i8* blockaddress(@caller, %End2))
40 to label %End [label %End2]
48 define void @callee(i1 %b) {
49 ; CHECK-LABEL: @callee(
50 ; CHECK-NEXT: ret void