[polly] r239033 - Store comparison objects as objects, not pointers

Tobias Grosser tobias at grosser.es
Thu Jun 4 04:44:10 PDT 2015


Author: grosser
Date: Thu Jun  4 06:44:09 2015
New Revision: 239033

URL: http://llvm.org/viewvc/llvm-project?rev=239033&view=rev
Log:
Store comparison objects as objects, not pointers

This fixes a memory leak. If we store the actual objects we can not forget to
free them.

Modified:
    polly/trunk/include/polly/TempScopInfo.h
    polly/trunk/lib/Analysis/TempScopInfo.cpp

Modified: polly/trunk/include/polly/TempScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/TempScopInfo.h?rev=239033&r1=239032&r2=239033&view=diff
==============================================================================
--- polly/trunk/include/polly/TempScopInfo.h (original)
+++ polly/trunk/include/polly/TempScopInfo.h Thu Jun  4 06:44:09 2015
@@ -243,7 +243,7 @@ class TempScopInfo : public FunctionPass
   void buildCondition(BasicBlock *BB, Region &R);
 
   // Build the affine function of the given condition
-  void buildAffineCondition(Value &V, bool inverted, Comparison **Comp) const;
+  Comparison buildAffineCondition(Value &V, bool inverted);
 
   // Return the temporary Scop information of Region R, where R must be a valid
   // part of Scop

Modified: polly/trunk/lib/Analysis/TempScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/TempScopInfo.cpp?rev=239033&r1=239032&r2=239033&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/TempScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/TempScopInfo.cpp Thu Jun  4 06:44:09 2015
@@ -314,8 +314,7 @@ void TempScopInfo::buildAccessFunctions(
   Accs.insert(Accs.end(), Functions.begin(), Functions.end());
 }
 
-void TempScopInfo::buildAffineCondition(Value &V, bool inverted,
-                                        Comparison **Comp) const {
+Comparison TempScopInfo::buildAffineCondition(Value &V, bool inverted) {
   if (ConstantInt *C = dyn_cast<ConstantInt>(&V)) {
     // If this is always true condition, we will create 0 <= 1,
     // otherwise we will create 0 >= 1.
@@ -323,11 +322,9 @@ void TempScopInfo::buildAffineCondition(
     const SCEV *RHS = SE->getConstant(C->getType(), 1);
 
     if (C->isOne() == inverted)
-      *Comp = new Comparison(LHS, RHS, ICmpInst::ICMP_SLE);
+      return Comparison(LHS, RHS, ICmpInst::ICMP_SLE);
     else
-      *Comp = new Comparison(LHS, RHS, ICmpInst::ICMP_SGE);
-
-    return;
+      return Comparison(LHS, RHS, ICmpInst::ICMP_SGE);
   }
 
   ICmpInst *ICmp = dyn_cast<ICmpInst>(&V);
@@ -357,7 +354,7 @@ void TempScopInfo::buildAffineCondition(
     break;
   }
 
-  *Comp = new Comparison(LHS, RHS, Pred);
+  return Comparison(LHS, RHS, Pred);
 }
 
 void TempScopInfo::buildCondition(BasicBlock *BB, Region &R) {
@@ -421,9 +418,7 @@ void TempScopInfo::buildCondition(BasicB
         inverted = false;
     }
 
-    Comparison *Cmp;
-    buildAffineCondition(*(Br->getCondition()), inverted, &Cmp);
-    Cond.push_back(*Cmp);
+    Cond.push_back(buildAffineCondition(*(Br->getCondition()), inverted));
   }
 
   if (!Cond.empty())





More information about the llvm-commits mailing list