Index: include/llvm/Analysis/LoopAccessAnalysis.h =================================================================== --- include/llvm/Analysis/LoopAccessAnalysis.h +++ include/llvm/Analysis/LoopAccessAnalysis.h @@ -520,13 +520,13 @@ bool canVectorizeMemory() const { return CanVecMem; } const RuntimePointerChecking *getRuntimePointerChecking() const { - return &PtrRtChecking; + return PtrRtChecking.get(); } /// \brief Number of memchecks required to prove independence of otherwise /// may-alias pointers. unsigned getNumRuntimePointerChecks() const { - return PtrRtChecking.getNumberOfChecks(); + return PtrRtChecking->getNumberOfChecks(); } /// Return true if the block BB needs to be predicated in order for the loop @@ -565,13 +565,13 @@ /// \brief the Memory Dependence Checker which can determine the /// loop-independent and loop-carried dependences between memory accesses. - const MemoryDepChecker &getDepChecker() const { return DepChecker; } + const MemoryDepChecker &getDepChecker() const { return *DepChecker; } /// \brief Return the list of instructions that use \p Ptr to read or write /// memory. SmallVector getInstructionsForAccess(Value *Ptr, bool isWrite) const { - return DepChecker.getInstructionsForAccess(Ptr, isWrite); + return DepChecker->getInstructionsForAccess(Ptr, isWrite); } /// \brief If an access has a symbolic strides, this maps the pointer value to @@ -616,11 +616,11 @@ /// We need to check that all of the pointers in this list are disjoint /// at runtime. - RuntimePointerChecking PtrRtChecking; + std::unique_ptr PtrRtChecking; /// \brief the Memory Dependence Checker which can determine the /// loop-independent and loop-carried dependences between memory accesses. - MemoryDepChecker DepChecker; + std::unique_ptr DepChecker; Loop *TheLoop; const DataLayout &DL; Index: lib/Analysis/LoopAccessAnalysis.cpp =================================================================== --- lib/Analysis/LoopAccessAnalysis.cpp +++ lib/Analysis/LoopAccessAnalysis.cpp @@ -1514,8 +1514,8 @@ unsigned NumReads = 0; unsigned NumReadWrites = 0; - PtrRtChecking.Pointers.clear(); - PtrRtChecking.Need = false; + PtrRtChecking->Pointers.clear(); + PtrRtChecking->Need = false; const bool IsAnnotatedParallel = TheLoop->isAnnotatedParallel(); @@ -1554,7 +1554,7 @@ } NumLoads++; Loads.push_back(Ld); - DepChecker.addAccess(Ld); + DepChecker->addAccess(Ld); if (EnableMemAccessVersioning) collectStridedAccess(Ld); continue; @@ -1578,7 +1578,7 @@ } NumStores++; Stores.push_back(St); - DepChecker.addAccess(St); + DepChecker->addAccess(St); if (EnableMemAccessVersioning) collectStridedAccess(St); } @@ -1676,7 +1676,7 @@ // Find pointers with computable bounds. We are going to use this information // to place a runtime bound check. - bool CanDoRTIfNeeded = Accesses.canCheckPtrAtRT(PtrRtChecking, PSE.getSE(), + bool CanDoRTIfNeeded = Accesses.canCheckPtrAtRT(*PtrRtChecking, PSE.getSE(), TheLoop, SymbolicStrides); if (!CanDoRTIfNeeded) { emitAnalysis(LoopAccessReport() << "cannot identify array bounds"); @@ -1691,21 +1691,21 @@ CanVecMem = true; if (Accesses.isDependencyCheckNeeded()) { DEBUG(dbgs() << "LAA: Checking memory dependencies\n"); - CanVecMem = DepChecker.areDepsSafe( + CanVecMem = DepChecker->areDepsSafe( DependentAccesses, Accesses.getDependenciesToCheck(), SymbolicStrides); - MaxSafeDepDistBytes = DepChecker.getMaxSafeDepDistBytes(); + MaxSafeDepDistBytes = DepChecker->getMaxSafeDepDistBytes(); - if (!CanVecMem && DepChecker.shouldRetryWithRuntimeCheck()) { + if (!CanVecMem && DepChecker->shouldRetryWithRuntimeCheck()) { DEBUG(dbgs() << "LAA: Retrying with memory checks\n"); // Clear the dependency checks. We assume they are not needed. - Accesses.resetDepChecks(DepChecker); + Accesses.resetDepChecks(*DepChecker); - PtrRtChecking.reset(); - PtrRtChecking.Need = true; + PtrRtChecking->reset(); + PtrRtChecking->Need = true; auto *SE = PSE.getSE(); - CanDoRTIfNeeded = Accesses.canCheckPtrAtRT(PtrRtChecking, SE, TheLoop, + CanDoRTIfNeeded = Accesses.canCheckPtrAtRT(*PtrRtChecking, SE, TheLoop, SymbolicStrides, true); // Check that we found the bounds for the pointer. @@ -1723,7 +1723,7 @@ if (CanVecMem) DEBUG(dbgs() << "LAA: No unsafe dependent memory operations in loop. We" - << (PtrRtChecking.Need ? "" : " don't") + << (PtrRtChecking->Need ? "" : " don't") << " need runtime memory checks.\n"); else { emitAnalysis( @@ -1835,7 +1835,7 @@ auto *SE = PSE.getSE(); SCEVExpander Exp(*SE, DL, "induction"); auto ExpandedChecks = - expandBounds(PointerChecks, TheLoop, Loc, SE, Exp, PtrRtChecking); + expandBounds(PointerChecks, TheLoop, Loc, SE, Exp, *PtrRtChecking); LLVMContext &Ctx = Loc->getContext(); Instruction *FirstInst = nullptr; @@ -1891,10 +1891,10 @@ std::pair LoopAccessInfo::addRuntimeChecks(Instruction *Loc) const { - if (!PtrRtChecking.Need) + if (!PtrRtChecking->Need) return std::make_pair(nullptr, nullptr); - return addRuntimeChecks(Loc, PtrRtChecking.getChecks()); + return addRuntimeChecks(Loc, PtrRtChecking->getChecks()); } void LoopAccessInfo::collectStridedAccess(Value *MemAccess) { @@ -1920,8 +1920,10 @@ const DataLayout &DL, const TargetLibraryInfo *TLI, AliasAnalysis *AA, DominatorTree *DT, LoopInfo *LI) - : PSE(*SE, *L), PtrRtChecking(SE), DepChecker(PSE, L), TheLoop(L), DL(DL), - TLI(TLI), AA(AA), DT(DT), LI(LI), NumLoads(0), NumStores(0), + : PSE(*SE, *L), + PtrRtChecking(llvm::make_unique(SE)), + DepChecker(llvm::make_unique(PSE, L)), TheLoop(L), + DL(DL), TLI(TLI), AA(AA), DT(DT), LI(LI), NumLoads(0), NumStores(0), MaxSafeDepDistBytes(-1U), CanVecMem(false), StoreToLoopInvariantAddress(false) { if (canAnalyzeLoop()) @@ -1934,7 +1936,7 @@ if (MaxSafeDepDistBytes != -1U) OS << " with a maximum dependence distance of " << MaxSafeDepDistBytes << " bytes"; - if (PtrRtChecking.Need) + if (PtrRtChecking->Need) OS << " with run-time checks"; OS << "\n"; } @@ -1942,17 +1944,17 @@ if (Report) OS.indent(Depth) << "Report: " << Report->str() << "\n"; - if (auto *Dependences = DepChecker.getDependences()) { + if (auto *Dependences = DepChecker->getDependences()) { OS.indent(Depth) << "Dependences:\n"; for (auto &Dep : *Dependences) { - Dep.print(OS, Depth + 2, DepChecker.getMemoryInstructions()); + Dep.print(OS, Depth + 2, DepChecker->getMemoryInstructions()); OS << "\n"; } } else OS.indent(Depth) << "Too many dependences, not recorded\n"; // List the pair of accesses need run-time checks to prove independence. - PtrRtChecking.print(OS, Depth); + PtrRtChecking->print(OS, Depth); OS << "\n"; OS.indent(Depth) << "Store to invariant address was "