[llvm] [BOLT][NFC] Simplify getOrCreate/analyze/populateJumpTables (PR #132108)

Maksim Panchenko via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 9 19:27:25 PDT 2025


================
@@ -645,24 +645,19 @@ bool BinaryContext::analyzeJumpTable(const uint64_t Address,
 
     // Function or one of its fragments.
     const BinaryFunction *TargetBF = getBinaryFunctionContainingAddress(Value);
-    const bool DoesBelongToFunction =
-        BF.containsAddress(Value) ||
-        (TargetBF && areRelatedFragments(TargetBF, &BF));
-    if (!DoesBelongToFunction) {
+    if (!TargetBF || !areRelatedFragments(TargetBF, &BF)) {
       LLVM_DEBUG({
-        if (!BF.containsAddress(Value)) {
-          dbgs() << "FAIL: function doesn't contain this address\n";
-          if (TargetBF) {
-            dbgs() << "  ! function containing this address: "
-                   << TargetBF->getPrintName() << '\n';
-            if (TargetBF->isFragment()) {
-              dbgs() << "  ! is a fragment";
-              for (BinaryFunction *Parent : TargetBF->ParentFragments)
-                dbgs() << ", parent: " << Parent->getPrintName();
-              dbgs() << '\n';
-            }
-          }
-        }
+        dbgs() << "FAIL: function doesn't contain this address\n";
+        if (!TargetBF)
+          break;
----------------
maksfb wrote:

Can you avoid using control flow instructions that depend on the context outside of `LLVM_DEBUG`? I.e. imagine what happens if we refactor the code outside and remove the `break` at 662. Perhaps even refactor the diagnostics to a new function so that the normal code flow is not disrupted.

https://github.com/llvm/llvm-project/pull/132108


More information about the llvm-commits mailing list