[llvm] [ProfileData] Introduce SampleProfileFuncOffsetTable (NFC) (PR #205045)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 25 09:43:33 PDT 2026
================
@@ -908,6 +908,79 @@ class FuncOffsetHashTableInfo {
}
};
+/// A unified wrapper representing the function offset table.
+///
+/// This class abstracts away the physical representation of the offset table,
+/// which can either be:
+///
+/// - An llvm::DenseMap mapping function GUIDs (or context hashes) to their
+/// profile offsets, populated when reading the array of offsets in
+/// context-sensitive (CS) profiles or version 103 profiles.
+///
+/// - An OnDiskIterableChainedHashTable providing the same mapping directly from
+/// the file in (non-context-sensitive) version 104 profiles.
+///
+/// It exposes a single, type-agnostic lookup interface, shielding the reader
+/// from the underlying container types. To prevent hybrid-state corruption, it
+/// enforces mutually exclusive paths using assertions.
+class SampleProfileFuncOffsetTable {
----------------
kazutakahirata wrote:
> can you templatize the class instead?
Thanks! Since the format choice is a runtime decision, templatizing the table just shifts the problem.
The reader would have to hold both instantiations (moving the hybrid state and dispatch logic into the reader, losing encapsulation). The current hybrid class cleanly encapsulates this dispatch with negligible overhead.
https://github.com/llvm/llvm-project/pull/205045
More information about the llvm-commits
mailing list