[llvm] [memprof] Fix IndexedMemProfRecord::clear (PR #118533)

via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 3 11:23:07 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

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.


---
Full diff: https://github.com/llvm/llvm-project/pull/118533.diff


1 Files Affected:

- (modified) llvm/include/llvm/ProfileData/MemProf.h (+4-1) 


``````````diff
diff --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h
index 47487c9342594a..b05fc08e8aeaea 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<CallStackId> 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

``````````

</details>


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


More information about the llvm-commits mailing list