Index: llvm/lib/IR/AsmWriter.cpp =================================================================== --- llvm/lib/IR/AsmWriter.cpp +++ llvm/lib/IR/AsmWriter.cpp @@ -3846,7 +3846,6 @@ /// printBasicBlock - This member is called for each basic block in a method. void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { - assert(BB && BB->getParent() && "block without parent!"); bool IsEntryBlock = BB->isEntryBlock(); if (BB->hasName()) { // Print out the label if it exists... Out << "\n"; Index: llvm/lib/IR/BasicBlock.cpp =================================================================== --- llvm/lib/IR/BasicBlock.cpp +++ llvm/lib/IR/BasicBlock.cpp @@ -374,7 +374,8 @@ bool BasicBlock::isEntryBlock() const { const Function *F = getParent(); - assert(F && "Block must have a parent function to use this API"); + if (F == nullptr) + return false; return this == &F->getEntryBlock(); }