diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 5e818bcbe19..9357d8fb6ea 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -250,7 +250,8 @@ public: // isLoopHeader - True if the block is a loop header node bool isLoopHeader(BasicBlock *BB) const { - return getLoopFor(BB)->getHeader() == BB; + const Loop *L = getLoopFor(BB); + return L && L->getHeader() == BB; } /// runOnFunction - Calculate the natural loop information.