diff options
author | Rahman Lavaee <rahmanl@google.com> | 2023-10-27 21:49:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-27 21:49:39 -0700 |
commit | f70e39ec173192058976805a2c51ac438bb2ff2f (patch) | |
tree | 35cc65ac2a9a88826df9dea732d6afbfa22e9bdd /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | 3cd2a0bc1a2dcf851f1821765946b77d0e65bd2e (diff) | |
download | llvm-f70e39ec173192058976805a2c51ac438bb2ff2f.zip llvm-f70e39ec173192058976805a2c51ac438bb2ff2f.tar.gz llvm-f70e39ec173192058976805a2c51ac438bb2ff2f.tar.bz2 |
[BasicBlockSections] Apply path cloning with -basic-block-sections. (#68860)
https://github.com/llvm/llvm-project/commit/28b912687900bc0a67cd61c374fce296b09963c4
introduced the path cloning format in the basic-block-sections profile.
This PR validates and applies path clonings.
A path cloning is valid if all of these conditions hold:
1. All bb ids in the path are mapped to existing blocks.
2. Each two consecutive bb ids in the path have a successor relationship
in the CFG.
3. The path does not include a block with indirect branches, except
possibly as the last block.
Applying a path cloning involves cloning all blocks in the path (except
the first one) and setting up their branches.
Once all clonings are applied, the cluster information is used to guide
block layout in the modified function.
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 5f9e4a6..ef8e1bd 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -567,7 +567,9 @@ void MachineBasicBlock::printName(raw_ostream &os, unsigned printNameFlags, } if (getBBID().has_value()) { os << (hasAttributes ? ", " : " ("); - os << "bb_id " << *getBBID(); + os << "bb_id " << getBBID()->BaseID; + if (getBBID()->CloneID != 0) + os << " " << getBBID()->CloneID; hasAttributes = true; } if (CallFrameSize != 0) { @@ -886,7 +888,7 @@ void MachineBasicBlock::replaceSuccessor(MachineBasicBlock *Old, removeSuccessor(OldI); } -void MachineBasicBlock::copySuccessor(MachineBasicBlock *Orig, +void MachineBasicBlock::copySuccessor(const MachineBasicBlock *Orig, succ_iterator I) { if (!Orig->Probs.empty()) addSuccessor(*I, Orig->getSuccProbability(I)); |