Deleted Added
full compact
112a113
>
113a115
>
144a147,150
> void SCEVCouldNotCompute::Profile(FoldingSetNodeID &ID) const {
> assert(0 && "Attempt to use a SCEVCouldNotCompute object!");
> }
>
177,179c183,191
< SCEVConstant *&R = SCEVConstants[V];
< if (R == 0) R = new SCEVConstant(V);
< return R;
---
> FoldingSetNodeID ID;
> ID.AddInteger(scConstant);
> ID.AddPointer(V);
> void *IP = 0;
> if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
> SCEV *S = SCEVAllocator.Allocate<SCEVConstant>();
> new (S) SCEVConstant(V);
> UniqueSCEVs.InsertNode(S, IP);
> return S;
190a203,207
> void SCEVConstant::Profile(FoldingSetNodeID &ID) const {
> ID.AddInteger(scConstant);
> ID.AddPointer(V);
> }
>
200a218,223
> void SCEVCastExpr::Profile(FoldingSetNodeID &ID) const {
> ID.AddInteger(getSCEVType());
> ID.AddPointer(Op);
> ID.AddPointer(Ty);
> }
>
279a303,309
> void SCEVNAryExpr::Profile(FoldingSetNodeID &ID) const {
> ID.AddInteger(getSCEVType());
> ID.AddInteger(Operands.size());
> for (unsigned i = 0, e = Operands.size(); i != e; ++i)
> ID.AddPointer(Operands[i]);
> }
>
287a318,323
> void SCEVUDivExpr::Profile(FoldingSetNodeID &ID) const {
> ID.AddInteger(scUDivExpr);
> ID.AddPointer(LHS);
> ID.AddPointer(RHS);
> }
>
304a341,348
> void SCEVAddRecExpr::Profile(FoldingSetNodeID &ID) const {
> ID.AddInteger(scAddRecExpr);
> ID.AddInteger(Operands.size());
> for (unsigned i = 0, e = Operands.size(); i != e; ++i)
> ID.AddPointer(Operands[i]);
> ID.AddPointer(L);
> }
>
348d391
<
355a399,403
> void SCEVUnknown::Profile(FoldingSetNodeID &ID) const {
> ID.AddInteger(scUnknown);
> ID.AddPointer(V);
> }
>
698a747
> // Fold if the operand is constant.
723,725c772,781
< SCEVTruncateExpr *&Result = SCEVTruncates[std::make_pair(Op, Ty)];
< if (Result == 0) Result = new SCEVTruncateExpr(Op, Ty);
< return Result;
---
> FoldingSetNodeID ID;
> ID.AddInteger(scTruncate);
> ID.AddPointer(Op);
> ID.AddPointer(Ty);
> void *IP = 0;
> if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
> SCEV *S = SCEVAllocator.Allocate<SCEVTruncateExpr>();
> new (S) SCEVTruncateExpr(Op, Ty);
> UniqueSCEVs.InsertNode(S, IP);
> return S;
735a792
> // Fold if the operand is constant.
811,813c868,877
< SCEVZeroExtendExpr *&Result = SCEVZeroExtends[std::make_pair(Op, Ty)];
< if (Result == 0) Result = new SCEVZeroExtendExpr(Op, Ty);
< return Result;
---
> FoldingSetNodeID ID;
> ID.AddInteger(scZeroExtend);
> ID.AddPointer(Op);
> ID.AddPointer(Ty);
> void *IP = 0;
> if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
> SCEV *S = SCEVAllocator.Allocate<SCEVZeroExtendExpr>();
> new (S) SCEVZeroExtendExpr(Op, Ty);
> UniqueSCEVs.InsertNode(S, IP);
> return S;
823a888
> // Fold if the operand is constant.
883,885c948,957
< SCEVSignExtendExpr *&Result = SCEVSignExtends[std::make_pair(Op, Ty)];
< if (Result == 0) Result = new SCEVSignExtendExpr(Op, Ty);
< return Result;
---
> FoldingSetNodeID ID;
> ID.AddInteger(scSignExtend);
> ID.AddPointer(Op);
> ID.AddPointer(Ty);
> void *IP = 0;
> if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
> SCEV *S = SCEVAllocator.Allocate<SCEVSignExtendExpr>();
> new (S) SCEVSignExtendExpr(Op, Ty);
> UniqueSCEVs.InsertNode(S, IP);
> return S;
983c1055
< M.insert(std::make_pair(Key, APInt()));
---
> M.insert(std::make_pair(Key, NewScale));
985d1056
< Pair.first->second = NewScale;
1002c1073
< M.insert(std::make_pair(Ops[i], APInt()));
---
> M.insert(std::make_pair(Ops[i], Scale));
1004d1074
< Pair.first->second = Scale;
1346,1350c1416,1426
< std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
< SCEVCommutativeExpr *&Result = SCEVCommExprs[std::make_pair(scAddExpr,
< SCEVOps)];
< if (Result == 0) Result = new SCEVAddExpr(Ops);
< return Result;
---
> FoldingSetNodeID ID;
> ID.AddInteger(scAddExpr);
> ID.AddInteger(Ops.size());
> for (unsigned i = 0, e = Ops.size(); i != e; ++i)
> ID.AddPointer(Ops[i]);
> void *IP = 0;
> if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
> SCEV *S = SCEVAllocator.Allocate<SCEVAddExpr>();
> new (S) SCEVAddExpr(Ops);
> UniqueSCEVs.InsertNode(S, IP);
> return S;
1511,1516c1587,1597
< std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
< SCEVCommutativeExpr *&Result = SCEVCommExprs[std::make_pair(scMulExpr,
< SCEVOps)];
< if (Result == 0)
< Result = new SCEVMulExpr(Ops);
< return Result;
---
> FoldingSetNodeID ID;
> ID.AddInteger(scMulExpr);
> ID.AddInteger(Ops.size());
> for (unsigned i = 0, e = Ops.size(); i != e; ++i)
> ID.AddPointer(Ops[i]);
> void *IP = 0;
> if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
> SCEV *S = SCEVAllocator.Allocate<SCEVMulExpr>();
> new (S) SCEVMulExpr(Ops);
> UniqueSCEVs.InsertNode(S, IP);
> return S;
1606,1608c1687,1696
< SCEVUDivExpr *&Result = SCEVUDivs[std::make_pair(LHS, RHS)];
< if (Result == 0) Result = new SCEVUDivExpr(LHS, RHS);
< return Result;
---
> FoldingSetNodeID ID;
> ID.AddInteger(scUDivExpr);
> ID.AddPointer(LHS);
> ID.AddPointer(RHS);
> void *IP = 0;
> if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
> SCEV *S = SCEVAllocator.Allocate<SCEVUDivExpr>();
> new (S) SCEVUDivExpr(LHS, RHS);
> UniqueSCEVs.InsertNode(S, IP);
> return S;
1680,1683c1768,1779
< std::vector<const SCEV*> SCEVOps(Operands.begin(), Operands.end());
< SCEVAddRecExpr *&Result = SCEVAddRecExprs[std::make_pair(L, SCEVOps)];
< if (Result == 0) Result = new SCEVAddRecExpr(Operands, L);
< return Result;
---
> FoldingSetNodeID ID;
> ID.AddInteger(scAddRecExpr);
> ID.AddInteger(Operands.size());
> for (unsigned i = 0, e = Operands.size(); i != e; ++i)
> ID.AddPointer(Operands[i]);
> ID.AddPointer(L);
> void *IP = 0;
> if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
> SCEV *S = SCEVAllocator.Allocate<SCEVAddRecExpr>();
> new (S) SCEVAddRecExpr(Operands, L);
> UniqueSCEVs.InsertNode(S, IP);
> return S;
1770,1774c1866,1876
< std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
< SCEVCommutativeExpr *&Result = SCEVCommExprs[std::make_pair(scSMaxExpr,
< SCEVOps)];
< if (Result == 0) Result = new SCEVSMaxExpr(Ops);
< return Result;
---
> FoldingSetNodeID ID;
> ID.AddInteger(scSMaxExpr);
> ID.AddInteger(Ops.size());
> for (unsigned i = 0, e = Ops.size(); i != e; ++i)
> ID.AddPointer(Ops[i]);
> void *IP = 0;
> if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
> SCEV *S = SCEVAllocator.Allocate<SCEVSMaxExpr>();
> new (S) SCEVSMaxExpr(Ops);
> UniqueSCEVs.InsertNode(S, IP);
> return S;
1861,1865c1963,1973
< std::vector<const SCEV*> SCEVOps(Ops.begin(), Ops.end());
< SCEVCommutativeExpr *&Result = SCEVCommExprs[std::make_pair(scUMaxExpr,
< SCEVOps)];
< if (Result == 0) Result = new SCEVUMaxExpr(Ops);
< return Result;
---
> FoldingSetNodeID ID;
> ID.AddInteger(scUMaxExpr);
> ID.AddInteger(Ops.size());
> for (unsigned i = 0, e = Ops.size(); i != e; ++i)
> ID.AddPointer(Ops[i]);
> void *IP = 0;
> if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
> SCEV *S = SCEVAllocator.Allocate<SCEVUMaxExpr>();
> new (S) SCEVUMaxExpr(Ops);
> UniqueSCEVs.InsertNode(S, IP);
> return S;
1886,1888c1994,2002
< SCEVUnknown *&Result = SCEVUnknowns[V];
< if (Result == 0) Result = new SCEVUnknown(V);
< return Result;
---
> FoldingSetNodeID ID;
> ID.AddInteger(scUnknown);
> ID.AddPointer(V);
> void *IP = 0;
> if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
> SCEV *S = SCEVAllocator.Allocate<SCEVUnknown>();
> new (S) SCEVUnknown(V);
> UniqueSCEVs.InsertNode(S, IP);
> return S;
1942c2056
< return CouldNotCompute;
---
> return &CouldNotCompute;
2753c2867
< if (ItCount.Exact != CouldNotCompute) {
---
> if (ItCount.Exact != getCouldNotCompute()) {
2762c2876
< if (ItCount.Max != CouldNotCompute)
---
> if (ItCount.Max != getCouldNotCompute())
2828,2829c2942,2943
< const SCEV* BECount = CouldNotCompute;
< const SCEV* MaxBECount = CouldNotCompute;
---
> const SCEV* BECount = getCouldNotCompute();
> const SCEV* MaxBECount = getCouldNotCompute();
2835c2949
< if (NewBTI.Exact == CouldNotCompute) {
---
> if (NewBTI.Exact == getCouldNotCompute()) {
2839c2953
< BECount = CouldNotCompute;
---
> BECount = getCouldNotCompute();
2841c2955
< if (BECount == CouldNotCompute)
---
> if (BECount == getCouldNotCompute())
2846c2960
< if (MaxBECount == CouldNotCompute)
---
> if (MaxBECount == getCouldNotCompute())
2848c2962
< else if (NewBTI.Max != CouldNotCompute)
---
> else if (NewBTI.Max != getCouldNotCompute())
2866c2980
< if (ExitBr == 0) return CouldNotCompute;
---
> if (ExitBr == 0) return getCouldNotCompute();
2895c3009
< return CouldNotCompute;
---
> return getCouldNotCompute();
2904c3018
< return CouldNotCompute;
---
> return getCouldNotCompute();
2913c3027
< return CouldNotCompute;
---
> return getCouldNotCompute();
2938,2939c3052,3053
< const SCEV* BECount = CouldNotCompute;
< const SCEV* MaxBECount = CouldNotCompute;
---
> const SCEV* BECount = getCouldNotCompute();
> const SCEV* MaxBECount = getCouldNotCompute();
2943,2944c3057,3059
< if (BTI0.Exact == CouldNotCompute || BTI1.Exact == CouldNotCompute)
< BECount = CouldNotCompute;
---
> if (BTI0.Exact == getCouldNotCompute() ||
> BTI1.Exact == getCouldNotCompute())
> BECount = getCouldNotCompute();
2947c3062
< if (BTI0.Max == CouldNotCompute)
---
> if (BTI0.Max == getCouldNotCompute())
2949c3064
< else if (BTI1.Max == CouldNotCompute)
---
> else if (BTI1.Max == getCouldNotCompute())
2956c3071,3072
< if (BTI0.Exact != CouldNotCompute && BTI1.Exact != CouldNotCompute)
---
> if (BTI0.Exact != getCouldNotCompute() &&
> BTI1.Exact != getCouldNotCompute())
2958c3074,3075
< if (BTI0.Max != CouldNotCompute && BTI1.Max != CouldNotCompute)
---
> if (BTI0.Max != getCouldNotCompute() &&
> BTI1.Max != getCouldNotCompute())
2970,2971c3087,3088
< const SCEV* BECount = CouldNotCompute;
< const SCEV* MaxBECount = CouldNotCompute;
---
> const SCEV* BECount = getCouldNotCompute();
> const SCEV* MaxBECount = getCouldNotCompute();
2975,2976c3092,3094
< if (BTI0.Exact == CouldNotCompute || BTI1.Exact == CouldNotCompute)
< BECount = CouldNotCompute;
---
> if (BTI0.Exact == getCouldNotCompute() ||
> BTI1.Exact == getCouldNotCompute())
> BECount = getCouldNotCompute();
2979c3097
< if (BTI0.Max == CouldNotCompute)
---
> if (BTI0.Max == getCouldNotCompute())
2981c3099
< else if (BTI1.Max == CouldNotCompute)
---
> else if (BTI1.Max == getCouldNotCompute())
2988c3106,3107
< if (BTI0.Exact != CouldNotCompute && BTI1.Exact != CouldNotCompute)
---
> if (BTI0.Exact != getCouldNotCompute() &&
> BTI1.Exact != getCouldNotCompute())
2990c3109,3110
< if (BTI0.Max != CouldNotCompute && BTI1.Max != CouldNotCompute)
---
> if (BTI0.Max != getCouldNotCompute() &&
> BTI1.Max != getCouldNotCompute())
3167c3287
< if (LI->isVolatile()) return CouldNotCompute;
---
> if (LI->isVolatile()) return getCouldNotCompute();
3171c3291
< if (!GEP) return CouldNotCompute;
---
> if (!GEP) return getCouldNotCompute();
3179c3299
< return CouldNotCompute;
---
> return getCouldNotCompute();
3189c3309
< if (VarIdx) return CouldNotCompute; // Multiple non-constant idx's.
---
> if (VarIdx) return getCouldNotCompute(); // Multiple non-constant idx's.
3206c3326
< return CouldNotCompute;
---
> return getCouldNotCompute();
3233c3353
< return CouldNotCompute;
---
> return getCouldNotCompute();
3374c3494
< /// evaluate the trip count of the loop, return CouldNotCompute.
---
> /// evaluate the trip count of the loop, return getCouldNotCompute().
3380c3500
< if (PN == 0) return CouldNotCompute;
---
> if (PN == 0) return getCouldNotCompute();
3388c3508
< if (StartCST == 0) return CouldNotCompute; // Must be a constant.
---
> if (StartCST == 0) return getCouldNotCompute(); // Must be a constant.
3392c3512
< if (PN2 != PN) return CouldNotCompute; // Not derived from same PHI.
---
> if (PN2 != PN) return getCouldNotCompute(); // Not derived from same PHI.
3405c3525
< if (!CondVal) return CouldNotCompute;
---
> if (!CondVal) return getCouldNotCompute();
3408d3527
< ConstantEvolutionLoopExitValue[PN] = PHIVal;
3416c3535
< return CouldNotCompute; // Couldn't evaluate or not making progress...
---
> return getCouldNotCompute();// Couldn't evaluate or not making progress...
3421c3540
< return CouldNotCompute;
---
> return getCouldNotCompute();
3460c3579
< if (RV) return getUnknown(RV);
---
> if (RV) return getSCEV(RV);
3474c3593
< return Pair.first->second ? &*getUnknown(Pair.first->second) : V;
---
> return Pair.first->second ? &*getSCEV(Pair.first->second) : V;
3523c3642
< return getUnknown(C);
---
> return getSCEV(C);
3577c3696
< if (BackedgeTakenCount == CouldNotCompute) return AddRec;
---
> if (BackedgeTakenCount == getCouldNotCompute()) return AddRec;
3732c3851
< return CouldNotCompute; // Otherwise it will loop infinitely.
---
> return getCouldNotCompute(); // Otherwise it will loop infinitely.
3737c3856
< return CouldNotCompute;
---
> return getCouldNotCompute();
3801c3920
< return CouldNotCompute;
---
> return getCouldNotCompute();
3817c3936
< return CouldNotCompute; // Otherwise it will loop infinitely.
---
> return getCouldNotCompute(); // Otherwise it will loop infinitely.
3822c3941
< return CouldNotCompute;
---
> return getCouldNotCompute();
4040c4159
< return CouldNotCompute;
---
> return getCouldNotCompute();
4052c4171
< if (!RHS->isLoopInvariant(L)) return CouldNotCompute;
---
> if (!RHS->isLoopInvariant(L)) return getCouldNotCompute();
4056c4175
< return CouldNotCompute;
---
> return getCouldNotCompute();
4066c4185
< return CouldNotCompute;
---
> return getCouldNotCompute();
4077c4196
< return CouldNotCompute;
---
> return getCouldNotCompute();
4082c4201
< return CouldNotCompute;
---
> return getCouldNotCompute();
4086c4205
< return CouldNotCompute;
---
> return getCouldNotCompute();
4089c4208
< return CouldNotCompute;
---
> return getCouldNotCompute();
4129c4248
< const SCEV* MaxBECount = getBECount(MinStart, MaxEnd, Step);;
---
> const SCEV* MaxBECount = getBECount(MinStart, MaxEnd, Step);
4134c4253
< return CouldNotCompute;
---
> return getCouldNotCompute();
4322c4441
< : FunctionPass(&ID), CouldNotCompute(new SCEVCouldNotCompute()) {
---
> : FunctionPass(&ID) {
4337,4375c4456,4457
<
< for (std::map<ConstantInt*, SCEVConstant*>::iterator
< I = SCEVConstants.begin(), E = SCEVConstants.end(); I != E; ++I)
< delete I->second;
< for (std::map<std::pair<const SCEV*, const Type*>,
< SCEVTruncateExpr*>::iterator I = SCEVTruncates.begin(),
< E = SCEVTruncates.end(); I != E; ++I)
< delete I->second;
< for (std::map<std::pair<const SCEV*, const Type*>,
< SCEVZeroExtendExpr*>::iterator I = SCEVZeroExtends.begin(),
< E = SCEVZeroExtends.end(); I != E; ++I)
< delete I->second;
< for (std::map<std::pair<unsigned, std::vector<const SCEV*> >,
< SCEVCommutativeExpr*>::iterator I = SCEVCommExprs.begin(),
< E = SCEVCommExprs.end(); I != E; ++I)
< delete I->second;
< for (std::map<std::pair<const SCEV*, const SCEV*>, SCEVUDivExpr*>::iterator
< I = SCEVUDivs.begin(), E = SCEVUDivs.end(); I != E; ++I)
< delete I->second;
< for (std::map<std::pair<const SCEV*, const Type*>,
< SCEVSignExtendExpr*>::iterator I = SCEVSignExtends.begin(),
< E = SCEVSignExtends.end(); I != E; ++I)
< delete I->second;
< for (std::map<std::pair<const Loop *, std::vector<const SCEV*> >,
< SCEVAddRecExpr*>::iterator I = SCEVAddRecExprs.begin(),
< E = SCEVAddRecExprs.end(); I != E; ++I)
< delete I->second;
< for (std::map<Value*, SCEVUnknown*>::iterator I = SCEVUnknowns.begin(),
< E = SCEVUnknowns.end(); I != E; ++I)
< delete I->second;
<
< SCEVConstants.clear();
< SCEVTruncates.clear();
< SCEVZeroExtends.clear();
< SCEVCommExprs.clear();
< SCEVUDivs.clear();
< SCEVSignExtends.clear();
< SCEVAddRecExprs.clear();
< SCEVUnknowns.clear();
---
> UniqueSCEVs.clear();
> SCEVAllocator.Reset();