Construct ArrayRef<const T*> from vector<T>
ArrayRef already has a SFINAE constructor which can construct ArrayRef<const T*> from ArrayRef<T*>. This adds methods to do the same directly from SmallVector and std::vector. This avoids an intermediate step through the use of makeArrayRef. Also update the users of this in LICM and SROA to remove the now unnecessary makeArrayRef call. Reviewed by David Blaikie. llvm-svn: 237309
This commit is contained in:
parent
fb2f33183e
commit
7c4d7b8fbe
|
@ -96,6 +96,25 @@ namespace llvm {
|
|||
std::is_convertible<U *const *, T const *>::value>::type* = 0)
|
||||
: Data(A.data()), Length(A.size()) {}
|
||||
|
||||
/// Construct an ArrayRef<const T*> from a SmallVector<T*>. This is
|
||||
/// templated in order to avoid instantiating SmallVectorTemplateCommon<T>
|
||||
/// whenever we copy-construct an ArrayRef.
|
||||
template<typename U, typename DummyT>
|
||||
/*implicit*/ ArrayRef(const SmallVectorTemplateCommon<U*, DummyT> &Vec,
|
||||
typename std::enable_if<
|
||||
std::is_convertible<U *const *,
|
||||
T const *>::value>::type* = 0)
|
||||
: Data(Vec.data()), Length(Vec.size()) {
|
||||
}
|
||||
|
||||
/// Construct an ArrayRef<const T*> from std::vector<T*>. This uses SFINAE
|
||||
/// to ensure that only vectors of pointers can be converted.
|
||||
template<typename U, typename A>
|
||||
ArrayRef(const std::vector<U *, A> &Vec,
|
||||
typename std::enable_if<
|
||||
std::is_convertible<U *const *, T const *>::value>::type* = 0)
|
||||
: Data(Vec.data()), Length(Vec.size()) {}
|
||||
|
||||
/// @}
|
||||
/// @name Simple Operations
|
||||
/// @{
|
||||
|
|
|
@ -929,7 +929,7 @@ bool llvm::promoteLoopAccessesToScalars(AliasSet &AS,
|
|||
// We use the SSAUpdater interface to insert phi nodes as required.
|
||||
SmallVector<PHINode*, 16> NewPHIs;
|
||||
SSAUpdater SSA(&NewPHIs);
|
||||
LoopPromoter Promoter(SomePtr, makeArrayRef(LoopUses), SSA,
|
||||
LoopPromoter Promoter(SomePtr, LoopUses, SSA,
|
||||
PointerMustAliases, ExitBlocks,
|
||||
InsertPts, PIC, *CurAST, *LI, DL, Alignment, AATags);
|
||||
|
||||
|
|
|
@ -4419,7 +4419,7 @@ bool SROA::promoteAllocas(Function &F) {
|
|||
DeadInsts.push_back(I);
|
||||
enqueueUsersInWorklist(*I, Worklist, Visited);
|
||||
}
|
||||
AllocaPromoter(makeArrayRef(Insts), SSA, *AI, DIB).run(Insts);
|
||||
AllocaPromoter(Insts, SSA, *AI, DIB).run(Insts);
|
||||
while (!DeadInsts.empty())
|
||||
DeadInsts.pop_back_val()->eraseFromParent();
|
||||
AI->eraseFromParent();
|
||||
|
|
Loading…
Reference in New Issue