diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 2c36ed98cb7..1823412755b 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -750,20 +750,24 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { else Out << ""; } - - if (BB != &BB->getParent()->front()) { // Not the entry block? - // Output predecessors for the block... - Out << "\t\t;"; - pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB); - - if (PI == PE) { - Out << " No predecessors!"; - } else { - Out << " preds ="; - writeOperand(*PI, false, true); - for (++PI; PI != PE; ++PI) { - Out << ","; + + if (BB->getParent() == 0) + Out << "\t\t; Error: Block without parent!"; + else { + if (BB != &BB->getParent()->front()) { // Not the entry block? + // Output predecessors for the block... + Out << "\t\t;"; + pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB); + + if (PI == PE) { + Out << " No predecessors!"; + } else { + Out << " preds ="; writeOperand(*PI, false, true); + for (++PI; PI != PE; ++PI) { + Out << ","; + writeOperand(*PI, false, true); + } } } }