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/MIRParser/MIParser.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/MIRParser/MIParser.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MIRParser/MIParser.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index 65280c6..c01b34d 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -500,7 +500,7 @@ public: bool parseAlignment(uint64_t &Alignment); bool parseAddrspace(unsigned &Addrspace); bool parseSectionID(std::optional<MBBSectionID> &SID); - bool parseBBID(std::optional<unsigned> &BBID); + bool parseBBID(std::optional<UniqueBBID> &BBID); bool parseCallFrameSize(unsigned &CallFrameSize); bool parseOperandsOffset(MachineOperand &Op); bool parseIRValue(const Value *&V); @@ -666,14 +666,20 @@ bool MIParser::parseSectionID(std::optional<MBBSectionID> &SID) { } // Parse Machine Basic Block ID. -bool MIParser::parseBBID(std::optional<unsigned> &BBID) { +bool MIParser::parseBBID(std::optional<UniqueBBID> &BBID) { assert(Token.is(MIToken::kw_bb_id)); lex(); - unsigned Value = 0; - if (getUnsigned(Value)) + unsigned BaseID = 0; + unsigned CloneID = 0; + if (getUnsigned(BaseID)) return error("Unknown BB ID"); - BBID = Value; lex(); + if (Token.is(MIToken::IntegerLiteral)) { + if (getUnsigned(CloneID)) + return error("Unknown Clone ID"); + lex(); + } + BBID = {BaseID, CloneID}; return false; } @@ -705,7 +711,7 @@ bool MIParser::parseBasicBlockDefinition( bool IsEHFuncletEntry = false; std::optional<MBBSectionID> SectionID; uint64_t Alignment = 0; - std::optional<unsigned> BBID; + std::optional<UniqueBBID> BBID; unsigned CallFrameSize = 0; BasicBlock *BB = nullptr; if (consumeIfPresent(MIToken::lparen)) { |