[PATCH] D130673: [BOLT] Handle jump tables that point to skipped functions

Huan Nguyen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 27 16:30:33 PDT 2022


nhuhuan created this revision.
Herald added a reviewer: rafauler.
Herald added a subscriber: ayermolo.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
nhuhuan requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.

Functions can be optionally skipped by users, or marked as ignored
during branch target analysis. Since the target function is not
processed, functions that access jump tables which point to these
target functions also need to be marked as ignored.

Test Plan:

  ninja check-bolt


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130673

Files:
  bolt/lib/Core/BinaryFunction.cpp


Index: bolt/lib/Core/BinaryFunction.cpp
===================================================================
--- bolt/lib/Core/BinaryFunction.cpp
+++ bolt/lib/Core/BinaryFunction.cpp
@@ -1668,12 +1668,23 @@
             break;
           }
         }
+
         if (IsBuiltIn)
           continue;
-        // Create local label for targets cannot be reached by other fragments
-        // Otherwise, secondary entry point to target function
+
+        // Functions can be optionally skipped by users, or marked as ignored
+        // during branch target analysis. Since the target function is not
+        // processed, functions that access jump tables which point to these
+        // target functions also need to be marked as ignored
         BinaryFunction *TargetBF =
             BC.getBinaryFunctionContainingAddress(EntryAddress);
+        if (TargetBF->getState() != BinaryFunction::State::Disassembled ||
+            TargetBF->isIgnored()) {
+          setIgnored();
+          return;
+        }
+        // Create local label for targets cannot be reached by other fragments
+        // Otherwise, register as a secondary entry point to target function
         if (TargetBF->getAddress() != EntryAddress) {
           MCSymbol *Label =
               (HasOneParent && TargetBF == this)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130673.448208.patch
Type: text/x-patch
Size: 1302 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220727/57fa71fd/attachment.bin>


More information about the llvm-commits mailing list