mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 16:24:23 +00:00
Add a ScalarEvolution::getCouldNotCompute() function, and use it
instead of allocating and leaking new SCEVCouldNotCompute objects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69452 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -246,6 +246,7 @@ namespace llvm {
|
|||||||
SCEVHandle getUMaxExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
|
SCEVHandle getUMaxExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
|
||||||
SCEVHandle getUMaxExpr(std::vector<SCEVHandle> Operands);
|
SCEVHandle getUMaxExpr(std::vector<SCEVHandle> Operands);
|
||||||
SCEVHandle getUnknown(Value *V);
|
SCEVHandle getUnknown(Value *V);
|
||||||
|
SCEVHandle getCouldNotCompute();
|
||||||
|
|
||||||
/// getNegativeSCEV - Return the SCEV object corresponding to -V.
|
/// getNegativeSCEV - Return the SCEV object corresponding to -V.
|
||||||
///
|
///
|
||||||
|
@ -569,7 +569,7 @@ static SCEVHandle BinomialCoefficient(SCEVHandle It, unsigned K,
|
|||||||
// Protection from insane SCEVs; this bound is conservative,
|
// Protection from insane SCEVs; this bound is conservative,
|
||||||
// but it probably doesn't matter.
|
// but it probably doesn't matter.
|
||||||
if (K > 1000)
|
if (K > 1000)
|
||||||
return new SCEVCouldNotCompute();
|
return SE.getCouldNotCompute();
|
||||||
|
|
||||||
unsigned W = SE.getTargetData().getTypeSizeInBits(ResultTy);
|
unsigned W = SE.getTargetData().getTypeSizeInBits(ResultTy);
|
||||||
|
|
||||||
@ -1337,7 +1337,6 @@ SCEVHandle ScalarEvolution::getUnknown(Value *V) {
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// ScalarEvolutionsImpl Definition and Implementation
|
// ScalarEvolutionsImpl Definition and Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -1386,6 +1385,8 @@ namespace {
|
|||||||
TargetData &td)
|
TargetData &td)
|
||||||
: SE(se), F(f), LI(li), TD(td), UnknownValue(new SCEVCouldNotCompute()) {}
|
: SE(se), F(f), LI(li), TD(td), UnknownValue(new SCEVCouldNotCompute()) {}
|
||||||
|
|
||||||
|
SCEVHandle getCouldNotCompute();
|
||||||
|
|
||||||
/// getIntegerSCEV - Given an integer or FP type, create a constant for the
|
/// getIntegerSCEV - Given an integer or FP type, create a constant for the
|
||||||
/// specified signed integer value and return a SCEV for the constant.
|
/// specified signed integer value and return a SCEV for the constant.
|
||||||
SCEVHandle getIntegerSCEV(int Val, const Type *Ty);
|
SCEVHandle getIntegerSCEV(int Val, const Type *Ty);
|
||||||
@ -1577,6 +1578,10 @@ const TargetData &ScalarEvolutionsImpl::getTargetData() const {
|
|||||||
return TD;
|
return TD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCEVHandle ScalarEvolutionsImpl::getCouldNotCompute() {
|
||||||
|
return UnknownValue;
|
||||||
|
}
|
||||||
|
|
||||||
/// getSCEV - Return an existing SCEV if it exists, otherwise analyze the
|
/// getSCEV - Return an existing SCEV if it exists, otherwise analyze the
|
||||||
/// expression and create a new one.
|
/// expression and create a new one.
|
||||||
SCEVHandle ScalarEvolutionsImpl::getSCEV(Value *V) {
|
SCEVHandle ScalarEvolutionsImpl::getSCEV(Value *V) {
|
||||||
@ -2732,7 +2737,7 @@ static SCEVHandle SolveLinEquationWithOverflow(const APInt &A, const APInt &B,
|
|||||||
// B is divisible by D if and only if the multiplicity of prime factor 2 for B
|
// B is divisible by D if and only if the multiplicity of prime factor 2 for B
|
||||||
// is not less than multiplicity of this prime factor for D.
|
// is not less than multiplicity of this prime factor for D.
|
||||||
if (B.countTrailingZeros() < Mult2)
|
if (B.countTrailingZeros() < Mult2)
|
||||||
return new SCEVCouldNotCompute();
|
return SE.getCouldNotCompute();
|
||||||
|
|
||||||
// 3. Compute I: the multiplicative inverse of (A / D) in arithmetic
|
// 3. Compute I: the multiplicative inverse of (A / D) in arithmetic
|
||||||
// modulo (N / D).
|
// modulo (N / D).
|
||||||
@ -2766,7 +2771,7 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec, ScalarEvolution &SE) {
|
|||||||
|
|
||||||
// We currently can only solve this if the coefficients are constants.
|
// We currently can only solve this if the coefficients are constants.
|
||||||
if (!LC || !MC || !NC) {
|
if (!LC || !MC || !NC) {
|
||||||
SCEV *CNC = new SCEVCouldNotCompute();
|
SCEV *CNC = SE.getCouldNotCompute();
|
||||||
return std::make_pair(CNC, CNC);
|
return std::make_pair(CNC, CNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2802,7 +2807,7 @@ SolveQuadraticEquation(const SCEVAddRecExpr *AddRec, ScalarEvolution &SE) {
|
|||||||
APInt NegB(-B);
|
APInt NegB(-B);
|
||||||
APInt TwoA( A << 1 );
|
APInt TwoA( A << 1 );
|
||||||
if (TwoA.isMinValue()) {
|
if (TwoA.isMinValue()) {
|
||||||
SCEV *CNC = new SCEVCouldNotCompute();
|
SCEV *CNC = SE.getCouldNotCompute();
|
||||||
return std::make_pair(CNC, CNC);
|
return std::make_pair(CNC, CNC);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3093,7 +3098,7 @@ HowManyLessThans(SCEV *LHS, SCEV *RHS, const Loop *L, bool isSigned) {
|
|||||||
SCEVHandle SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range,
|
SCEVHandle SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range,
|
||||||
ScalarEvolution &SE) const {
|
ScalarEvolution &SE) const {
|
||||||
if (Range.isFullSet()) // Infinite loop.
|
if (Range.isFullSet()) // Infinite loop.
|
||||||
return new SCEVCouldNotCompute();
|
return SE.getCouldNotCompute();
|
||||||
|
|
||||||
// If the start is a non-zero constant, shift the range to simplify things.
|
// If the start is a non-zero constant, shift the range to simplify things.
|
||||||
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(getStart()))
|
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(getStart()))
|
||||||
@ -3105,14 +3110,14 @@ SCEVHandle SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range,
|
|||||||
return ShiftedAddRec->getNumIterationsInRange(
|
return ShiftedAddRec->getNumIterationsInRange(
|
||||||
Range.subtract(SC->getValue()->getValue()), SE);
|
Range.subtract(SC->getValue()->getValue()), SE);
|
||||||
// This is strange and shouldn't happen.
|
// This is strange and shouldn't happen.
|
||||||
return new SCEVCouldNotCompute();
|
return SE.getCouldNotCompute();
|
||||||
}
|
}
|
||||||
|
|
||||||
// The only time we can solve this is when we have all constant indices.
|
// The only time we can solve this is when we have all constant indices.
|
||||||
// Otherwise, we cannot determine the overflow conditions.
|
// Otherwise, we cannot determine the overflow conditions.
|
||||||
for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
|
||||||
if (!isa<SCEVConstant>(getOperand(i)))
|
if (!isa<SCEVConstant>(getOperand(i)))
|
||||||
return new SCEVCouldNotCompute();
|
return SE.getCouldNotCompute();
|
||||||
|
|
||||||
|
|
||||||
// Okay at this point we know that all elements of the chrec are constants and
|
// Okay at this point we know that all elements of the chrec are constants and
|
||||||
@ -3145,7 +3150,7 @@ SCEVHandle SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range,
|
|||||||
// things must have happened.
|
// things must have happened.
|
||||||
ConstantInt *Val = EvaluateConstantChrecAtConstant(this, ExitValue, SE);
|
ConstantInt *Val = EvaluateConstantChrecAtConstant(this, ExitValue, SE);
|
||||||
if (Range.contains(Val->getValue()))
|
if (Range.contains(Val->getValue()))
|
||||||
return new SCEVCouldNotCompute(); // Something strange happened
|
return SE.getCouldNotCompute(); // Something strange happened
|
||||||
|
|
||||||
// Ensure that the previous value is in the range. This is a sanity check.
|
// Ensure that the previous value is in the range. This is a sanity check.
|
||||||
assert(Range.contains(
|
assert(Range.contains(
|
||||||
@ -3188,7 +3193,7 @@ SCEVHandle SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range,
|
|||||||
R1Val = EvaluateConstantChrecAtConstant(this, NextVal, SE);
|
R1Val = EvaluateConstantChrecAtConstant(this, NextVal, SE);
|
||||||
if (!Range.contains(R1Val->getValue()))
|
if (!Range.contains(R1Val->getValue()))
|
||||||
return SE.getConstant(NextVal);
|
return SE.getConstant(NextVal);
|
||||||
return new SCEVCouldNotCompute(); // Something strange happened
|
return SE.getCouldNotCompute(); // Something strange happened
|
||||||
}
|
}
|
||||||
|
|
||||||
// If R1 was not in the range, then it is a good return value. Make
|
// If R1 was not in the range, then it is a good return value. Make
|
||||||
@ -3197,12 +3202,12 @@ SCEVHandle SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range,
|
|||||||
R1Val = EvaluateConstantChrecAtConstant(this, NextVal, SE);
|
R1Val = EvaluateConstantChrecAtConstant(this, NextVal, SE);
|
||||||
if (Range.contains(R1Val->getValue()))
|
if (Range.contains(R1Val->getValue()))
|
||||||
return R1;
|
return R1;
|
||||||
return new SCEVCouldNotCompute(); // Something strange happened
|
return SE.getCouldNotCompute(); // Something strange happened
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SCEVCouldNotCompute();
|
return SE.getCouldNotCompute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3233,6 +3238,10 @@ const TargetData &ScalarEvolution::getTargetData() const {
|
|||||||
return ((ScalarEvolutionsImpl*)Impl)->getTargetData();
|
return ((ScalarEvolutionsImpl*)Impl)->getTargetData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCEVHandle ScalarEvolution::getCouldNotCompute() {
|
||||||
|
return ((ScalarEvolutionsImpl*)Impl)->getCouldNotCompute();
|
||||||
|
}
|
||||||
|
|
||||||
SCEVHandle ScalarEvolution::getIntegerSCEV(int Val, const Type *Ty) {
|
SCEVHandle ScalarEvolution::getIntegerSCEV(int Val, const Type *Ty) {
|
||||||
return ((ScalarEvolutionsImpl*)Impl)->getIntegerSCEV(Val, Ty);
|
return ((ScalarEvolutionsImpl*)Impl)->getIntegerSCEV(Val, Ty);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user