From 1824e411c6e2eee5b0517492a0f1ac267eea7b27 Mon Sep 17 00:00:00 2001 From: Adam Nemet Date: Wed, 13 Jul 2016 22:18:51 +0000 Subject: [PATCH] [LAA] Don't hold on to DataLayout in the analysis result In fact, don't even pass this to the ctor since we can get it from the module. llvm-svn: 275326 --- llvm/include/llvm/Analysis/LoopAccessAnalysis.h | 9 +++------ llvm/lib/Analysis/LoopAccessAnalysis.cpp | 19 ++++++++----------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h index 697671e..7ba7a49 100644 --- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h +++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h @@ -511,9 +511,8 @@ private: /// PSE must be emitted in order for the results of this analysis to be valid. class LoopAccessInfo { public: - LoopAccessInfo(Loop *L, ScalarEvolution *SE, const DataLayout &DL, - const TargetLibraryInfo *TLI, AliasAnalysis *AA, - DominatorTree *DT, LoopInfo *LI); + LoopAccessInfo(Loop *L, ScalarEvolution *SE, const TargetLibraryInfo *TLI, + AliasAnalysis *AA, DominatorTree *DT, LoopInfo *LI); // FIXME: // Hack for MSVC 2013 which sems like it can't synthesize this even @@ -521,7 +520,7 @@ public: // LoopAccessInfo(LoopAccessInfo &&LAI) = default; LoopAccessInfo(LoopAccessInfo &&LAI) : PSE(std::move(LAI.PSE)), PtrRtChecking(std::move(LAI.PtrRtChecking)), - DepChecker(std::move(LAI.DepChecker)), TheLoop(LAI.TheLoop), DL(LAI.DL), + DepChecker(std::move(LAI.DepChecker)), TheLoop(LAI.TheLoop), TLI(LAI.TLI), DT(LAI.DT), NumLoads(LAI.NumLoads), NumStores(LAI.NumStores), MaxSafeDepDistBytes(LAI.MaxSafeDepDistBytes), CanVecMem(LAI.CanVecMem), @@ -537,7 +536,6 @@ public: PtrRtChecking = std::move(LAI.PtrRtChecking); DepChecker = std::move(LAI.DepChecker); TheLoop = LAI.TheLoop; - DL = LAI.DL; TLI = LAI.TLI; DT = LAI.DT; NumLoads = LAI.NumLoads; @@ -661,7 +659,6 @@ private: std::unique_ptr DepChecker; Loop *TheLoop; - const DataLayout *DL; const TargetLibraryInfo *TLI; DominatorTree *DT; diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index b092a1a..4f0d8ad 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -1830,8 +1830,9 @@ std::pair LoopAccessInfo::addRuntimeChecks( Instruction *Loc, const SmallVectorImpl &PointerChecks) const { + const DataLayout &DL = TheLoop->getHeader()->getModule()->getDataLayout(); auto *SE = PSE->getSE(); - SCEVExpander Exp(*SE, *DL, "induction"); + SCEVExpander Exp(*SE, DL, "induction"); auto ExpandedChecks = expandBounds(PointerChecks, TheLoop, Loc, SE, Exp, *PtrRtChecking); @@ -1915,15 +1916,13 @@ void LoopAccessInfo::collectStridedAccess(Value *MemAccess) { } LoopAccessInfo::LoopAccessInfo(Loop *L, ScalarEvolution *SE, - const DataLayout &DL, const TargetLibraryInfo *TLI, AliasAnalysis *AA, DominatorTree *DT, LoopInfo *LI) : PSE(llvm::make_unique(*SE, *L)), PtrRtChecking(llvm::make_unique(SE)), DepChecker(llvm::make_unique(*PSE, L)), TheLoop(L), - DL(&DL), TLI(TLI), DT(DT), NumLoads(0), NumStores(0), - MaxSafeDepDistBytes(-1), CanVecMem(false), - StoreToLoopInvariantAddress(false) { + TLI(TLI), DT(DT), NumLoads(0), NumStores(0), MaxSafeDepDistBytes(-1), + CanVecMem(false), StoreToLoopInvariantAddress(false) { if (canAnalyzeLoop()) analyzeLoop(AA, LI); } @@ -1971,10 +1970,9 @@ void LoopAccessInfo::print(raw_ostream &OS, unsigned Depth) const { const LoopAccessInfo &LoopAccessLegacyAnalysis::getInfo(Loop *L) { auto &LAI = LoopAccessInfoMap[L]; - if (!LAI) { - const DataLayout &DL = L->getHeader()->getModule()->getDataLayout(); - LAI = llvm::make_unique(L, SE, DL, TLI, AA, DT, LI); - } + if (!LAI) + LAI = llvm::make_unique(L, SE, TLI, AA, DT, LI); + return *LAI.get(); } @@ -2040,8 +2038,7 @@ LoopAccessInfo LoopAccessAnalysis::run(Loop &L, AnalysisManager &AM) { report_fatal_error("DominatorTree must have been cached at a higher level"); if (!LI) report_fatal_error("LoopInfo must have been cached at a higher level"); - const DataLayout &DL = F.getParent()->getDataLayout(); - return LoopAccessInfo(&L, SE, DL, TLI, AA, DT, LI); + return LoopAccessInfo(&L, SE, TLI, AA, DT, LI); } PreservedAnalyses LoopAccessInfoPrinterPass::run(Loop &L, -- 2.7.4