aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineFunction.cpp
diff options
context:
space:
mode:
authorRahman Lavaee <rahmanl@google.com>2020-09-14 10:16:44 -0700
committerRahman Lavaee <rahmanl@google.com>2020-09-14 10:16:44 -0700
commit7841e21c98495ba5e33e0d2507d985bd5b938445 (patch)
treeb9703371f791704f08408fba96dd1e9573312231 /llvm/lib/CodeGen/MachineFunction.cpp
parentce6dd973ac556a326c38bd7667b4fb448f215d09 (diff)
downloadllvm-7841e21c98495ba5e33e0d2507d985bd5b938445.zip
llvm-7841e21c98495ba5e33e0d2507d985bd5b938445.tar.gz
llvm-7841e21c98495ba5e33e0d2507d985bd5b938445.tar.bz2
Let -basic-block-sections=labels emit basicblock metadata in a new .bb_addr_map section, instead of emitting special unary-encoded symbols.
This patch introduces the new .bb_addr_map section feature which allows us to emit the bits needed for mapping binary profiles to basic blocks into a separate section. The format of the emitted data is represented as follows. It includes a header for every function: | Address of the function | -> 8 bytes (pointer size) | Number of basic blocks in this function (>0) | -> ULEB128 The header is followed by a BB record for every basic block. These records are ordered in the same order as MachineBasicBlocks are placed in the function. Each BB Info is structured as follows: | Offset of the basic block relative to function begin | -> ULEB128 | Binary size of the basic block | -> ULEB128 | BB metadata | -> ULEB128 [ MBB.isReturn() OR MBB.hasTailCall() << 1 OR MBB.isEHPad() << 2 ] The new feature will replace the existing "BB labels" functionality with -basic-block-sections=labels. The .bb_addr_map section scrubs the specially-encoded BB symbols from the binary and makes it friendly to profilers and debuggers. Furthermore, the new feature reduces the binary size overhead from 70% bloat to only 12%. For more information and results please refer to the RFC: https://lists.llvm.org/pipermail/llvm-dev/2020-July/143512.html Reviewed By: MaskRay, snehasish Differential Revision: https://reviews.llvm.org/D85408
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp27
1 files changed, 0 insertions, 27 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index 0950d64..e4473fd 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -341,33 +341,6 @@ void MachineFunction::RenumberBlocks(MachineBasicBlock *MBB) {
MBBNumbering.resize(BlockNo);
}
-/// This is used with -fbasic-block-sections or -fbasicblock-labels option.
-/// A unary encoding of basic block labels is done to keep ".strtab" sizes
-/// small.
-void MachineFunction::createBBLabels() {
- const TargetInstrInfo *TII = getSubtarget().getInstrInfo();
- this->BBSectionsSymbolPrefix.resize(getNumBlockIDs(), 'a');
- for (auto MBBI = begin(), E = end(); MBBI != E; ++MBBI) {
- assert(
- (MBBI->getNumber() >= 0 && MBBI->getNumber() < (int)getNumBlockIDs()) &&
- "BasicBlock number was out of range!");
- // 'a' - Normal block.
- // 'r' - Return block.
- // 'l' - Landing Pad.
- // 'L' - Return and landing pad.
- bool isEHPad = MBBI->isEHPad();
- bool isRetBlock = MBBI->isReturnBlock() && !TII->isTailCall(MBBI->back());
- char type = 'a';
- if (isEHPad && isRetBlock)
- type = 'L';
- else if (isEHPad)
- type = 'l';
- else if (isRetBlock)
- type = 'r';
- BBSectionsSymbolPrefix[MBBI->getNumber()] = type;
- }
-}
-
/// 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.