[llvm] [llvm-profgen][SPGO] Support profiles with multiple concurrent processes (PR #169353)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 11 18:23:39 PST 2025


================
@@ -198,7 +198,14 @@ class ProfiledBinary {
   // Options used to configure the symbolizer
   symbolize::LLVMSymbolizer::Options SymbolizerOpts;
   // The runtime base address that the first executable segment is loaded at.
-  uint64_t BaseAddress = 0;
+  // The binary may be loaded at different addresses in different processes,
+  // so we use a map to store base address by PID.
+  // If the profile doesn't contain PID info we use the default PID value
+  // (DefaultPID defined in PerfReaderBase).
+  std::unordered_map<int32_t, uint64_t> BaseAddressByPID;
----------------
HighW4y2H3ll wrote:

Why base address is a map depending on pid? The assumption is the binary simply forks and doesn’t move its text sections around? Otherwise we won’t be able to map addresses from different processes back to a consistent binary or function info. 

I think a bigger concern is how do we know if the sample is even correct? The binary is the single source of ground truth that we can use it to validate samples, but now we don’t know its base address? And the samples may come from  different binaries that may even have different function/text layout?

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


More information about the llvm-commits mailing list