• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -lower-guard-intrinsic < %s | FileCheck %s
2
3declare void @llvm.experimental.guard(i1, ...)
4
5define i8 @f_basic(i1* %c_ptr) {
6; CHECK-LABEL: @f_basic(
7
8  %c = load volatile i1, i1* %c_ptr
9  call void(i1, ...) @llvm.experimental.guard(i1 %c, i32 1) [ "deopt"(i32 1) ]
10  ret i8 5
11
12; CHECK:  br i1 %c, label %guarded, label %deopt, !prof !0
13; CHECK: deopt:
14; CHECK-NEXT:  %deoptcall = call i8 (...) @llvm.experimental.deoptimize.i8(i32 1) [ "deopt"(i32 1) ]
15; CHECK-NEXT:  ret i8 %deoptcall
16; CHECK: guarded:
17; CHECK-NEXT:  ret i8 5
18}
19
20define void @f_void_return_ty(i1* %c_ptr) {
21; CHECK-LABEL: @f_void_return_ty(
22
23  %c = load volatile i1, i1* %c_ptr
24  call void(i1, ...) @llvm.experimental.guard(i1 %c, i32 1) [ "deopt"() ]
25  ret void
26
27; CHECK:  br i1 %c, label %guarded, label %deopt, !prof !0
28; CHECK: deopt:
29; CHECK-NEXT:  call void (...) @llvm.experimental.deoptimize.isVoid(i32 1) [ "deopt"() ]
30; CHECK-NEXT:  ret void
31; CHECK: guarded:
32; CHECK-NEXT:  ret void
33}
34
35define void @f_multiple_args(i1* %c_ptr) {
36; CHECK-LABEL: @f_multiple_args(
37
38  %c = load volatile i1, i1* %c_ptr
39  call void(i1, ...) @llvm.experimental.guard(i1 %c, i32 1, i32 2, double 500.0) [ "deopt"(i32 2, i32 3) ]
40  ret void
41
42; CHECK: br i1 %c, label %guarded, label %deopt, !prof !0
43; CHECK: deopt:
44; CHECK-NEXT:  call void (...) @llvm.experimental.deoptimize.isVoid(i32 1, i32 2, double 5.000000e+02) [ "deopt"(i32 2, i32 3) ]
45; CHECK-NEXT:  ret void
46; CHECK: guarded:
47; CHECK-NEXT:  ret void
48}
49
50define i32 @f_zero_args(i1* %c_ptr) {
51; CHECK-LABEL: @f_zero_args(
52  %c = load volatile i1, i1* %c_ptr
53  call void(i1, ...) @llvm.experimental.guard(i1 %c) [ "deopt"(i32 2, i32 3) ]
54  ret i32 500
55
56; CHECK: br i1 %c, label %guarded, label %deopt, !prof !0
57; CHECK: deopt:
58; CHECK-NEXT:  %deoptcall = call i32 (...) @llvm.experimental.deoptimize.i32() [ "deopt"(i32 2, i32 3) ]
59; CHECK-NEXT:  ret i32 %deoptcall
60; CHECK: guarded:
61; CHECK-NEXT:  ret i32 500
62}
63
64define i8 @f_with_make_implicit_md(i32* %ptr) {
65; CHECK-LABEL: @f_with_make_implicit_md(
66; CHECK:  br i1 %notNull, label %guarded, label %deopt, !prof !0, !make.implicit !1
67; CHECK: deopt:
68; CHECK-NEXT:  %deoptcall = call i8 (...) @llvm.experimental.deoptimize.i8(i32 1) [ "deopt"(i32 1) ]
69; CHECK-NEXT:  ret i8 %deoptcall
70
71  %notNull = icmp ne i32* %ptr, null
72  call void(i1, ...) @llvm.experimental.guard(i1 %notNull, i32 1) [ "deopt"(i32 1) ], !make.implicit !{}
73  ret i8 5
74}
75
76!0 = !{!"branch_weights", i32 1048576, i32 1}
77