forked from OSchip/llvm-project
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. llvm-svn: 239033
This commit is contained in:
parent
c164a3f4e6
commit
ff22e9e5f6
|
@ -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
|
||||
|
|
|
@ -314,8 +314,7 @@ void TempScopInfo::buildAccessFunctions(Region &R, BasicBlock &BB,
|
|||
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(Value &V, bool inverted,
|
|||
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(Value &V, bool inverted,
|
|||
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(BasicBlock *BB, Region &R) {
|
|||
inverted = false;
|
||||
}
|
||||
|
||||
Comparison *Cmp;
|
||||
buildAffineCondition(*(Br->getCondition()), inverted, &Cmp);
|
||||
Cond.push_back(*Cmp);
|
||||
Cond.push_back(buildAffineCondition(*(Br->getCondition()), inverted));
|
||||
}
|
||||
|
||||
if (!Cond.empty())
|
||||
|
|
Loading…
Reference in New Issue