From 0b2f4cdf2bd4e48974099cd441afaabc18ead227 Mon Sep 17 00:00:00 2001 From: Rahman Lavaee Date: Mon, 26 Oct 2020 16:15:56 -0700 Subject: Explicitly check for entry basic block, rather than relying on MachineBasicBlock::pred_empty. Sometimes in unoptimized code, we have dangling unreachable basic blocks with no predecessors. Basic block sections should be emitted for those as well. Without this patch, the included test fails with a fatal error in `AsmPrinter::emitBasicBlockEnd`. Reviewed By: tmsriram Differential Revision: https://reviews.llvm.org/D89423 --- llvm/lib/CodeGen/MachineBasicBlock.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp') diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 13ece5e..c203ad1 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -266,6 +266,10 @@ bool MachineBasicBlock::hasEHPadSuccessor() const { return false; } +bool MachineBasicBlock::isEntryBlock() const { + return getParent()->begin() == getIterator(); +} + #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void MachineBasicBlock::dump() const { print(dbgs()); -- cgit v1.1