diff options
author | Dan Gohman <gohman@apple.com> | 2009-05-18 15:44:58 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-05-18 15:44:58 +0000 |
commit | f78a978d4674c5163663170d8d162479a96d014f (patch) | |
tree | 0e20b02369ac75427b517679c4310805c432abfe | |
parent | 859b4824eeb2d88c441e855afe3dd7827dfd62a4 (diff) | |
download | external_llvm-f78a978d4674c5163663170d8d162479a96d014f.zip external_llvm-f78a978d4674c5163663170d8d162479a96d014f.tar.gz external_llvm-f78a978d4674c5163663170d8d162479a96d014f.tar.bz2 |
Add assertion checks to the SCEV operator creation methods to catch
type mismatches.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72006 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index f300039..e1fc345 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -921,6 +921,12 @@ SCEVHandle ScalarEvolution::getSignExtendExpr(const SCEVHandle &Op, SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) { assert(!Ops.empty() && "Cannot get empty add!"); if (Ops.size() == 1) return Ops[0]; +#ifndef NDEBUG + for (unsigned i = 1, e = Ops.size(); i != e; ++i) + assert(getEffectiveSCEVType(Ops[i]->getType()) == + getEffectiveSCEVType(Ops[0]->getType()) && + "SCEVAddExpr operand types don't match!"); +#endif // Sort by complexity, this groups all similar expression types together. GroupByComplexity(Ops, LI); @@ -1205,6 +1211,12 @@ SCEVHandle ScalarEvolution::getAddExpr(std::vector<SCEVHandle> &Ops) { SCEVHandle ScalarEvolution::getMulExpr(std::vector<SCEVHandle> &Ops) { assert(!Ops.empty() && "Cannot get empty mul!"); +#ifndef NDEBUG + for (unsigned i = 1, e = Ops.size(); i != e; ++i) + assert(getEffectiveSCEVType(Ops[i]->getType()) == + getEffectiveSCEVType(Ops[0]->getType()) && + "SCEVMulExpr operand types don't match!"); +#endif // Sort by complexity, this groups all similar expression types together. GroupByComplexity(Ops, LI); @@ -1362,6 +1374,10 @@ SCEVHandle ScalarEvolution::getMulExpr(std::vector<SCEVHandle> &Ops) { SCEVHandle ScalarEvolution::getUDivExpr(const SCEVHandle &LHS, const SCEVHandle &RHS) { + assert(getEffectiveSCEVType(LHS->getType()) == + getEffectiveSCEVType(RHS->getType()) && + "SCEVUDivExpr operand types don't match!"); + if (const SCEVConstant *RHSC = dyn_cast<SCEVConstant>(RHS)) { if (RHSC->getValue()->equalsInt(1)) return LHS; // X udiv 1 --> x @@ -1466,6 +1482,12 @@ SCEVHandle ScalarEvolution::getAddRecExpr(const SCEVHandle &Start, SCEVHandle ScalarEvolution::getAddRecExpr(std::vector<SCEVHandle> &Operands, const Loop *L) { if (Operands.size() == 1) return Operands[0]; +#ifndef NDEBUG + for (unsigned i = 1, e = Operands.size(); i != e; ++i) + assert(getEffectiveSCEVType(Operands[i]->getType()) == + getEffectiveSCEVType(Operands[0]->getType()) && + "SCEVAddRecExpr operand types don't match!"); +#endif if (Operands.back()->isZero()) { Operands.pop_back(); @@ -1502,6 +1524,12 @@ SCEVHandle ScalarEvolution::getSMaxExpr(const SCEVHandle &LHS, SCEVHandle ScalarEvolution::getSMaxExpr(std::vector<SCEVHandle> Ops) { assert(!Ops.empty() && "Cannot get empty smax!"); if (Ops.size() == 1) return Ops[0]; +#ifndef NDEBUG + for (unsigned i = 1, e = Ops.size(); i != e; ++i) + assert(getEffectiveSCEVType(Ops[i]->getType()) == + getEffectiveSCEVType(Ops[0]->getType()) && + "SCEVSMaxExpr operand types don't match!"); +#endif // Sort by complexity, this groups all similar expression types together. GroupByComplexity(Ops, LI); @@ -1582,6 +1610,12 @@ SCEVHandle ScalarEvolution::getUMaxExpr(const SCEVHandle &LHS, SCEVHandle ScalarEvolution::getUMaxExpr(std::vector<SCEVHandle> Ops) { assert(!Ops.empty() && "Cannot get empty umax!"); if (Ops.size() == 1) return Ops[0]; +#ifndef NDEBUG + for (unsigned i = 1, e = Ops.size(); i != e; ++i) + assert(getEffectiveSCEVType(Ops[i]->getType()) == + getEffectiveSCEVType(Ops[0]->getType()) && + "SCEVUMaxExpr operand types don't match!"); +#endif // Sort by complexity, this groups all similar expression types together. GroupByComplexity(Ops, LI); |