[llvm] r216358 - Analysis: unique_ptr-ify DependenceAnalysis::collectCoeffInfo

Dylan Noblesmith nobled at dreamwidth.org
Sun Aug 24 17:28:43 PDT 2014


Author: nobled
Date: Sun Aug 24 19:28:43 2014
New Revision: 216358

URL: http://llvm.org/viewvc/llvm-project?rev=216358&view=rev
Log:
Analysis: unique_ptr-ify DependenceAnalysis::collectCoeffInfo

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

Modified: llvm/trunk/include/llvm/Analysis/DependenceAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DependenceAnalysis.h?rev=216358&r1=216357&r2=216358&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/DependenceAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/DependenceAnalysis.h Sun Aug 24 19:28:43 2014
@@ -766,9 +766,10 @@ namespace llvm {
     /// collectCoefficientInfo - Walks through the subscript,
     /// collecting each coefficient, the associated loop bounds,
     /// and recording its positive and negative parts for later use.
-    CoefficientInfo *collectCoeffInfo(const SCEV *Subscript,
-                                      bool SrcFlag,
-                                      const SCEV *&Constant) const;
+    std::unique_ptr<CoefficientInfo[]>
+    collectCoeffInfo(const SCEV *Subscript,
+                     bool SrcFlag,
+                     const SCEV *&Constant) const;
 
     /// getPositivePart - X^+ = max(X, 0).
     ///

Modified: llvm/trunk/lib/Analysis/DependenceAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DependenceAnalysis.cpp?rev=216358&r1=216357&r2=216358&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/DependenceAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/DependenceAnalysis.cpp Sun Aug 24 19:28:43 2014
@@ -2437,11 +2437,14 @@ bool DependenceAnalysis::banerjeeMIVtest
   ++BanerjeeApplications;
   DEBUG(dbgs() << "    Src = " << *Src << '\n');
   const SCEV *A0;
-  CoefficientInfo *A = collectCoeffInfo(Src, true, A0);
+  auto AOwner = collectCoeffInfo(Src, true, A0);
+  auto A = AOwner.get();
   DEBUG(dbgs() << "    Dst = " << *Dst << '\n');
   const SCEV *B0;
-  CoefficientInfo *B = collectCoeffInfo(Dst, false, B0);
-  BoundInfo *Bound = new BoundInfo[MaxLevels + 1];
+  auto BOwner = collectCoeffInfo(Dst, false, B0);
+  auto B = BOwner.get();
+  auto BoundOwner = make_unique<BoundInfo[]>(MaxLevels + 1);
+  auto Bound = BoundOwner.get();
   const SCEV *Delta = SE->getMinusSCEV(B0, A0);
   DEBUG(dbgs() << "\tDelta = " << *Delta << '\n');
 
@@ -2498,9 +2501,6 @@ bool DependenceAnalysis::banerjeeMIVtest
     ++BanerjeeIndependence;
     Disproved = true;
   }
-  delete [] Bound;
-  delete [] A;
-  delete [] B;
   return Disproved;
 }
 
@@ -2818,12 +2818,12 @@ const SCEV *DependenceAnalysis::getNegat
 // Walks through the subscript,
 // collecting each coefficient, the associated loop bounds,
 // and recording its positive and negative parts for later use.
-DependenceAnalysis::CoefficientInfo *
+std::unique_ptr<DependenceAnalysis::CoefficientInfo[]>
 DependenceAnalysis::collectCoeffInfo(const SCEV *Subscript,
                                      bool SrcFlag,
                                      const SCEV *&Constant) const {
   const SCEV *Zero = SE->getConstant(Subscript->getType(), 0);
-  CoefficientInfo *CI = new CoefficientInfo[MaxLevels + 1];
+  auto CI = make_unique<CoefficientInfo[]>(MaxLevels + 1);
   for (unsigned K = 1; K <= MaxLevels; ++K) {
     CI[K].Coeff = Zero;
     CI[K].PosPart = Zero;





More information about the llvm-commits mailing list