[llvm] [BOLT] Add validation for direct call/branch targets, bypassing invalid functions (PR #165406)

Maksim Panchenko via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 4 17:04:21 PST 2025


================
@@ -1902,6 +1910,71 @@ bool BinaryFunction::scanExternalRefs() {
   return Success;
 }
 
+bool BinaryFunction::validateExternalBranch(uint64_t TargetAddress) {
----------------
maksfb wrote:

This function has some similarities with `processInterproceduralReferences()` from which it is called from. I think the code will be more clear if we modify `processInterproceduralReferences()` directly. E.g., you can handle `nullptr` return from `handleExternalBranchTarget()` as an invalid reference and similarly treat conditions when the `Section` is not found or is not a code section. WDYT?

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


More information about the llvm-commits mailing list