1; RUN: opt -S -always-inline < %s | FileCheck %s
2
3declare void @llvm.experimental.guard(i1, ...)
4
5define i8 @callee(i1* %c_ptr) alwaysinline {
6  %c = load volatile i1, i1* %c_ptr
7  call void(i1, ...) @llvm.experimental.guard(i1 %c, i32 1) [ "deopt"(i32 1) ]
8  ret i8 5
9}
10
11define void @caller_0(i1* %c, i8* %ptr) {
12; CHECK-LABEL: @caller_0(
13entry:
14; CHECK:  [[COND:%[^ ]+]] = load volatile i1, i1* %c
15; CHECK-NEXT:  call void (i1, ...) @llvm.experimental.guard(i1 [[COND]], i32 1) [ "deopt"(i32 2, i32 1) ]
16; CHECK-NEXT:  store i8 5, i8* %ptr
17
18  %v = call i8 @callee(i1* %c)  [ "deopt"(i32 2) ]
19  store i8 %v, i8* %ptr
20  ret void
21}
22
23define i32 @caller_1(i1* %c, i8* %ptr) personality i8 3 {
24; CHECK-LABEL: @caller_1(
25; CHECK:  [[COND:%[^ ]+]] = load volatile i1, i1* %c
26; CHECK-NEXT:  call void (i1, ...) @llvm.experimental.guard(i1 [[COND]], i32 1) [ "deopt"(i32 3, i32 1) ]
27; CHECK-NEXT:  br label %normal
28entry:
29  %v = invoke i8 @callee(i1* %c)  [ "deopt"(i32 3) ] to label %normal
30       unwind label %unwind
31
32unwind:
33  %lp = landingpad i32 cleanup
34  ret i32 43
35
36normal:
37  store i8 %v, i8* %ptr
38  ret i32 42
39}
40