[llvm] [BOLT] Validate that direct branch/call targets are valid instructions (PR #165406)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 28 07:40:46 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,h -- bolt/include/bolt/Core/BinaryFunction.h 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/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h
index 6fdc8336b..c9ec1b4ae 100644
--- a/bolt/include/bolt/Core/BinaryFunction.h
+++ b/bolt/include/bolt/Core/BinaryFunction.h
@@ -2239,8 +2239,7 @@ public:
/// Validates if the target of a direct branch/call is a valid
/// executable instruction.
/// Return true if the target is valid, false otherwise.
- bool validateBranchTarget(uint64_t TargetAddress,
- uint64_t AbsoluteInstrAddr,
+ bool validateBranchTarget(uint64_t TargetAddress, uint64_t AbsoluteInstrAddr,
const ArrayRef<uint8_t> &CurrentFunctionData);
/// Disassemble function from raw data.
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index 821a302d1..6c5d3c647 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -1286,8 +1286,7 @@ BinaryFunction::disassembleInstructionAtOffset(uint64_t Offset) const {
bool BinaryFunction::validateBranchTarget(
uint64_t TargetAddress, uint64_t AbsoluteInstrAddr,
const ArrayRef<uint8_t> &CurrentFunctionData) {
- if (auto *TargetFunc =
- BC.getBinaryFunctionContainingAddress(TargetAddress)) {
+ if (auto *TargetFunc = BC.getBinaryFunctionContainingAddress(TargetAddress)) {
const uint64_t TargetOffset = TargetAddress - TargetFunc->getAddress();
ArrayRef<uint8_t> TargetFunctionData;
// Check if the target address is within the current function.
``````````
</details>
https://github.com/llvm/llvm-project/pull/165406
More information about the llvm-commits
mailing list