1 ; RUN: not opt -S %s -passes=verify 2>&1 | FileCheck %s
3 ; CHECK: Number of label constraints does not match number of callbr dests
4 ; CHECK-NEXT: #too_few_label_constraints
5 define void @too_few_label_constraints() {
6 callbr void asm sideeffect "#too_few_label_constraints", "!i"()
7 to label %1 [label %2, label %3]
16 ; CHECK-NOT: Number of label constraints does not match number of callbr dests
17 define void @correct_label_constraints() {
18 callbr void asm sideeffect "${0:l} ${1:l}", "!i,!i"()
19 to label %1 [label %2, label %3]
28 ; CHECK: Number of label constraints does not match number of callbr dests
29 ; CHECK-NEXT: #too_many_label_constraints
30 define void @too_many_label_constraints() {
31 callbr void asm sideeffect "#too_many_label_constraints", "!i,!i,!i"()
32 to label %1 [label %2, label %3]
41 ; CHECK: Label constraints can only be used with callbr
42 ; CHECK-NEXT: #label_constraint_without_callbr
43 define void @label_constraint_without_callbr() {
44 call void asm sideeffect "#label_constraint_without_callbr", "!i"()
48 ; CHECK: Number of label constraints does not match number of callbr dests
49 ; CHECK-NEXT: #callbr_without_label_constraint
50 define void @callbr_without_label_constraint() {
51 callbr void asm sideeffect "#callbr_without_label_constraint", ""()
52 to label %1 [label %2]
59 ;; Ensure you can use the return value of a callbr in indirect targets.
61 define i32 @test4(i1 %var) {
63 %ret = callbr i32 asm sideeffect "#test4", "=r,!i"() to label %normal [label %abnormal]
72 ;; Tests of the callbr.landingpad intrinsic function.
73 declare i32 @llvm.callbr.landingpad.i64(i64)
74 define void @callbrpad_bad_type() {
76 ; CHECK: Intrinsic has incorrect argument type!
77 ; CHECK-NEXT: ptr @llvm.callbr.landingpad.i64
78 %foo = call i32 @llvm.callbr.landingpad.i64(i64 42)
82 declare i32 @llvm.callbr.landingpad.i32(i32)
83 define i32 @callbrpad_multi_preds() {
85 %foo = callbr i32 asm "", "=r,!i"() to label %direct [label %indirect]
89 ; CHECK-NEXT: Intrinsic in block must have 1 unique predecessor
90 ; CHECK-NEXT: %out = call i32 @llvm.callbr.landingpad.i32(i32 %foo)
91 %out = call i32 @llvm.callbr.landingpad.i32(i32 %foo)
95 define void @callbrpad_wrong_callbr() {
97 %foo = callbr i32 asm "", "=r,!i"() to label %direct [label %indirect]
99 ; CHECK-NEXT: Intrinsic's corresponding callbr must have intrinsic's parent basic block in indirect destination list
100 ; CHECK-NEXT: %x = call i32 @llvm.callbr.landingpad.i32(i32 %foo)
101 %x = call i32 @llvm.callbr.landingpad.i32(i32 %foo)
107 declare i32 @foo(i32)
108 define i32 @test_callbr_landingpad_not_first_inst() {
110 %0 = callbr i32 asm "", "=r,!i"()
111 to label %asm.fallthrough [label %landingpad]
117 %foo = call i32 @foo(i32 42)
118 ; CHECK-NEXT: No other instructions may proceed intrinsic
119 ; CHECK-NEXT: %out = call i32 @llvm.callbr.landingpad.i32(i32 %0)
120 %out = call i32 @llvm.callbr.landingpad.i32(i32 %0)