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
21
25
27 Value *Condition, *WidenableCondition;
30 DeoptBB);
31}
32
35 return false;
38 Visited.insert(DeoptBB);
39 do {
40 for (auto &Insn : *DeoptBB) {
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
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
83 WC = &BI->getOperandUse(0);
84 C = nullptr;
85 return true;
86 }
87
88
89
90
91
92
95 return false;
98
99 return false;
100
102 A->hasOneUse()) {
103 WC = &And->getOperandUse(0);
104 C = &And->getOperandUse(1);
105 return true;
106 }
107
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
143
147 return true;
148 });
149}
150
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}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static void parseCondition(Value *Condition, CallbackType RecordCheckOrWidenableCond)
Definition GuardUtils.cpp:118
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
const SmallVectorImpl< MachineOperand > & Cond
LLVM Basic Block Representation.
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
static LLVM_ABI 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)
IntrinsicID_match m_Intrinsic()
Match intrinsic calls like this: m_IntrinsicIntrinsic::fabs(m_Value(X))
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
Value * extractWidenableCondition(const User *U)
Definition GuardUtils.cpp:151
void parseWidenableGuard(const User *U, llvm::SmallVectorImpl< Value * > &Checks)
Definition GuardUtils.cpp:138
bool isGuard(const User *U)
Returns true iff U has semantics of a guard expressed in a form of call of llvm.experimental....
Definition GuardUtils.cpp:18
bool isWidenableCondition(const Value *V)
Returns true iff V has semantics of llvm.experimental.widenable.condition call.
Definition GuardUtils.cpp:22
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....
Definition GuardUtils.cpp:53
bool isWidenableBranch(const User *U)
Returns true iff U is a widenable branch (that is, extractWidenableCondition returns widenable condit...
Definition GuardUtils.cpp:26
bool isGuardAsWidenableBranch(const User *U)
Returns true iff U has semantics of a guard expressed in a form of a widenable conditional branch to ...
Definition GuardUtils.cpp:33
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.