[llvm] [llvm-profgen] Set FirstLoadableAddress only once (PR #151257)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 29 16:53:18 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-pgo
Author: Wei Wang (apolloww)
<details>
<summary>Changes</summary>
The address of the first loadable segment can be zero, so `FirstLoadableAddress` may actually point to the second loadable segment. Use an optional instead.
---
Full diff: https://github.com/llvm/llvm-project/pull/151257.diff
1 Files Affected:
- (modified) llvm/tools/llvm-profgen/ProfiledBinary.h (+5-2)
``````````diff
diff --git a/llvm/tools/llvm-profgen/ProfiledBinary.h b/llvm/tools/llvm-profgen/ProfiledBinary.h
index 0588cb48b2af6..8bc7e7b3b0061 100644
--- a/llvm/tools/llvm-profgen/ProfiledBinary.h
+++ b/llvm/tools/llvm-profgen/ProfiledBinary.h
@@ -199,7 +199,7 @@ class ProfiledBinary {
// The runtime base address that the first executable segment is loaded at.
uint64_t BaseAddress = 0;
// The runtime base address that the first loadabe segment is loaded at.
- uint64_t FirstLoadableAddress = 0;
+ std::optional<uint64_t> FirstLoadableAddress;
// The preferred load address of each executable segment.
std::vector<uint64_t> PreferredTextSegmentAddresses;
// The file offset of each executable segment.
@@ -381,7 +381,10 @@ class ProfiledBinary {
return PreferredTextSegmentAddresses[0];
}
// Return the preferred load address for the first loadable segment.
- uint64_t getFirstLoadableAddress() const { return FirstLoadableAddress; }
+ uint64_t getFirstLoadableAddress() const {
+ assert(FirstLoadableAddress && "FirstLoadableAddress must be set.");
+ return *FirstLoadableAddress;
+ }
// Return the file offset for the first executable segment.
uint64_t getTextSegmentOffset() const { return TextSegmentOffsets[0]; }
const std::vector<uint64_t> &getPreferredTextSegmentAddresses() const {
``````````
</details>
https://github.com/llvm/llvm-project/pull/151257
More information about the llvm-commits
mailing list