[llvm] [SampleFDO][TypeProf]Support vtable type profiling for ext-binary and text format (PR #148002)

David Li via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 24 12:53:51 PDT 2025


================
@@ -989,6 +1018,42 @@ class FunctionSamples {
     return CallsiteSamples;
   }
 
+  /// Returns vtable access samples for the C++ types collcted in this function.
+  const CallsiteTypeMap &getCallsiteTypeCounts() const {
+    return VirtualCallsiteTypeCounts;
+  }
+
+  /// Returns the vtable access samples for the C++ types at the un-drifted
+  /// location of \p Loc.
+  TypeCountMap &getTypeSamplesAt(const LineLocation &Loc) {
+    return VirtualCallsiteTypeCounts[mapIRLocToProfileLoc(Loc)];
+  }
+
+  /// Scale \p Other sample counts by \p Weight and add the scaled result to the
+  /// type samples for the undrifted location of \p Loc.
+  template <typename T>
+  sampleprof_error addCallsiteVTableTypeProfAt(const LineLocation &Loc,
+                                               const T &Other,
+                                               uint64_t Weight = 1) {
+    static_assert((std::is_same_v<typename T::key_type, StringRef> ||
----------------
david-xl wrote:

FunctionId can represent StringRef. Is it possible to untemplatize the function?

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


More information about the llvm-commits mailing list