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

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 12 05:08:51 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;
+  // The last PID we saw the binary loaded into. Used to warn the user if a
+  // binary is loaded in multiple processes without --multi-process-profile.
+  std::optional<int32_t> LastSeenPID = std::nullopt;
----------------
Heath123 wrote:

No, this is only used to check if the PID ever changed in order to emit a warning if that happens without the relevant flag enabled.

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


More information about the llvm-commits mailing list