diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h --- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h +++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h @@ -20,6 +20,8 @@ #include "llvm/IR/DiagnosticInfo.h" #include "llvm/Pass.h" +#include + namespace llvm { class AAResults; @@ -446,7 +448,7 @@ SmallVector Pointers; /// Holds a partitioning of pointers into "check groups". - SmallVector CheckingGroups; + SmallVector, 2> CheckingGroups; /// Check if pointers are in the same partition /// 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 @@ -65,6 +65,8 @@ #include #include +#include + using namespace llvm; #define DEBUG_TYPE "loop-accesses" @@ -242,8 +244,8 @@ for (unsigned I = 0; I < CheckingGroups.size(); ++I) { for (unsigned J = I + 1; J < CheckingGroups.size(); ++J) { - const RuntimeCheckingPtrGroup &CGI = CheckingGroups[I]; - const RuntimeCheckingPtrGroup &CGJ = CheckingGroups[J]; + const RuntimeCheckingPtrGroup &CGI = *CheckingGroups[I]; + const RuntimeCheckingPtrGroup &CGJ = *CheckingGroups[J]; if (needsChecking(CGI, CGJ)) Checks.push_back(std::make_pair(&CGI, &CGJ)); @@ -357,7 +359,8 @@ // pointers to the same underlying object. if (!UseDependencies) { for (unsigned I = 0; I < Pointers.size(); ++I) - CheckingGroups.push_back(RuntimeCheckingPtrGroup(I, *this)); + CheckingGroups.push_back( + std::make_shared(I, *this)); return; } @@ -383,7 +386,7 @@ MemoryDepChecker::MemAccessInfo Access(Pointers[I].PointerValue, Pointers[I].IsWritePtr); - SmallVector Groups; + SmallVector, 2> Groups; auto LeaderI = DepCands.findValue(DepCands.getLeaderValue(Access)); // Because DepCands is constructed by visiting accesses in the order in @@ -403,7 +406,7 @@ // Go through all the existing sets and see if we can find one // which can include this pointer. - for (RuntimeCheckingPtrGroup &Group : Groups) { + for (auto &Group : Groups) { // Don't perform more than a certain amount of comparisons. // This should limit the cost of grouping the pointers to something // reasonable. If we do end up hitting this threshold, the algorithm @@ -413,7 +416,7 @@ TotalComparisons++; - if (Group.addPointer(Pointer)) { + if (Group->addPointer(Pointer)) { Merged = true; break; } @@ -423,7 +426,8 @@ // We couldn't add this pointer to any existing set or the threshold // for the number of comparisons has been reached. Create a new group // to hold the current pointer. - Groups.push_back(RuntimeCheckingPtrGroup(Pointer, *this)); + Groups.push_back( + std::make_shared(Pointer, *this)); } // We've computed the grouped checks for this partition. @@ -484,7 +488,7 @@ OS.indent(Depth) << "Grouped accesses:\n"; for (unsigned I = 0; I < CheckingGroups.size(); ++I) { - const auto &CG = CheckingGroups[I]; + const auto &CG = *CheckingGroups[I]; OS.indent(Depth + 2) << "Group " << &CG << ":\n"; OS.indent(Depth + 4) << "(Low: " << *CG.Low << " High: " << *CG.High diff --git a/llvm/lib/Transforms/Utils/LoopVersioning.cpp b/llvm/lib/Transforms/Utils/LoopVersioning.cpp --- a/llvm/lib/Transforms/Utils/LoopVersioning.cpp +++ b/llvm/lib/Transforms/Utils/LoopVersioning.cpp @@ -183,10 +183,10 @@ MDNode *Domain = MDB.createAnonymousAliasScopeDomain("LVerDomain"); for (const auto &Group : RtPtrChecking->CheckingGroups) { - GroupToScope[&Group] = MDB.createAnonymousAliasScope(Domain); + GroupToScope[&*Group] = MDB.createAnonymousAliasScope(Domain); - for (unsigned PtrIdx : Group.Members) - PtrToGroup[RtPtrChecking->getPointerInfo(PtrIdx).PointerValue] = &Group; + for (unsigned PtrIdx : Group->Members) + PtrToGroup[RtPtrChecking->getPointerInfo(PtrIdx).PointerValue] = &*Group; } // Go through the checks and for each pointer group, collect the scopes for