LLVM: lib/Analysis/GuardUtils.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
14
15using namespace llvm;
17
19 return match(U, m_IntrinsicIntrinsic::experimental\_guard());
20}
21
23 return match(V, m_IntrinsicIntrinsic::experimental\_widenable\_condition());
24}
25
27 Value *Condition, *WidenableCondition;
30 DeoptBB);
31}
32
35 return false;
36 BasicBlock *DeoptBB = cast(U)->getSuccessor(1);
38 Visited.insert(DeoptBB);
39 do {
40 for (auto &Insn : *DeoptBB) {
41 if (match(&Insn, m_IntrinsicIntrinsic::experimental\_deoptimize()))
42 return true;
43 if (Insn.mayHaveSideEffects())
44 return false;
45 }
46 DeoptBB = DeoptBB->getUniqueSuccessor();
47 if (!DeoptBB)
48 return false;
49 } while (Visited.insert(DeoptBB).second);
50 return false;
51}
52
54 Value *&WidenableCondition,
56
59 if (C)
60 Condition = C->get();
61 else
63 WidenableCondition = WC->get();
64 return true;
65 }
66 return false;
67}
68
71
72 auto *BI = dyn_cast(U);
73 if (!BI || !BI->isConditional())
74 return false;
75 auto *Cond = BI->getCondition();
76 if (->hasOneUse())
77 return false;
78
79 IfTrueBB = BI->getSuccessor(0);
80 IfFalseBB = BI->getSuccessor(1);
81
82 if (match(Cond, m_IntrinsicIntrinsic::experimental\_widenable\_condition())) {
83 WC = &BI->getOperandUse(0);
84 C = nullptr;
85 return true;
86 }
87
88
89
90
91
92
95 return false;
96 auto *And = dyn_cast(Cond);
98
99 return false;
100
101 if (match(A, m_IntrinsicIntrinsic::experimental\_widenable\_condition()) &&
102 A->hasOneUse()) {
103 WC = &And->getOperandUse(0);
104 C = &And->getOperandUse(1);
105 return true;
106 }
107
108 if (match(B, m_IntrinsicIntrinsic::experimental\_widenable\_condition()) &&
109 B->hasOneUse()) {
110 WC = &And->getOperandUse(1);
111 C = &And->getOperandUse(0);
112 return true;
113 }
114 return false;
115}
116
117template
119 CallbackType RecordCheckOrWidenableCond) {
122 Visited.insert(Condition);
123 do {
131 continue;
132 }
133 if (!RecordCheckOrWidenableCond(Check))
134 break;
135 } while (!Worklist.empty());
136}
137
141 Value *Condition = isGuard(U) ? cast(U)->getArgOperand(0)
142 : cast(U)->getCondition();
143
147 return true;
148 });
149}
150
152 auto *BI = dyn_cast(U);
153 if (!BI || !BI->isConditional())
154 return nullptr;
155
156 auto Condition = BI->getCondition();
157 if (!Condition->hasOneUse())
158 return nullptr;
159
160 Value *WidenableCondition = nullptr;
162
163
165 WidenableCondition = Check;
166 return false;
167 }
168 return true;
169 });
170 return WidenableCondition;
171}
SmallVector< AArch64_IMM::ImmInsnModel, 4 > Insn
static void parseCondition(Value *Condition, CallbackType RecordCheckOrWidenableCond)
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Basic Block Representation.
LLVMContext & getContext() const
Get the context in which this basic block lives.
static ConstantInt * getTrue(LLVMContext &Context)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
@ C
The default llvm calling convention, compatible with C.
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
bool match(Val *V, const Pattern &P)
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
This is an optimization pass for GlobalISel generic memory operations.
Value * extractWidenableCondition(const User *U)
void parseWidenableGuard(const User *U, llvm::SmallVectorImpl< Value * > &Checks)
bool isGuard(const User *U)
Returns true iff U has semantics of a guard expressed in a form of call of llvm.experimental....
bool isWidenableCondition(const Value *V)
Returns true iff V has semantics of llvm.experimental.widenable.condition call.
bool parseWidenableBranch(const User *U, Value *&Condition, Value *&WidenableCondition, BasicBlock *&IfTrueBB, BasicBlock *&IfFalseBB)
If U is widenable branch looking like: cond = ... wc = call i1 @llvm.experimental....
bool isWidenableBranch(const User *U)
Returns true iff U is a widenable branch (that is, extractWidenableCondition returns widenable condit...
bool isGuardAsWidenableBranch(const User *U)
Returns true iff U has semantics of a guard expressed in a form of a widenable conditional branch to ...
@ And
Bitwise or logical AND of integers.