Index: llvm/lib/Analysis/LoopInfo.cpp =================================================================== --- llvm/lib/Analysis/LoopInfo.cpp +++ llvm/lib/Analysis/LoopInfo.cpp @@ -367,6 +367,10 @@ "Expecting a loop with valid preheader and latch"); assert(isLoopExiting(Latch) && "Only valid for rotated loop"); + BasicBlock *Exiting = getExitingBlock(); + if (!Exiting) + return nullptr; + Instruction *LatchTI = Latch->getTerminator(); if (!LatchTI || LatchTI->getNumSuccessors() != 2) return nullptr;