1 ; RUN: opt -S -lower-guard-intrinsic < %s | FileCheck %s
2 ; RUN: opt -S -passes='lower-guard-intrinsic' < %s | FileCheck %s
4 declare void @llvm.experimental.guard(i1, ...)
6 define i8 @f_basic(i1* %c_ptr) {
7 ; CHECK-LABEL: @f_basic(
9 %c = load volatile i1, i1* %c_ptr
10 call void(i1, ...) @llvm.experimental.guard(i1 %c, i32 1) [ "deopt"(i32 1) ]
13 ; CHECK: br i1 %c, label %guarded, label %deopt, !prof !0
15 ; CHECK-NEXT: %deoptcall = call i8 (...) @llvm.experimental.deoptimize.i8(i32 1) [ "deopt"(i32 1) ]
16 ; CHECK-NEXT: ret i8 %deoptcall
18 ; CHECK-NEXT: ret i8 5
21 define void @f_void_return_ty(i1* %c_ptr) {
22 ; CHECK-LABEL: @f_void_return_ty(
24 %c = load volatile i1, i1* %c_ptr
25 call void(i1, ...) @llvm.experimental.guard(i1 %c, i32 1) [ "deopt"() ]
28 ; CHECK: br i1 %c, label %guarded, label %deopt, !prof !0
30 ; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid(i32 1) [ "deopt"() ]
31 ; CHECK-NEXT: ret void
33 ; CHECK-NEXT: ret void
36 define void @f_multiple_args(i1* %c_ptr) {
37 ; CHECK-LABEL: @f_multiple_args(
39 %c = load volatile i1, i1* %c_ptr
40 call void(i1, ...) @llvm.experimental.guard(i1 %c, i32 1, i32 2, double 500.0) [ "deopt"(i32 2, i32 3) ]
43 ; CHECK: br i1 %c, label %guarded, label %deopt, !prof !0
45 ; CHECK-NEXT: call void (...) @llvm.experimental.deoptimize.isVoid(i32 1, i32 2, double 5.000000e+02) [ "deopt"(i32 2, i32 3) ]
46 ; CHECK-NEXT: ret void
48 ; CHECK-NEXT: ret void
51 define i32 @f_zero_args(i1* %c_ptr) {
52 ; CHECK-LABEL: @f_zero_args(
53 %c = load volatile i1, i1* %c_ptr
54 call void(i1, ...) @llvm.experimental.guard(i1 %c) [ "deopt"(i32 2, i32 3) ]
57 ; CHECK: br i1 %c, label %guarded, label %deopt, !prof !0
59 ; CHECK-NEXT: %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32() [ "deopt"(i32 2, i32 3) ]
60 ; CHECK-NEXT: ret i32 %deoptcall
62 ; CHECK-NEXT: ret i32 500
65 define i8 @f_with_make_implicit_md(i32* %ptr) {
66 ; CHECK-LABEL: @f_with_make_implicit_md(
67 ; CHECK: br i1 %notNull, label %guarded, label %deopt, !prof !0, !make.implicit !1
69 ; CHECK-NEXT: %deoptcall = call i8 (...) @llvm.experimental.deoptimize.i8(i32 1) [ "deopt"(i32 1) ]
70 ; CHECK-NEXT: ret i8 %deoptcall
72 %notNull = icmp ne i32* %ptr, null
73 call void(i1, ...) @llvm.experimental.guard(i1 %notNull, i32 1) [ "deopt"(i32 1) ], !make.implicit !{}
77 !0 = !{!"branch_weights", i32 1048576, i32 1}