aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorRahman Lavaee <rahmanl@google.com>2020-10-26 16:15:56 -0700
committerRahman Lavaee <rahmanl@google.com>2020-10-26 16:15:56 -0700
commit0b2f4cdf2bd4e48974099cd441afaabc18ead227 (patch)
treea94f086450ddb54c617ae1b79b6950621c4205d6 /llvm/lib/CodeGen/MachineBasicBlock.cpp
parentd176e13ca55353c7ee8d4da23be6eae9f82a64e1 (diff)
downloadllvm-0b2f4cdf2bd4e48974099cd441afaabc18ead227.zip
llvm-0b2f4cdf2bd4e48974099cd441afaabc18ead227.tar.gz
llvm-0b2f4cdf2bd4e48974099cd441afaabc18ead227.tar.bz2
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
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp4
1 files changed, 4 insertions, 0 deletions
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());