[llvm] [StaticDataLayout][PGO]Implement reader and writer change for data access profiles (PR #139997)
Mingming Liu via llvm-commits
llvm-commits at lists.llvm.org
Wed May 21 16:24:10 PDT 2025
================
@@ -10,14 +10,20 @@
//
//===----------------------------------------------------------------------===//
+#include "llvm/ProfileData/DataAccessProf.h"
#include "llvm/ProfileData/InstrProf.h"
#include "llvm/ProfileData/MemProf.h"
+#include <functional>
+#include <optional>
+
namespace llvm {
// Write the MemProf data to OS.
-Error writeMemProf(ProfOStream &OS, memprof::IndexedMemProfData &MemProfData,
- memprof::IndexedVersion MemProfVersionRequested,
- bool MemProfFullSchema);
+Error writeMemProf(
+ ProfOStream &OS, memprof::IndexedMemProfData &MemProfData,
+ memprof::IndexedVersion MemProfVersionRequested, bool MemProfFullSchema,
+ std::optional<std::reference_wrapper<data_access_prof::DataAccessProfData>>
----------------
mingmingl-llvm wrote:
> I think there is no need for the DataAccessProf record object to be valid after `writeMemProf` is called. How about just use `std::unique_ptr<DataAccessProfData>` as the param and move the contents here if valid. Then we can check if the pointer is not null inside. Wdyt?
Sounds reasonable. Done.
> If you change the namespace to memprof then you won't need this extra qualification here.
To save `memprof::` before `writeMemProf` parameters, we need to put `writeMemProf` function inside `memprof` namespace. I don't feel strong about this, and removing `optional<reference_wrapper<T>>` already simplified parameter a lot.
https://github.com/llvm/llvm-project/pull/139997
More information about the llvm-commits
mailing list