Fix ScalarEvolution::isLoopGuardedByCond to accept a null Loop*, for
authorDan Gohman <gohman@apple.com>
Mon, 18 May 2009 16:03:58 +0000 (16:03 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 18 May 2009 16:03:58 +0000 (16:03 +0000)
consistency with other routines that use a null Loop* to mean code
not contained by any loop.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72008 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp

index 30d6e7088c82a03d3a63a1513d2f65b0846ae9e6..c53ec8a5f1a8d558cee2f5dc32853a691c312fca 100644 (file)
@@ -3328,6 +3328,10 @@ ScalarEvolution::getPredecessorWithUniqueSuccessorForBB(BasicBlock *BB) {
 bool ScalarEvolution::isLoopGuardedByCond(const Loop *L,
                                           ICmpInst::Predicate Pred,
                                           const SCEV *LHS, const SCEV *RHS) {
+  // Interpret a null as meaning no loop, where there is obviously no guard
+  // (interprocedural conditions notwithstanding).
+  if (!L) return false;
+
   BasicBlock *Predecessor = getLoopPredecessor(L);
   BasicBlock *PredecessorDest = L->getHeader();