Skip to content

Commit 3f2a9e5

Browse files
authored
[BOLT] Sort TakenBranches immediately before use. NFCI (llvm#83333)
Move code that sorts TakenBranches right before the branches are used. We can populate TakenBranches in pre-CFG post-processing and hence have to postpone the sorting to a later point in the processing pipeline. Will add such a pass later. For now it's NFC.
1 parent ffa48f0 commit 3f2a9e5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1759,13 +1759,6 @@ void BinaryFunction::postProcessJumpTables() {
17591759
}
17601760
}
17611761
}
1762-
1763-
// Remove duplicates branches. We can get a bunch of them from jump tables.
1764-
// Without doing jump table value profiling we don't have use for extra
1765-
// (duplicate) branches.
1766-
llvm::sort(TakenBranches);
1767-
auto NewEnd = std::unique(TakenBranches.begin(), TakenBranches.end());
1768-
TakenBranches.erase(NewEnd, TakenBranches.end());
17691762
}
17701763

17711764
bool BinaryFunction::validateExternallyReferencedOffsets() {
@@ -2128,6 +2121,13 @@ Error BinaryFunction::buildCFG(MCPlusBuilder::AllocatorIdTy AllocatorId) {
21282121
// e.g. exit(3), etc. Otherwise we'll see a false fall-through
21292122
// blocks.
21302123

2124+
// Remove duplicates branches. We can get a bunch of them from jump tables.
2125+
// Without doing jump table value profiling we don't have a use for extra
2126+
// (duplicate) branches.
2127+
llvm::sort(TakenBranches);
2128+
auto NewEnd = std::unique(TakenBranches.begin(), TakenBranches.end());
2129+
TakenBranches.erase(NewEnd, TakenBranches.end());
2130+
21312131
for (std::pair<uint32_t, uint32_t> &Branch : TakenBranches) {
21322132
LLVM_DEBUG(dbgs() << "registering branch [0x"
21332133
<< Twine::utohexstr(Branch.first) << "] -> [0x"

0 commit comments

Comments
 (0)