Index: lib/IR/BasicBlock.cpp =================================================================== --- lib/IR/BasicBlock.cpp +++ lib/IR/BasicBlock.cpp @@ -264,7 +264,12 @@ } iterator_range BasicBlock::phis() { - return make_range(dyn_cast(&front()), nullptr); + PHINode *P = nullptr; + auto I = begin(); + if (I != end()) + P = dyn_cast(&*I); + + return make_range(P, nullptr); } /// This method is used to notify a BasicBlock that the