LLVM 24.0.0git
PHITransAddr.cpp
Go to the documentation of this file.
1//===- PHITransAddr.cpp - PHI Translation for Addresses -------------------===//
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//
9// This file implements the PHITransAddr class.
10//
11//===----------------------------------------------------------------------===//
12
14#include "AnalysisOptions.h"
17#include "llvm/Config/llvm-config.h"
18#include "llvm/IR/Constants.h"
19#include "llvm/IR/Dominators.h"
23using namespace llvm;
24
25static bool canPHITrans(Instruction *Inst) {
26 if (isa<PHINode>(Inst) || isa<GetElementPtrInst>(Inst) || isa<CastInst>(Inst))
27 return true;
28
29 if (Inst->getOpcode() == Instruction::Add &&
31 return true;
32
33 return false;
34}
35
36#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
38 if (!Addr) {
39 dbgs() << "PHITransAddr: null\n";
40 return;
41 }
42 dbgs() << "PHITransAddr: " << *Addr << "\n";
43 for (unsigned i = 0, e = InstInputs.size(); i != e; ++i)
44 dbgs() << " Input #" << i << " is " << *InstInputs[i] << "\n";
45}
46#endif
47
48static bool verifySubExpr(Value *Expr,
50 // If this is a non-instruction value, there is nothing to do.
52 if (!I) return true;
53
54 // If it's an instruction, it is either in Tmp or its operands recursively
55 // are.
56 if (auto Entry = find(InstInputs, I); Entry != InstInputs.end()) {
57 InstInputs.erase(Entry);
58 return true;
59 }
60
61 // If it isn't in the InstInputs list it is a subexpr incorporated into the
62 // address. Validate that it is phi translatable.
63 if (!canPHITrans(I)) {
64 errs() << "Instruction in PHITransAddr is not phi-translatable:\n";
65 errs() << *I << '\n';
66 llvm_unreachable("Either something is missing from InstInputs or "
67 "canPHITrans is wrong.");
68 }
69
70 // Validate the operands of the instruction.
71 return all_of(I->operands(),
72 [&](Value *Op) { return verifySubExpr(Op, InstInputs); });
73}
74
75/// verify - Check internal consistency of this data structure. If the
76/// structure is valid, it returns true. If invalid, it prints errors and
77/// returns false.
79 if (!Addr) return true;
80
81 SmallVector<Instruction*, 8> Tmp(InstInputs.begin(), InstInputs.end());
82
83 if (!verifySubExpr(Addr, Tmp))
84 return false;
85
86 if (!Tmp.empty()) {
87 errs() << "PHITransAddr contains extra instructions:\n";
88 for (unsigned i = 0, e = InstInputs.size(); i != e; ++i)
89 errs() << " InstInput #" << i << " is " << *InstInputs[i] << "\n";
90 llvm_unreachable("This is unexpected.");
91 }
92
93 // a-ok.
94 return true;
95}
96
97/// isPotentiallyPHITranslatable - If this needs PHI translation, return true
98/// if we have some hope of doing it. This should be used as a filter to
99/// avoid calling PHITranslateValue in hopeless situations.
101 // If the input value is not an instruction, or if it is not defined in CurBB,
102 // then we don't need to phi translate it.
104 return !Inst || canPHITrans(Inst);
105}
106
107static void RemoveInstInputs(Value *V,
108 SmallVectorImpl<Instruction*> &InstInputs) {
110 if (!I) return;
111
112 // If the instruction is in the InstInputs list, remove it.
113 if (auto Entry = find(InstInputs, I); Entry != InstInputs.end()) {
114 InstInputs.erase(Entry);
115 return;
116 }
117
118 assert(!isa<PHINode>(I) && "Error, removing something that isn't an input");
119
120 // Otherwise, it must have instruction inputs itself. Zap them recursively.
121 for (Value *Op : I->operands())
122 if (Instruction *OpInst = dyn_cast<Instruction>(Op))
123 RemoveInstInputs(OpInst, InstInputs);
124}
125
126Value *PHITransAddr::translateSubExpr(Value *V, BasicBlock *CurBB,
127 BasicBlock *PredBB,
128 const DominatorTree *DT, Value *Cond,
129 bool CondVal) {
130 // If this is a non-instruction value, it can't require PHI translation.
132 if (!Inst) return V;
133
134 // Determine whether 'Inst' is an input to our PHI translatable expression.
135 bool isInput = is_contained(InstInputs, Inst);
136
137 // Handle inputs instructions if needed.
138 if (isInput) {
139 if (Inst->getParent() != CurBB) {
140 // If it is an input defined in a different block, then it remains an
141 // input.
142 return Inst;
143 }
144
145 // If 'Inst' is defined in this block and is an input that needs to be phi
146 // translated, we need to incorporate the value into the expression or fail.
147
148 // In either case, the instruction itself isn't an input any longer.
149 InstInputs.erase(find(InstInputs, Inst));
150
151 // If this is a PHI, go ahead and translate it.
152 if (PHINode *PN = dyn_cast<PHINode>(Inst)) {
153 Value *Incoming = PN->getIncomingValueForBlock(PredBB);
154 // If the incoming value on this edge is a select on the condition we are
155 // resolving, fold it to the requested side. This is what lets us obtain
156 // the two distinct addresses referenced by a select-dependent load along
157 // a backedge (e.g. min/max idioms).
158 if (Cond)
159 if (auto *SI = dyn_cast<SelectInst>(Incoming))
160 if (SI->getCondition() == Cond)
161 return addAsInput(CondVal ? SI->getTrueValue()
162 : SI->getFalseValue());
163 return addAsInput(Incoming);
164 }
165
166 // If this is a non-phi value, and it is analyzable, we can incorporate it
167 // into the expression by making all instruction operands be inputs.
168 if (!canPHITrans(Inst))
169 return nullptr;
170
171 // All instruction operands are now inputs (and of course, they may also be
172 // defined in this block, so they may need to be phi translated themselves.
173 for (Value *Op : Inst->operands())
174 addAsInput(Op);
175 }
176
177 // Ok, it must be an intermediate result (either because it started that way
178 // or because we just incorporated it into the expression). See if its
179 // operands need to be phi translated, and if so, reconstruct it.
180
181 if (CastInst *Cast = dyn_cast<CastInst>(Inst)) {
182 Value *PHIIn =
183 translateSubExpr(Cast->getOperand(0), CurBB, PredBB, DT, Cond, CondVal);
184 if (!PHIIn) return nullptr;
185 if (PHIIn == Cast->getOperand(0))
186 return Cast;
187
188 // Find an available version of this cast.
189
190 // Try to simplify cast first.
191 if (Value *V = simplifyCastInst(Cast->getOpcode(), PHIIn, Cast->getType(),
192 {DL, TLI, DT, AC})) {
193 RemoveInstInputs(PHIIn, InstInputs);
194 return addAsInput(V);
195 }
196
197 // Otherwise we have to see if a casted version of the incoming pointer
198 // is available. If so, we can use it, otherwise we have to fail. Don't
199 // scan the use list of a constant: ConstantData has no use list, and
200 // other constants may be used from different functions, whose blocks are
201 // not in this function's DominatorTree.
202 if (!isa<Constant>(PHIIn)) {
203 for (User *U : PHIIn->users()) {
204 if (CastInst *CastI = dyn_cast<CastInst>(U))
205 if (CastI->getOpcode() == Cast->getOpcode() &&
206 CastI->getType() == Cast->getType() &&
207 (!DT || DT->dominates(CastI->getParent(), PredBB)))
208 return CastI;
209 }
210 }
211 return nullptr;
212 }
213
214 // Handle getelementptr with at least one PHI translatable operand.
215 if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
216 SmallVector<Value*, 8> GEPOps;
217 bool AnyChanged = false;
218 for (Value *Op : GEP->operands()) {
219 Value *GEPOp = translateSubExpr(Op, CurBB, PredBB, DT, Cond, CondVal);
220 if (!GEPOp) return nullptr;
221
222 AnyChanged |= GEPOp != Op;
223 GEPOps.push_back(GEPOp);
224 }
225
226 if (!AnyChanged)
227 return GEP;
228
229 // Simplify the GEP to handle 'gep x, 0' -> x etc.
230 if (Value *V = simplifyGEPInst(GEP->getSourceElementType(), GEPOps[0],
231 ArrayRef<Value *>(GEPOps).slice(1),
232 GEP->getNoWrapFlags(), {DL, TLI, DT, AC})) {
233 for (Value *Op : GEPOps)
234 RemoveInstInputs(Op, InstInputs);
235
236 return addAsInput(V);
237 }
238
239 // Scan to see if we have this GEP available.
240 Value *APHIOp = GEPOps[0];
241 if (isa<ConstantData>(APHIOp))
242 return nullptr;
243
244 for (User *U : APHIOp->users()) {
245 if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(U))
246 if (GEPI->getType() == GEP->getType() &&
247 GEPI->getSourceElementType() == GEP->getSourceElementType() &&
248 GEPI->getNumOperands() == GEPOps.size() &&
249 GEPI->getParent()->getParent() == CurBB->getParent() &&
250 (!DT || DT->dominates(GEPI->getParent(), PredBB))) {
251 if (std::equal(GEPOps.begin(), GEPOps.end(), GEPI->op_begin()))
252 return GEPI;
253 }
254 }
255 return nullptr;
256 }
257
258 // Handle add with a constant RHS.
259 if (Inst->getOpcode() == Instruction::Add &&
260 isa<ConstantInt>(Inst->getOperand(1))) {
261 // PHI translate the LHS.
263 bool isNSW = cast<BinaryOperator>(Inst)->hasNoSignedWrap();
264 bool isNUW = cast<BinaryOperator>(Inst)->hasNoUnsignedWrap();
265
266 Value *LHS =
267 translateSubExpr(Inst->getOperand(0), CurBB, PredBB, DT, Cond, CondVal);
268 if (!LHS) return nullptr;
269
270 // If the PHI translated LHS is an add of a constant, fold the immediates.
271 if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(LHS))
272 if (BOp->getOpcode() == Instruction::Add)
273 if (ConstantInt *CI = dyn_cast<ConstantInt>(BOp->getOperand(1))) {
274 LHS = BOp->getOperand(0);
276 isNSW = isNUW = false;
277
278 // If the old 'LHS' was an input, add the new 'LHS' as an input.
279 if (is_contained(InstInputs, BOp)) {
280 RemoveInstInputs(BOp, InstInputs);
281 addAsInput(LHS);
282 }
283 }
284
285 // See if the add simplifies away.
286 if (Value *Res = simplifyAddInst(LHS, RHS, isNSW, isNUW, {DL, TLI, DT, AC})) {
287 // If we simplified the operands, the LHS is no longer an input, but Res
288 // is.
289 RemoveInstInputs(LHS, InstInputs);
290 return addAsInput(Res);
291 }
292
293 // If we didn't modify the add, just return it.
294 if (LHS == Inst->getOperand(0) && RHS == Inst->getOperand(1))
295 return Inst;
296
297 // Otherwise, see if we have this add available somewhere.
298 for (User *U : LHS->users()) {
299 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(U))
300 if (BO->getOpcode() == Instruction::Add &&
301 BO->getOperand(0) == LHS && BO->getOperand(1) == RHS &&
302 BO->getParent()->getParent() == CurBB->getParent() &&
303 (!DT || DT->dominates(BO->getParent(), PredBB)))
304 return BO;
305 }
306
307 return nullptr;
308 }
309
310 // Otherwise, we failed.
311 return nullptr;
312}
313
314/// PHITranslateValue - PHI translate the current address up the CFG from
315/// CurBB to Pred, updating our state to reflect any needed changes. If
316/// 'MustDominate' is true, the translated value must dominate PredBB.
318 const DominatorTree *DT,
319 bool MustDominate) {
320 assert(DT || !MustDominate);
321 assert(verify() && "Invalid PHITransAddr!");
322 if (DT && DT->isReachableFromEntry(PredBB))
323 Addr = translateSubExpr(Addr, CurBB, PredBB, DT);
324 else
325 Addr = nullptr;
326 assert(verify() && "Invalid PHITransAddr!");
327
328 if (MustDominate)
329 // Make sure the value is live in the predecessor.
331 if (!DT->dominates(Inst->getParent(), PredBB))
332 Addr = nullptr;
333
334 return Addr;
335}
336
338 BasicBlock *PredBB,
339 const DominatorTree *DT,
340 Value *Cond) {
341 assert(Cond && "expected a non-null select condition");
342 assert(verify() && "Invalid PHITransAddr!");
343
344 if (!DT || !DT->isReachableFromEntry(PredBB))
345 return {nullptr, nullptr};
346
347 auto TranslateSide = [&](bool CondVal) -> Value * {
348 // Work on a copy so that the original address state is preserved and the
349 // other side can be translated independently.
350 PHITransAddr Tmp(*this);
351 return Tmp.translateSubExpr(Tmp.Addr, CurBB, PredBB, DT, Cond, CondVal);
352 };
353
354 return {TranslateSide(/*CondVal=*/true), TranslateSide(/*CondVal=*/false)};
355}
356
358 for (Instruction *I : InstInputs)
359 if (auto *SI = dyn_cast<SelectInst>(I))
360 return SI;
361 return nullptr;
362}
363
364/// PHITranslateWithInsertion - PHI translate this value into the specified
365/// predecessor block, inserting a computation of the value if it is
366/// unavailable.
367///
368/// All newly created instructions are added to the NewInsts list. This
369/// returns null on failure.
370///
371Value *
373 const DominatorTree &DT,
375 unsigned NISize = NewInsts.size();
376
377 // Attempt to PHI translate with insertion.
378 Addr = insertTranslatedSubExpr(Addr, CurBB, PredBB, DT, NewInsts);
379
380 // If successful, return the new value.
381 if (Addr) return Addr;
382
383 // If not, destroy any intermediate instructions inserted.
384 while (NewInsts.size() != NISize)
385 NewInsts.pop_back_val()->eraseFromParent();
386 return nullptr;
387}
388
389/// insertTranslatedSubExpr - Insert a computation of the PHI translated
390/// version of 'V' for the edge PredBB->CurBB into the end of the PredBB
391/// block. All newly created instructions are added to the NewInsts list.
392/// This returns null on failure.
393///
394Value *PHITransAddr::insertTranslatedSubExpr(
395 Value *InVal, BasicBlock *CurBB, BasicBlock *PredBB,
396 const DominatorTree &DT, SmallVectorImpl<Instruction *> &NewInsts) {
397 // See if we have a version of this value already available and dominating
398 // PredBB. If so, there is no need to insert a new instance of it.
399 PHITransAddr Tmp(InVal, DL, AC);
400 if (Value *Addr =
401 Tmp.translateValue(CurBB, PredBB, &DT, /*MustDominate=*/true))
402 return Addr;
403
404 // We don't need to PHI translate values which aren't instructions.
405 auto *Inst = dyn_cast<Instruction>(InVal);
406 if (!Inst)
407 return nullptr;
408
409 // Handle cast of PHI translatable value.
410 if (CastInst *Cast = dyn_cast<CastInst>(Inst)) {
411 Value *OpVal = insertTranslatedSubExpr(Cast->getOperand(0), CurBB, PredBB,
412 DT, NewInsts);
413 if (!OpVal) return nullptr;
414
415 // Otherwise insert a cast at the end of PredBB.
416 CastInst *New = CastInst::Create(Cast->getOpcode(), OpVal, InVal->getType(),
417 InVal->getName() + ".phi.trans.insert",
418 PredBB->getTerminator()->getIterator());
419 New->setDebugLoc(Inst->getDebugLoc());
420 NewInsts.push_back(New);
421 return New;
422 }
423
424 // Handle getelementptr with at least one PHI operand.
427 BasicBlock *CurBB = GEP->getParent();
428 for (Value *Op : GEP->operands()) {
429 Value *OpVal = insertTranslatedSubExpr(Op, CurBB, PredBB, DT, NewInsts);
430 if (!OpVal) return nullptr;
431 GEPOps.push_back(OpVal);
432 }
433
434 GetElementPtrInst *Result = GetElementPtrInst::Create(
435 GEP->getSourceElementType(), GEPOps[0], ArrayRef(GEPOps).slice(1),
436 InVal->getName() + ".phi.trans.insert",
437 PredBB->getTerminator()->getIterator());
438 Result->setDebugLoc(Inst->getDebugLoc());
439 Result->setNoWrapFlags(GEP->getNoWrapFlags());
440 NewInsts.push_back(Result);
441 return Result;
442 }
443
444 // Handle add with a constant RHS.
445 if (Inst->getOpcode() == Instruction::Add &&
446 isa<ConstantInt>(Inst->getOperand(1)) &&
447 getAnalysisOptions(Inst->getContext()).gvn_add_phi_translation) {
448
449 // FIXME: This code works, but it is unclear that we actually want to insert
450 // a big chain of computation in order to make a value available in a block.
451 // This needs to be evaluated carefully to consider its cost trade offs.
452
453 // PHI translate the LHS.
454 Value *OpVal = insertTranslatedSubExpr(Inst->getOperand(0), CurBB, PredBB,
455 DT, NewInsts);
456 if (OpVal == nullptr)
457 return nullptr;
458
459 BinaryOperator *Res = BinaryOperator::CreateAdd(
460 OpVal, Inst->getOperand(1), InVal->getName() + ".phi.trans.insert",
461 PredBB->getTerminator()->getIterator());
464 NewInsts.push_back(Res);
465 return Res;
466 }
467
468 return nullptr;
469}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition Compiler.h:690
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Hexagon Common GEP
static bool hasNoSignedWrap(BinaryOperator &I)
static bool hasNoUnsignedWrap(BinaryOperator &I)
#define I(x, y, z)
Definition MD5.cpp:57
static bool isInput(const ArrayRef< StringRef > &Prefixes, StringRef Arg)
Definition OptTable.cpp:143
static void RemoveInstInputs(Value *V, SmallVectorImpl< Instruction * > &InstInputs)
static bool canPHITrans(Instruction *Inst)
static bool verifySubExpr(Value *Expr, SmallVectorImpl< Instruction * > &InstInputs)
SmallVector< MachineOperand, 4 > Cond
Value * RHS
Value * LHS
LLVM Basic Block Representation.
Definition BasicBlock.h:62
const Function * getParent() const
Return the enclosing method, or null if none.
Definition BasicBlock.h:213
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
Definition BasicBlock.h:237
This is the base class for all instructions that perform data casts.
Definition InstrTypes.h:512
static LLVM_ABI CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
static LLVM_ABI Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
Definition Dominators.h:122
LLVM_ABI bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
static GetElementPtrInst * Create(Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
LLVM_ABI void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
PHITransAddr - An address value which tracks and handles phi translation.
LLVM_ABI Value * translateValue(BasicBlock *CurBB, BasicBlock *PredBB, const DominatorTree *DT, bool MustDominate)
translateValue - PHI translate the current address up the CFG from CurBB to Pred, updating our state ...
LLVM_ABI void dump() const
PHITransAddr(Value *Addr, const DataLayout &DL, AssumptionCache *AC)
LLVM_ABI bool isPotentiallyPHITranslatable() const
isPotentiallyPHITranslatable - If this needs PHI translation, return true if we have some hope of doi...
LLVM_ABI bool verify() const
verify - Check internal consistency of this data structure.
LLVM_ABI Value * translateWithInsertion(BasicBlock *CurBB, BasicBlock *PredBB, const DominatorTree &DT, SmallVectorImpl< Instruction * > &NewInsts)
translateWithInsertion - PHI translate this value into the specified predecessor block,...
LLVM_ABI SelectInst * getSelect() const
If the address expression depends on a select instruction (possibly through casts or GEPs),...
std::pair< Value *, Value * > SelectAddrs
This class represents the LLVM 'select' instruction.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
iterator erase(const_iterator CI)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
op_range operands()
Definition User.h:267
Value * getOperand(unsigned i) const
Definition User.h:207
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:260
iterator_range< user_iterator > users()
Definition Value.h:428
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
Definition Value.cpp:315
const ParentTy * getParent() const
Definition ilist_node.h:34
self_iterator getIterator()
Definition ilist_node.h:123
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
friend class Instruction
Iterator for Instructions in a `BasicBlock.
Definition BasicBlock.h:73
This is an optimization pass for GlobalISel generic memory operations.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1781
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1755
LLVM_ABI Value * simplifyGEPInst(Type *SrcTy, Value *Ptr, ArrayRef< Value * > Indices, GEPNoWrapFlags NW, const SimplifyQuery &Q)
Given operands for a GetElementPtrInst, fold the result or return null.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
LLVM_ABI Value * simplifyCastInst(unsigned CastOpc, Value *Op, Type *Ty, const SimplifyQuery &Q)
Given operands for a CastInst, fold the result or return null.
const AnalysisOptions & getAnalysisOptions(const LLVMContext &C)
LLVM_ABI Value * simplifyAddInst(Value *LHS, Value *RHS, bool IsNSW, bool IsNUW, const SimplifyQuery &Q)
Given operands for an Add, fold the result or return null.
auto dyn_cast_or_null(const Y &Val)
Definition Casting.h:753
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Definition STLExtras.h:1963