From 19a19a9ad1fe941e8cc10bb9ebbe8f1136007831 Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Wed, 13 May 2015 01:12:16 +0000 Subject: [PATCH] Change LoadAndStorePromoter to take ArrayRef instead of SmallVectorImpl&. The array passed to LoadAndStorePromoter's constructor was a constant reference to a SmallVectorImpl, which is just the same as passing an ArrayRef. Also, the data in the array can be 'const Instruction*' instead of 'Instruction*'. Its not possible to convert a SmallVectorImpl to SmallVectorImpl, but ArrayRef does provide such a method. Currently this added calls to makeArrayRef which should be a nop, but i'm going to kick off a discussion about improving ArrayRef to not need these. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237226 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Utils/SSAUpdater.h | 3 ++- lib/Transforms/Scalar/LICM.cpp | 6 ++++-- lib/Transforms/Scalar/SROA.cpp | 5 +++-- lib/Transforms/Scalar/ScalarReplAggregates.cpp | 2 +- lib/Transforms/Utils/SSAUpdater.cpp | 6 +++--- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/llvm/Transforms/Utils/SSAUpdater.h b/include/llvm/Transforms/Utils/SSAUpdater.h index 19e2a4a4af4..1c7b2c587a3 100644 --- a/include/llvm/Transforms/Utils/SSAUpdater.h +++ b/include/llvm/Transforms/Utils/SSAUpdater.h @@ -14,6 +14,7 @@ #ifndef LLVM_TRANSFORMS_UTILS_SSAUPDATER_H #define LLVM_TRANSFORMS_UTILS_SSAUPDATER_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Compiler.h" @@ -135,7 +136,7 @@ protected: SSAUpdater &SSA; public: - LoadAndStorePromoter(const SmallVectorImpl &Insts, + LoadAndStorePromoter(ArrayRef Insts, SSAUpdater &S, StringRef Name = StringRef()); virtual ~LoadAndStorePromoter() {} diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index ca1918ef83d..760ce7773ec 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -714,7 +714,8 @@ namespace { } public: - LoopPromoter(Value *SP, const SmallVectorImpl &Insts, + LoopPromoter(Value *SP, + ArrayRef Insts, SSAUpdater &S, SmallPtrSetImpl &PMA, SmallVectorImpl &LEB, SmallVectorImpl &LIP, PredIteratorCache &PIC, @@ -920,7 +921,8 @@ bool llvm::promoteLoopAccessesToScalars(AliasSet &AS, // We use the SSAUpdater interface to insert phi nodes as required. SmallVector NewPHIs; SSAUpdater SSA(&NewPHIs); - LoopPromoter Promoter(SomePtr, LoopUses, SSA, PointerMustAliases, ExitBlocks, + LoopPromoter Promoter(SomePtr, makeArrayRef(LoopUses), SSA, + PointerMustAliases, ExitBlocks, InsertPts, PIC, *CurAST, *LI, DL, Alignment, AATags); // Set up the preheader to have a definition of the value. It is the live-out diff --git a/lib/Transforms/Scalar/SROA.cpp b/lib/Transforms/Scalar/SROA.cpp index 3e062ba96d7..2e785807759 100644 --- a/lib/Transforms/Scalar/SROA.cpp +++ b/lib/Transforms/Scalar/SROA.cpp @@ -1088,7 +1088,8 @@ class AllocaPromoter : public LoadAndStorePromoter { SmallVector DVIs; public: - AllocaPromoter(const SmallVectorImpl &Insts, SSAUpdater &S, + AllocaPromoter(ArrayRef Insts, + SSAUpdater &S, AllocaInst &AI, DIBuilder &DIB) : LoadAndStorePromoter(Insts, S), AI(AI), DIB(DIB) {} @@ -4418,7 +4419,7 @@ bool SROA::promoteAllocas(Function &F) { DeadInsts.push_back(I); enqueueUsersInWorklist(*I, Worklist, Visited); } - AllocaPromoter(Insts, SSA, *AI, DIB).run(Insts); + AllocaPromoter(makeArrayRef(Insts), SSA, *AI, DIB).run(Insts); while (!DeadInsts.empty()) DeadInsts.pop_back_val()->eraseFromParent(); AI->eraseFromParent(); diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 2ec1fd014aa..d955da7ce75 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1052,7 +1052,7 @@ class AllocaPromoter : public LoadAndStorePromoter { SmallVector DDIs; SmallVector DVIs; public: - AllocaPromoter(const SmallVectorImpl &Insts, SSAUpdater &S, + AllocaPromoter(ArrayRef Insts, SSAUpdater &S, DIBuilder *DB) : LoadAndStorePromoter(Insts, S), AI(nullptr), DIB(DB) {} diff --git a/lib/Transforms/Utils/SSAUpdater.cpp b/lib/Transforms/Utils/SSAUpdater.cpp index 955ce30ed3d..88b39dd7f66 100644 --- a/lib/Transforms/Utils/SSAUpdater.cpp +++ b/lib/Transforms/Utils/SSAUpdater.cpp @@ -322,12 +322,12 @@ Value *SSAUpdater::GetValueAtEndOfBlockInternal(BasicBlock *BB) { //===----------------------------------------------------------------------===// LoadAndStorePromoter:: -LoadAndStorePromoter(const SmallVectorImpl &Insts, +LoadAndStorePromoter(ArrayRef Insts, SSAUpdater &S, StringRef BaseName) : SSA(S) { if (Insts.empty()) return; - Value *SomeVal; - if (LoadInst *LI = dyn_cast(Insts[0])) + const Value *SomeVal; + if (const LoadInst *LI = dyn_cast(Insts[0])) SomeVal = LI; else SomeVal = cast(Insts[0])->getOperand(0); -- 2.34.1