/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Analysis/GuardUtils.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===-- GuardUtils.cpp - Utils for work with guards -------------*- C++ -*-===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | // Utils that are used to perform analyzes related to guards and their |
9 | | // conditions. |
10 | | //===----------------------------------------------------------------------===// |
11 | | |
12 | | #include "llvm/Analysis/GuardUtils.h" |
13 | | #include "llvm/IR/PatternMatch.h" |
14 | | |
15 | | using namespace llvm; |
16 | | |
17 | 43.6M | bool llvm::isGuard(const User *U) { |
18 | 43.6M | using namespace llvm::PatternMatch; |
19 | 43.6M | return match(U, m_Intrinsic<Intrinsic::experimental_guard>()); |
20 | 43.6M | } |
21 | | |
22 | 2.16k | bool llvm::isGuardAsWidenableBranch(const User *U) { |
23 | 2.16k | Value *Condition, *WidenableCondition; |
24 | 2.16k | BasicBlock *GuardedBB, *DeoptBB; |
25 | 2.16k | if (!parseWidenableBranch(U, Condition, WidenableCondition, GuardedBB, |
26 | 2.16k | DeoptBB)) |
27 | 1.77k | return false; |
28 | 398 | using namespace llvm::PatternMatch; |
29 | 398 | for (auto &Insn : *DeoptBB) { |
30 | 398 | if (match(&Insn, m_Intrinsic<Intrinsic::experimental_deoptimize>())) |
31 | 398 | return true; |
32 | 0 | if (Insn.mayHaveSideEffects()) |
33 | 0 | return false; |
34 | 0 | } |
35 | 398 | return false0 ; |
36 | 398 | } |
37 | | |
38 | | bool llvm::parseWidenableBranch(const User *U, Value *&Condition, |
39 | | Value *&WidenableCondition, |
40 | 2.16k | BasicBlock *&IfTrueBB, BasicBlock *&IfFalseBB) { |
41 | 2.16k | using namespace llvm::PatternMatch; |
42 | 2.16k | if (!match(U, m_Br(m_And(m_Value(Condition), m_Value(WidenableCondition)), |
43 | 2.16k | IfTrueBB, IfFalseBB))) |
44 | 1.76k | return false; |
45 | 401 | // TODO: At the moment, we only recognize the branch if the WC call in this |
46 | 401 | // specific position. We should generalize! |
47 | 401 | return match(WidenableCondition, |
48 | 401 | m_Intrinsic<Intrinsic::experimental_widenable_condition>()); |
49 | 401 | } |