[llvm] [BOLT] Check if symbol is in data area of function (PR #160143)

Asher Dobrescu via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 25 08:07:07 PDT 2025


================
@@ -2374,8 +2374,16 @@ BinaryFunction *BinaryContext::getFunctionForSymbol(const MCSymbol *Symbol,
     return nullptr;
 
   BinaryFunction *BF = BFI->second;
-  if (EntryDesc)
+  if (EntryDesc) {
+    const uint64_t Address = BF->getAddress() + Symbol->getOffset();
----------------
Asher8118 wrote:

As far as I understand, if `Symbol->getOffset()` does not return the symbol offset, then it returns `0`. In which case `const uint64_t Address = BF->getAddress() + Symbol->getOffset();` becomes the same as `BF->getAddress()`. For the purpose of this patch, I think that is fine. Whether we're checking the function address or the symbol address, the point is to check if we're in a data area (constant island) before proceeding. This check is only reached in `getFunctionForSymbol` as a way to prevent calling `getEntryIDForSymbol`, and avoid hitting the `llvm_unreachable`, if we're in a data area.

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


More information about the llvm-commits mailing list