diff options
author | Rahman Lavaee <rahmanl@google.com> | 2020-04-13 12:12:34 -0700 |
---|---|---|
committer | Rahman Lavaee <rahmanl@google.com> | 2020-04-13 12:19:59 -0700 |
commit | 4ddf7ab454b0b0e885e4970f3896adc53d1c64e4 (patch) | |
tree | d8a5e8c88e8cd803fce8a790c2251602bc729f5a /llvm/lib/CodeGen/MachineFunction.cpp | |
parent | 5c7bbe3659a04c1d17deb3b50ab5b88204327842 (diff) | |
download | llvm-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/MachineFunction.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineFunction.cpp | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 464f389..1b89333 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -340,6 +340,32 @@ void MachineFunction::RenumberBlocks(MachineBasicBlock *MBB) { MBBNumbering.resize(BlockNo); } +/// This sets the section ranges of cold or exception section with basic block +/// sections. +void MachineFunction::setSectionRange() { + // Compute the Section Range of cold and exception basic blocks. Find the + // first and last block of each range. + auto SectionRange = + ([&](llvm::MachineBasicBlockSection S) -> std::pair<int, int> { + auto MBBP = + std::find_if(begin(), end(), [&](MachineBasicBlock &MBB) -> bool { + return MBB.getSectionType() == S; + }); + if (MBBP == end()) + return std::make_pair(-1, -1); + + auto MBBQ = + std::find_if(rbegin(), rend(), [&](MachineBasicBlock &MBB) -> bool { + return MBB.getSectionType() == S; + }); + assert(MBBQ != rend() && "Section end not found!"); + return std::make_pair(MBBP->getNumber(), MBBQ->getNumber()); + }); + + ExceptionSectionRange = SectionRange(MBBS_Exception); + ColdSectionRange = SectionRange(llvm::MBBS_Cold); +} + /// This is used with -fbasicblock-sections or -fbasicblock-labels option. /// A unary encoding of basic block labels is done to keep ".strtab" sizes /// small. @@ -367,22 +393,6 @@ void MachineFunction::createBBLabels() { } } -/// This method iterates over the basic blocks and assigns their IsBeginSection -/// and IsEndSection fields. This must be called after MBB layout is finalized -/// and the SectionID's are assigned to MBBs. -void MachineFunction::assignBeginEndSections() { - front().setIsBeginSection(); - auto CurrentSectionID = front().getSectionID(); - for (auto MBBI = std::next(begin()), E = end(); MBBI != E; ++MBBI) { - if (MBBI->getSectionID() == CurrentSectionID) - continue; - MBBI->setIsBeginSection(); - std::prev(MBBI)->setIsEndSection(); - CurrentSectionID = MBBI->getSectionID(); - } - back().setIsEndSection(); -} - /// Allocate a new MachineInstr. Use this instead of `new MachineInstr'. MachineInstr *MachineFunction::CreateMachineInstr(const MCInstrDesc &MCID, const DebugLoc &DL, |