Today the front-ends (llvm-gcc and clang) generate multiple llvm.dbg.compile_units...
[oota-llvm.git] / lib / Analysis / LoopVR.cpp
index 7f5de259caf366d2834799bafd75c6c58f2cb2e9..d0b77b89f0a4e85abe0d49854d6f5a788be97031 100644 (file)
@@ -247,12 +247,13 @@ ConstantRange LoopVR::compute(Value *V) {
     return ConstantRange(cast<IntegerType>(V->getType())->getBitWidth(), false);
 
   LoopInfo &LI = getAnalysis<LoopInfo>();
-  ScalarEvolution &SE = getAnalysis<ScalarEvolution>();
 
   Loop *L = LI.getLoopFor(I->getParent());
-  if (L->isLoopInvariant(I))
+  if (!L || L->isLoopInvariant(I))
     return ConstantRange(cast<IntegerType>(V->getType())->getBitWidth(), false);
 
+  ScalarEvolution &SE = getAnalysis<ScalarEvolution>();
+
   SCEVHandle S = SE.getSCEV(I);
   if (isa<SCEVUnknown>(S) || isa<SCEVCouldNotCompute>(S))
     return ConstantRange(cast<IntegerType>(V->getType())->getBitWidth(), false);