diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -513,8 +513,7 @@ class AccessAnalysis { public: /// Read or write access location. - typedef PointerIntPair MemAccessInfo; - typedef SmallVector MemAccessInfoList; + typedef SmallVector MemAccessInfoList; AccessAnalysis(Loop *TheLoop, AAResults *AA, LoopInfo *LI, MemoryDepChecker::DepCandidates &DA, @@ -525,7 +524,7 @@ void addLoad(MemoryLocation &Loc, bool IsReadOnly) { Value *Ptr = const_cast(Loc.Ptr); AST.add(Ptr, LocationSize::beforeOrAfterPointer(), Loc.AATags); - Accesses.insert(MemAccessInfo(Ptr, false)); + Accesses.insert(MemoryDepChecker::MemAccessInfo(Ptr, false)); if (IsReadOnly) ReadOnlyPtr.insert(Ptr); } @@ -534,7 +533,7 @@ void addStore(MemoryLocation &Loc) { Value *Ptr = const_cast(Loc.Ptr); AST.add(Ptr, LocationSize::beforeOrAfterPointer(), Loc.AATags); - Accesses.insert(MemAccessInfo(Ptr, true)); + Accesses.insert(MemoryDepChecker::MemAccessInfo(Ptr, true)); } /// Check if we can emit a run-time no-alias check for \p Access. @@ -545,12 +544,11 @@ /// we will attempt to use additional run-time checks in order to get /// the bounds of the pointer. bool createCheckForAccess(RuntimePointerChecking &RtCheck, - MemAccessInfo Access, + MemoryDepChecker::MemAccessInfo Access, const ValueToValueMap &Strides, DenseMap &DepSetId, Loop *TheLoop, unsigned &RunningDepId, - unsigned ASId, bool ShouldCheckStride, - bool Assume); + unsigned ASId, bool ShouldCheckStride, bool Assume); /// Check whether we can check the pointers at runtime for /// non-intersection. @@ -583,7 +581,7 @@ MemAccessInfoList &getDependenciesToCheck() { return CheckDeps; } private: - typedef SetVector PtrAccessSet; + typedef SetVector PtrAccessSet; /// Go over all memory access and check whether runtime pointer checks /// are needed and build sets of dependency check candidates. @@ -688,13 +686,11 @@ } } -bool AccessAnalysis::createCheckForAccess(RuntimePointerChecking &RtCheck, - MemAccessInfo Access, - const ValueToValueMap &StridesMap, - DenseMap &DepSetId, - Loop *TheLoop, unsigned &RunningDepId, - unsigned ASId, bool ShouldCheckWrap, - bool Assume) { +bool AccessAnalysis::createCheckForAccess( + RuntimePointerChecking &RtCheck, MemoryDepChecker::MemAccessInfo Access, + const ValueToValueMap &StridesMap, DenseMap &DepSetId, + Loop *TheLoop, unsigned &RunningDepId, unsigned ASId, bool ShouldCheckWrap, + bool Assume) { Value *Ptr = Access.getPointer(); if (!hasComputableBounds(PSE, StridesMap, Ptr, TheLoop, Assume)) @@ -727,7 +723,7 @@ LLVM_DEBUG(dbgs() << "LAA: Found a runtime check ptr:" << *Ptr << '\n'); return true; - } +} bool AccessAnalysis::canCheckPtrAtRT(RuntimePointerChecking &RtCheck, ScalarEvolution *SE, Loop *TheLoop, @@ -756,14 +752,14 @@ unsigned RunningDepId = 1; DenseMap DepSetId; - SmallVector Retries; + SmallVector Retries; // First, count how many write and read accesses are in the alias set. Also // collect MemAccessInfos for later. - SmallVector AccessInfos; + SmallVector AccessInfos; for (const auto &A : AS) { Value *Ptr = A.getValue(); - bool IsWrite = Accesses.count(MemAccessInfo(Ptr, true)); + bool IsWrite = Accesses.count(MemoryDepChecker::MemAccessInfo(Ptr, true)); if (IsWrite) ++NumWritePtrChecks; @@ -779,7 +775,8 @@ assert((AS.size() <= 1 || all_of(AS, [this](auto AC) { - MemAccessInfo AccessWrite(AC.getValue(), true); + MemoryDepChecker::MemAccessInfo AccessWrite( + AC.getValue(), true); return DepCands.findValue(AccessWrite) == DepCands.end(); })) && "Can only skip updating CanDoRT below, if all entries in AS " @@ -903,7 +900,8 @@ bool SetHasWrite = false; // Map of pointers to last access encountered. - typedef DenseMap UnderlyingObjToAccessMap; + typedef DenseMap + UnderlyingObjToAccessMap; UnderlyingObjToAccessMap ObjToLastAccess; // Set of access to check after all writes have been processed. @@ -934,10 +932,10 @@ // Otherwise, the pointer must be in the PtrAccessSet, either as a // read or a write. assert(((IsReadOnlyPtr && UseDeferred) || IsWrite || - S.count(MemAccessInfo(Ptr, false))) && + S.count(MemoryDepChecker::MemAccessInfo(Ptr, false))) && "Alias-set pointer not in the access set?"); - MemAccessInfo Access(Ptr, IsWrite); + MemoryDepChecker::MemAccessInfo Access(Ptr, IsWrite); DepCands.insert(Access); // Memorize read-only pointers for later processing and skip them in @@ -1285,21 +1283,23 @@ } void MemoryDepChecker::addAccess(StoreInst *SI) { - visitPointers(SI->getPointerOperand(), *InnermostLoop, - [this, SI](Value *Ptr) { - Accesses[MemAccessInfo(Ptr, true)].push_back(AccessIdx); - InstMap.push_back(SI); - ++AccessIdx; - }); + visitPointers( + SI->getPointerOperand(), *InnermostLoop, [this, SI](Value *Ptr) { + Accesses[MemoryDepChecker::MemAccessInfo(Ptr, true)].push_back( + AccessIdx); + InstMap.push_back(SI); + ++AccessIdx; + }); } void MemoryDepChecker::addAccess(LoadInst *LI) { - visitPointers(LI->getPointerOperand(), *InnermostLoop, - [this, LI](Value *Ptr) { - Accesses[MemAccessInfo(Ptr, false)].push_back(AccessIdx); - InstMap.push_back(LI); - ++AccessIdx; - }); + visitPointers( + LI->getPointerOperand(), *InnermostLoop, [this, LI](Value *Ptr) { + Accesses[MemoryDepChecker::MemAccessInfo(Ptr, false)].push_back( + AccessIdx); + InstMap.push_back(LI); + ++AccessIdx; + }); } MemoryDepChecker::VectorizationSafetyStatus @@ -1509,9 +1509,10 @@ } MemoryDepChecker::Dependence::DepType -MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx, - const MemAccessInfo &B, unsigned BIdx, - const ValueToValueMap &Strides) { +MemoryDepChecker::isDependent(const MemoryDepChecker::MemAccessInfo &A, + unsigned AIdx, + const MemoryDepChecker::MemAccessInfo &B, + unsigned BIdx, const ValueToValueMap &Strides) { assert (AIdx < BIdx && "Must pass arguments in program order"); Value *APtr = A.getPointer(); @@ -1709,19 +1710,19 @@ const ValueToValueMap &Strides) { MaxSafeDepDistBytes = -1; - SmallPtrSet Visited; - for (MemAccessInfo CurAccess : CheckDeps) { + SmallPtrSet Visited; + for (MemoryDepChecker::MemAccessInfo CurAccess : CheckDeps) { if (Visited.count(CurAccess)) continue; // Get the relevant memory access set. - EquivalenceClasses::iterator I = - AccessSets.findValue(AccessSets.getLeaderValue(CurAccess)); + EquivalenceClasses::iterator I = + AccessSets.findValue(AccessSets.getLeaderValue(CurAccess)); // Check accesses within this set. - EquivalenceClasses::member_iterator AI = + EquivalenceClasses::member_iterator AI = AccessSets.member_begin(I); - EquivalenceClasses::member_iterator AE = + EquivalenceClasses::member_iterator AE = AccessSets.member_end(); // Check every access pair. @@ -1730,7 +1731,7 @@ bool AIIsWrite = AI->getInt(); // Check loads only against next equivalent class, but stores also against // other stores in the same equivalence class - to the same address. - EquivalenceClasses::member_iterator OI = + EquivalenceClasses::member_iterator OI = (AIIsWrite ? AI : std::next(AI)); while (OI != AE) { // Check every accessing instruction pair in program order. @@ -1783,7 +1784,7 @@ SmallVector MemoryDepChecker::getInstructionsForAccess(Value *Ptr, bool isWrite) const { - MemAccessInfo Access(Ptr, isWrite); + MemoryDepChecker::MemAccessInfo Access(Ptr, isWrite); auto &IndexVector = Accesses.find(Access)->second; SmallVector Insts;