mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-13 23:18:51 +00:00
de765686f8
Summary: As discussed on llvm-dev[1]. This change adds the basic boilerplate code around having this intrinsic in LLVM: - Changes in Intrinsics.td, and the IR Verifier - A lowering pass to lower @llvm.experimental.guard to normal control flow - Inliner support [1]: http://lists.llvm.org/pipermail/llvm-dev/2016-February/095523.html Reviewers: reames, atrick, chandlerc, rnk, JosephTremoulet, echristo Subscribers: mcrosier, llvm-commits Differential Revision: http://reviews.llvm.org/D18527 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264976 91177308-0d34-0410-b5e6-96231b3b80d8
40 lines
1.1 KiB
LLVM
40 lines
1.1 KiB
LLVM
; RUN: opt -S -always-inline < %s | FileCheck %s
|
|
|
|
declare void @llvm.experimental.guard(i1, ...)
|
|
|
|
define i8 @callee(i1* %c_ptr) alwaysinline {
|
|
%c = load volatile i1, i1* %c_ptr
|
|
call void(i1, ...) @llvm.experimental.guard(i1 %c, i32 1) [ "deopt"(i32 1) ]
|
|
ret i8 5
|
|
}
|
|
|
|
define void @caller_0(i1* %c, i8* %ptr) {
|
|
; CHECK-LABEL: @caller_0(
|
|
entry:
|
|
; CHECK: [[COND:%[^ ]+]] = load volatile i1, i1* %c
|
|
; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[COND]], i32 1) [ "deopt"(i32 2, i32 1) ]
|
|
; CHECK-NEXT: store i8 5, i8* %ptr
|
|
|
|
%v = call i8 @callee(i1* %c) [ "deopt"(i32 2) ]
|
|
store i8 %v, i8* %ptr
|
|
ret void
|
|
}
|
|
|
|
define i32 @caller_1(i1* %c, i8* %ptr) personality i8 3 {
|
|
; CHECK-LABEL: @caller_1(
|
|
; CHECK: [[COND:%[^ ]+]] = load volatile i1, i1* %c
|
|
; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 [[COND]], i32 1) [ "deopt"(i32 3, i32 1) ]
|
|
; CHECK-NEXT: br label %normal
|
|
entry:
|
|
%v = invoke i8 @callee(i1* %c) [ "deopt"(i32 3) ] to label %normal
|
|
unwind label %unwind
|
|
|
|
unwind:
|
|
%lp = landingpad i32 cleanup
|
|
ret i32 43
|
|
|
|
normal:
|
|
store i8 %v, i8* %ptr
|
|
ret i32 42
|
|
}
|