summaryrefslogtreecommitdiff
path: root/bolt/lib
diff options
context:
space:
mode:
authorAmir Ayupov <aaupov@fb.com>2023-02-27 15:21:23 -0800
committerAmir Ayupov <aaupov@fb.com>2023-02-27 15:22:43 -0800
commit1c286acfb81813951b7cb0651db648226d327d9a (patch)
treefda4d09bc9f6a08ecb8fb0e81e3db72b279d281d /bolt/lib
parent08ab4faf1aa338802ce7f482622dc020a2a26e08 (diff)
downloadllvm-1c286acfb81813951b7cb0651db648226d327d9a.tar.gz
[BOLT] Prevent unsetting unknown control flow for split jump table
In case of a function with unknown control flow but with a single jump table and a single jump table site, we attempt to match the jump table and a site and update block successors using jump table targets. Restrict this behavior for split jump tables which have targets in a fragment function. Fixes https://github.com/llvm/llvm-project/issues/60795. Reviewed By: #bolt, rafauler Differential Revision: https://reviews.llvm.org/D144602
Diffstat (limited to 'bolt/lib')
-rw-r--r--bolt/lib/Core/BinaryFunction.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index d1a046791d46..13c5fd444ea4 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -1770,6 +1770,8 @@ bool BinaryFunction::validateExternallyReferencedOffsets() {
bool BinaryFunction::postProcessIndirectBranches(
MCPlusBuilder::AllocatorIdTy AllocId) {
auto addUnknownControlFlow = [&](BinaryBasicBlock &BB) {
+ LLVM_DEBUG(dbgs() << "BOLT-DEBUG: adding unknown control flow in " << *this
+ << " for " << BB.getName() << "\n");
HasUnknownControlFlow = true;
BB.removeAllSuccessors();
for (uint64_t PossibleDestination : ExternallyReferencedOffsets)
@@ -1877,7 +1879,10 @@ bool BinaryFunction::postProcessIndirectBranches(
// references, then we should be able to derive the jump table even if we
// fail to match the pattern.
if (HasUnknownControlFlow && NumIndirectJumps == 1 &&
- JumpTables.size() == 1 && LastIndirectJump) {
+ JumpTables.size() == 1 && LastIndirectJump &&
+ !BC.getJumpTableContainingAddress(LastJT)->IsSplit) {
+ LLVM_DEBUG(dbgs() << "BOLT-DEBUG: unsetting unknown control flow in "
+ << *this << '\n');
BC.MIB->setJumpTable(*LastIndirectJump, LastJT, LastJTIndexReg, AllocId);
HasUnknownControlFlow = false;