Index: include/llvm/Transforms/Utils/LoopVersioning.h =================================================================== --- include/llvm/Transforms/Utils/LoopVersioning.h +++ include/llvm/Transforms/Utils/LoopVersioning.h @@ -31,10 +31,10 @@ /// already has a preheader. class LoopVersioning { public: - LoopVersioning(SmallVector Checks, - const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI, - DominatorTree *DT, - const SmallVector *PtrToPartition = nullptr); + LoopVersioning( + const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI, DominatorTree *DT, + SmallVector *Checks = nullptr, + const SmallVector *PtrToPartition = nullptr); /// \brief Performs the CFG manipulation part of versioning the loop including /// the DominatorTree and LoopInfo updates. @@ -80,13 +80,14 @@ /// in NonVersionedLoop. ValueToValueMapTy VMap; - /// \brief The set of checks that we are versioning for. - SmallVector Checks; - /// \brief Analyses used. const LoopAccessInfo &LAI; LoopInfo *LI; DominatorTree *DT; + + /// \brief The set of checks that we are versioning for. + SmallVector *Checks; + }; } Index: lib/Transforms/Scalar/LoopDistribute.cpp =================================================================== --- lib/Transforms/Scalar/LoopDistribute.cpp +++ lib/Transforms/Scalar/LoopDistribute.cpp @@ -793,7 +793,7 @@ if (!Checks.empty()) { DEBUG(dbgs() << "\nPointers:\n"); DEBUG(LAI.getRuntimePointerChecking()->printChecks(dbgs(), Checks)); - LoopVersioning LVer(std::move(Checks), LAI, L, LI, DT); + LoopVersioning LVer(LAI, L, LI, DT, &Checks); LVer.versionLoop(this); LVer.addPHINodes(DefsUsedOutside); } Index: lib/Transforms/Utils/LoopVersioning.cpp =================================================================== --- lib/Transforms/Utils/LoopVersioning.cpp +++ lib/Transforms/Utils/LoopVersioning.cpp @@ -23,11 +23,11 @@ using namespace llvm; LoopVersioning::LoopVersioning( - SmallVector Checks, const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI, DominatorTree *DT, + SmallVector *Checks, const SmallVector *PtrToPartition) - : VersionedLoop(L), NonVersionedLoop(nullptr), Checks(std::move(Checks)), - LAI(LAI), LI(LI), DT(DT) { + : VersionedLoop(L), NonVersionedLoop(nullptr), LAI(LAI), LI(LI), DT(DT), + Checks(Checks) { assert(L->getExitBlock() && "No single exit block"); assert(L->getLoopPreheader() && "No preheader"); } @@ -38,7 +38,8 @@ // Add the memcheck in the original preheader (this is empty initially). BasicBlock *MemCheckBB = VersionedLoop->getLoopPreheader(); std::tie(FirstCheckInst, MemRuntimeCheck) = - LAI.addRuntimeCheck(MemCheckBB->getTerminator(), Checks); + Checks ? LAI.addRuntimeCheck(MemCheckBB->getTerminator(), *Checks) + : LAI.addRuntimeCheck(MemCheckBB->getTerminator()); assert(MemRuntimeCheck && "called even though needsAnyChecking = false"); // Rename the block to make the IR more readable.