[PATCH] D132495: [BOLT] Improve recognition of unknown control flow

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 23 13:13:51 PDT 2022


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

For functions with references to internal offsets from data but with no
recognized jump tables, add externally referenced blocks as entry points and
mark the function as having an unknown control flow.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132495

Files:
  bolt/lib/Core/BinaryFunction.cpp


Index: bolt/lib/Core/BinaryFunction.cpp
===================================================================
--- bolt/lib/Core/BinaryFunction.cpp
+++ bolt/lib/Core/BinaryFunction.cpp
@@ -1842,6 +1842,16 @@
   if (HasInternalLabelReference)
     return false;
 
+  // If there are references to function internals from data but the function
+  // does not have recognized jump tables, mark it as having unknown control
+  // flow and register externally referenced blocks as entry points.
+  if (hasInternalReference() && JumpTables.empty()) {
+    HasUnknownControlFlow = true;
+    for (uint64_t PossibleDestination : ExternallyReferencedOffsets)
+      if (BinaryBasicBlock *BB = getBasicBlockAtOffset(PossibleDestination))
+        addEntryPoint(*BB);
+  }
+
   // If there's only one jump table, and one indirect jump, and no other
   // references, then we should be able to derive the jump table even if we
   // fail to match the pattern.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132495.454936.patch
Type: text/x-patch
Size: 945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220823/f3a034fe/attachment.bin>


More information about the llvm-commits mailing list