[llvm] r275326 - [LAA] Don't hold on to DataLayout in the analysis result

Adam Nemet via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 13 15:18:52 PDT 2016


Author: anemet
Date: Wed Jul 13 17:18:51 2016
New Revision: 275326

URL: http://llvm.org/viewvc/llvm-project?rev=275326&view=rev
Log:
[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.

Modified:
    llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h
    llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp

Modified: llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h?rev=275326&r1=275325&r2=275326&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h Wed Jul 13 17:18:51 2016
@@ -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<MemoryDepChecker> DepChecker;
 
   Loop *TheLoop;
-  const DataLayout *DL;
   const TargetLibraryInfo *TLI;
   DominatorTree *DT;
 

Modified: llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp?rev=275326&r1=275325&r2=275326&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp Wed Jul 13 17:18:51 2016
@@ -1830,8 +1830,9 @@ std::pair<Instruction *, Instruction *>
     Instruction *Loc,
     const SmallVectorImpl<RuntimePointerChecking::PointerCheck> &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::collectStridedAcces
 }
 
 LoopAccessInfo::LoopAccessInfo(Loop *L, ScalarEvolution *SE,
-                               const DataLayout &DL,
                                const TargetLibraryInfo *TLI, AliasAnalysis *AA,
                                DominatorTree *DT, LoopInfo *LI)
     : PSE(llvm::make_unique<PredicatedScalarEvolution>(*SE, *L)),
       PtrRtChecking(llvm::make_unique<RuntimePointerChecking>(SE)),
       DepChecker(llvm::make_unique<MemoryDepChecker>(*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 &
 const LoopAccessInfo &LoopAccessLegacyAnalysis::getInfo(Loop *L) {
   auto &LAI = LoopAccessInfoMap[L];
 
-  if (!LAI) {
-    const DataLayout &DL = L->getHeader()->getModule()->getDataLayout();
-    LAI = llvm::make_unique<LoopAccessInfo>(L, SE, DL, TLI, AA, DT, LI);
-  }
+  if (!LAI)
+    LAI = llvm::make_unique<LoopAccessInfo>(L, SE, TLI, AA, DT, LI);
+
   return *LAI.get();
 }
 
@@ -2040,8 +2038,7 @@ LoopAccessInfo LoopAccessAnalysis::run(L
     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,




More information about the llvm-commits mailing list