[llvm] [StaticDataLayout][PGO]Implement reader and writer change for data access profiles (PR #139997)

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed May 21 16:32:39 PDT 2025


================
@@ -100,18 +103,21 @@ using SymbolHandle = std::variant<std::string, uint64_t>;
 /// The data access profiles for a symbol.
 struct DataAccessProfRecord {
 public:
-  DataAccessProfRecord(SymbolHandleRef SymHandleRef,
-                       ArrayRef<internal::SourceLocationRef> LocRefs) {
+  DataAccessProfRecord(SymbolHandleRef SymHandleRef, uint64_t AccessCount,
+                       ArrayRef<internal::SourceLocationRef> LocRefs)
+      : AccessCount(AccessCount) {
     if (std::holds_alternative<StringRef>(SymHandleRef)) {
       SymHandle = std::get<StringRef>(SymHandleRef).str();
     } else
       SymHandle = std::get<uint64_t>(SymHandleRef);
 
     for (auto Loc : LocRefs)
-      Locations.push_back(SourceLocation(Loc.FileName, Loc.Line));
+      Locations.emplace_back(SourceLocation(Loc.FileName, Loc.Line));
----------------
snehasish wrote:

I think this can just be `Locations.emplace_back(Loc.FileName, Loc.Line)`. If we still pass it a temporary object I think we'll end up invoking the copy constructor?

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


More information about the llvm-commits mailing list