1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -S -passes="simplifycfg<sink-common-insts>" \
3 ; RUN: -simplifycfg-require-and-preserve-domtree=1 | FileCheck %s
5 define void @callbr_duplicate_dest() {
6 ; CHECK-LABEL: @callbr_duplicate_dest(
8 ; CHECK-NEXT: callbr void asm sideeffect "", "!i"()
9 ; CHECK-NEXT: to label [[BB:%.*]] [label %bb]
11 ; CHECK-NEXT: ret void
14 callbr void asm sideeffect "", "!i"()
15 to label %bb [label %bb]
21 define void @callbr_can_fold_to_duplicate_dest1() {
22 ; CHECK-LABEL: @callbr_can_fold_to_duplicate_dest1(
24 ; CHECK-NEXT: callbr void asm sideeffect "", "!i"()
25 ; CHECK-NEXT: to label [[COMMON_RET:%.*]] [label %common.ret]
27 ; CHECK-NEXT: ret void
30 callbr void asm sideeffect "", "!i"()
31 to label %bb2 [label %bb1]
40 define void @callbr_can_fold_to_duplicate_dest2() {
41 ; CHECK-LABEL: @callbr_can_fold_to_duplicate_dest2(
43 ; CHECK-NEXT: callbr void asm sideeffect "", "!i,!i"()
44 ; CHECK-NEXT: to label [[COMMON_RET:%.*]] [label [[COMMON_RET]], label %common.ret]
46 ; CHECK-NEXT: ret void
49 callbr void asm sideeffect "", "!i,!i"()
50 to label %bb1 [label %bb2, label %bb3]
62 ; Validate that callbr landingpad intrinsics do not get merged (via the
63 ; IntrNoMerge attribute).
64 define i32 @callbr_landingpad_nomerge() {
65 ; CHECK-LABEL: @callbr_landingpad_nomerge(
67 ; CHECK-NEXT: [[OUT:%.*]] = callbr i32 asm "# $0", "=r,!i"()
68 ; CHECK-NEXT: to label [[DIRECT:%.*]] [label %entry.indirect_crit_edge]
69 ; CHECK: entry.indirect_crit_edge:
70 ; CHECK-NEXT: [[TMP0:%.*]] = call i32 @llvm.callbr.landingpad.i32(i32 [[OUT]])
71 ; CHECK-NEXT: br label [[COMMON_RET:%.*]]
73 ; CHECK-NEXT: [[OUT2:%.*]] = callbr i32 asm "# $0", "=r,!i"()
74 ; CHECK-NEXT: to label [[COMMON_RET]] [label %direct.indirect_crit_edge]
75 ; CHECK: direct.indirect_crit_edge:
76 ; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.callbr.landingpad.i32(i32 [[OUT2]])
77 ; CHECK-NEXT: br label [[COMMON_RET]]
79 ; CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi i32 [ 0, [[DIRECT]] ], [ [[TMP0]], [[ENTRY_INDIRECT_CRIT_EDGE:%.*]] ], [ [[TMP1]], [[DIRECT_INDIRECT_CRIT_EDGE:%.*]] ]
80 ; CHECK-NEXT: ret i32 [[COMMON_RET_OP]]
83 %out = callbr i32 asm "# $0", "=r,!i"()
84 to label %direct [label %entry.indirect_crit_edge]
86 entry.indirect_crit_edge:
87 %0 = call i32 @llvm.callbr.landingpad.i32(i32 %out)
91 %out2 = callbr i32 asm "# $0", "=r,!i"()
92 to label %direct2 [label %direct.indirect_crit_edge]
94 direct.indirect_crit_edge:
95 %1 = call i32 @llvm.callbr.landingpad.i32(i32 %out2)
102 %out3 = phi i32 [ %0, %entry.indirect_crit_edge ], [ %1, %direct.indirect_crit_edge ]
106 declare i32 @llvm.callbr.landingpad.i32(i32)