Avoid crashing if instruction is not part of a loop.

If it is not part of a loop it is obviously invariant wrt to all loops.

llvm-svn: 58240
This commit is contained in:
Torok Edwin 2008-10-27 10:18:45 +00:00
parent bb026a0c63
commit 450ffd2f3e
1 changed files with 3 additions and 2 deletions

View File

@ -247,12 +247,13 @@ ConstantRange LoopVR::compute(Value *V) {
return ConstantRange(cast<IntegerType>(V->getType())->getBitWidth(), false); return ConstantRange(cast<IntegerType>(V->getType())->getBitWidth(), false);
LoopInfo &LI = getAnalysis<LoopInfo>(); LoopInfo &LI = getAnalysis<LoopInfo>();
ScalarEvolution &SE = getAnalysis<ScalarEvolution>();
Loop *L = LI.getLoopFor(I->getParent()); Loop *L = LI.getLoopFor(I->getParent());
if (L->isLoopInvariant(I)) if (!L || L->isLoopInvariant(I))
return ConstantRange(cast<IntegerType>(V->getType())->getBitWidth(), false); return ConstantRange(cast<IntegerType>(V->getType())->getBitWidth(), false);
ScalarEvolution &SE = getAnalysis<ScalarEvolution>();
SCEVHandle S = SE.getSCEV(I); SCEVHandle S = SE.getSCEV(I);
if (isa<SCEVUnknown>(S) || isa<SCEVCouldNotCompute>(S)) if (isa<SCEVUnknown>(S) || isa<SCEVCouldNotCompute>(S))
return ConstantRange(cast<IntegerType>(V->getType())->getBitWidth(), false); return ConstantRange(cast<IntegerType>(V->getType())->getBitWidth(), false);