Bump version to 19.1.0-rc3
[llvm-project.git] / llvm / test / Transforms / SimplifyCFG / callbr-destinations.ll
blob89a124ac27dfe466abc316af327f8f9b13607d55
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(
7 ; CHECK-NEXT:  entry:
8 ; CHECK-NEXT:    callbr void asm sideeffect "", "!i"()
9 ; CHECK-NEXT:            to label [[BB:%.*]] [label %bb]
10 ; CHECK:       bb:
11 ; CHECK-NEXT:    ret void
13 entry:
14   callbr void asm sideeffect "", "!i"()
15   to label %bb [label %bb]
17 bb:
18   ret void
21 define void @callbr_can_fold_to_duplicate_dest1() {
22 ; CHECK-LABEL: @callbr_can_fold_to_duplicate_dest1(
23 ; CHECK-NEXT:  entry:
24 ; CHECK-NEXT:    callbr void asm sideeffect "", "!i"()
25 ; CHECK-NEXT:            to label [[COMMON_RET:%.*]] [label %common.ret]
26 ; CHECK:       common.ret:
27 ; CHECK-NEXT:    ret void
29 entry:
30   callbr void asm sideeffect "", "!i"()
31   to label %bb2 [label %bb1]
33 bb1:
34   ret void
36 bb2:
37   ret void
40 define void @callbr_can_fold_to_duplicate_dest2() {
41 ; CHECK-LABEL: @callbr_can_fold_to_duplicate_dest2(
42 ; CHECK-NEXT:  entry:
43 ; CHECK-NEXT:    callbr void asm sideeffect "", "!i,!i"()
44 ; CHECK-NEXT:            to label [[COMMON_RET:%.*]] [label [[COMMON_RET]], label %common.ret]
45 ; CHECK:       common.ret:
46 ; CHECK-NEXT:    ret void
48 entry:
49   callbr void asm sideeffect "", "!i,!i"()
50   to label %bb1 [label %bb2, label %bb3]
52 bb1:
53   ret void
55 bb2:
56   ret void
58 bb3:
59   ret void
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(
66 ; CHECK-NEXT:  entry:
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:%.*]]
72 ; CHECK:       direct:
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]]
78 ; CHECK:       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]]
82 entry:
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)
88   br label %indirect
90 direct:
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)
96   br label %indirect
98 direct2:
99   ret i32 0
101 indirect:
102   %out3 = phi i32 [ %0, %entry.indirect_crit_edge ], [ %1, %direct.indirect_crit_edge ]
103   ret i32 %out3
106 declare i32 @llvm.callbr.landingpad.i32(i32)