aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorRahman Lavaee <rahmanl@google.com>2020-04-13 12:12:34 -0700
committerRahman Lavaee <rahmanl@google.com>2020-04-13 12:19:59 -0700
commit4ddf7ab454b0b0e885e4970f3896adc53d1c64e4 (patch)
treed8a5e8c88e8cd803fce8a790c2251602bc729f5a /llvm/lib/CodeGen/MachineBasicBlock.cpp
parent5c7bbe3659a04c1d17deb3b50ab5b88204327842 (diff)
downloadllvm-4ddf7ab454b0b0e885e4970f3896adc53d1c64e4.zip
llvm-4ddf7ab454b0b0e885e4970f3896adc53d1c64e4.tar.gz
llvm-4ddf7ab454b0b0e885e4970f3896adc53d1c64e4.tar.bz2
Revert "Extend BasicBlock sections to allow specifying clusters of basic blocks"
This reverts commit 0d4ec16d3db3a92514e14101f635e8536c208c4f Because tests were not added to the commit.
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp50
1 files changed, 43 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index 5f46086..3fa60dd 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -62,9 +62,7 @@ MCSymbol *MachineBasicBlock::getSymbol() const {
MCContext &Ctx = MF->getContext();
auto Prefix = Ctx.getAsmInfo()->getPrivateLabelPrefix();
- // We emit a non-temporary symbol for every basic block if we have BBLabels
- // or -- with basic block sections -- when a basic block begins a section.
- bool BasicBlockSymbols = isBeginSection() || MF->hasBBLabels();
+ bool BasicBlockSymbols = MF->hasBBSections() || MF->hasBBLabels();
auto Delimiter = BasicBlockSymbols ? "." : "_";
assert(getNumber() >= 0 && "cannot get label for unreachable MBB");
@@ -550,6 +548,48 @@ void MachineBasicBlock::moveAfter(MachineBasicBlock *NewBefore) {
getParent()->splice(++NewBefore->getIterator(), getIterator());
}
+// Returns true if this basic block and the Other are in the same section.
+bool MachineBasicBlock::sameSection(const MachineBasicBlock *Other) const {
+ if (this == Other)
+ return true;
+
+ if (this->getSectionType() != Other->getSectionType())
+ return false;
+
+ // If either is in a unique section, return false.
+ if (this->getSectionType() == llvm::MachineBasicBlockSection::MBBS_Unique ||
+ Other->getSectionType() == llvm::MachineBasicBlockSection::MBBS_Unique)
+ return false;
+
+ return true;
+}
+
+const MachineBasicBlock *MachineBasicBlock::getSectionEndMBB() const {
+ if (this->isEndSection())
+ return this;
+ auto I = std::next(this->getIterator());
+ const MachineFunction *MF = getParent();
+ while (I != MF->end()) {
+ const MachineBasicBlock &MBB = *I;
+ if (MBB.isEndSection())
+ return &MBB;
+ I = std::next(I);
+ }
+ llvm_unreachable("No End Basic Block for this section.");
+}
+
+// Returns true if this block begins any section.
+bool MachineBasicBlock::isBeginSection() const {
+ return (SectionType == MBBS_Entry || SectionType == MBBS_Unique ||
+ getParent()->isSectionStartMBB(getNumber()));
+}
+
+// Returns true if this block begins any section.
+bool MachineBasicBlock::isEndSection() const {
+ return (SectionType == MBBS_Entry || SectionType == MBBS_Unique ||
+ getParent()->isSectionEndMBB(getNumber()));
+}
+
void MachineBasicBlock::updateTerminator() {
const TargetInstrInfo *TII = getParent()->getSubtarget().getInstrInfo();
// A block with no successors has no concerns with fall-through edges.
@@ -1532,7 +1572,3 @@ MachineBasicBlock::livein_iterator MachineBasicBlock::livein_begin() const {
"Liveness information is accurate");
return LiveIns.begin();
}
-
-const MBBSectionID MBBSectionID::ColdSectionID(MBBSectionID::SectionType::Cold);
-const MBBSectionID
- MBBSectionID::ExceptionSectionID(MBBSectionID::SectionType::Exception);