From 7ec7cd5d4fbb5b597f8180c6dda6f48122524aee Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 3 Dec 2024 11:07:42 -0800 Subject: [PATCH 1/2] [memprof] Fix IndexedMemProfRecord::clear This patch ensures that IndexedMemProfRecord::clear clears every field of IndexedMemProfRecord. This fix is not critical at the moment. The only use of this function is in RecordWriterTrait::EmitData to release the memory we are done with. That is, we never clear the data structure for the purpose of reusing it. --- llvm/include/llvm/ProfileData/MemProf.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h index 47487c9342594..b05fc08e8aeae 100644 --- a/llvm/include/llvm/ProfileData/MemProf.h +++ b/llvm/include/llvm/ProfileData/MemProf.h @@ -416,7 +416,10 @@ struct IndexedMemProfRecord { // the last entry in the list with the same function GUID. llvm::SmallVector CallSiteIds; - void clear() { AllocSites.clear(); } + void clear() { + AllocSites.clear(); + CallSiteIds.clear(); + } void merge(const IndexedMemProfRecord &Other) { // TODO: Filter out duplicates which may occur if multiple memprof From c94d56e27e1453571dd4a95fad4bf3f585a16356 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 3 Dec 2024 13:42:02 -0800 Subject: [PATCH 2/2] Address a comment. --- llvm/include/llvm/ProfileData/MemProf.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h index b05fc08e8aeae..6ffead4f13aeb 100644 --- a/llvm/include/llvm/ProfileData/MemProf.h +++ b/llvm/include/llvm/ProfileData/MemProf.h @@ -416,10 +416,7 @@ struct IndexedMemProfRecord { // the last entry in the list with the same function GUID. llvm::SmallVector CallSiteIds; - void clear() { - AllocSites.clear(); - CallSiteIds.clear(); - } + void clear() { *this = IndexedMemProfRecord(); } void merge(const IndexedMemProfRecord &Other) { // TODO: Filter out duplicates which may occur if multiple memprof