[llvm] [BOLT] Add 'constant island' check in scanExternalRefs to prevent a crash when the function is disassembled fail or skipped (PR #165577)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 29 08:21:53 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- bolt/lib/Core/BinaryFunction.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index f8ef80d75..1a6a8b168 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -1701,15 +1701,16 @@ bool BinaryFunction::scanExternalRefs() {
           TargetAddress - TargetFunction->getAddress();
       if (!TargetFunction->isInConstantIsland(TargetAddress)) {
         BranchTargetSymbol =
-            FunctionOffset ? TargetFunction->addEntryPointAtOffset(FunctionOffset)
-                          : TargetFunction->getSymbol();
+            FunctionOffset
+                ? TargetFunction->addEntryPointAtOffset(FunctionOffset)
+                : TargetFunction->getSymbol();
       } else {
         TargetFunction->setIgnored();
         Success = false;
         BC.outs() << "BOLT-WARNING: Ignoring entry point at address 0x"
-                      << Twine::utohexstr(Address)
-                      << " in constant island of function " << *TargetFunction
-                      << '\n';
+                  << Twine::utohexstr(Address)
+                  << " in constant island of function " << *TargetFunction
+                  << '\n';
         break;
       }
     }

``````````

</details>


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


More information about the llvm-commits mailing list