Skip to content

Conversation

kazutakahirata
Copy link
Contributor

This patch adds a default constructor to Frame along with a use in
FrameIdConverter.

The real intent is to facilitate deserialization of YAML-based MemProf
format. Note that the YAML parser default-constructs a struct and
then populates one field at a time.

This patch adds a default constructor to Frame along with a use in
FrameIdConverter.

The real intent is to facilitate deserialization of YAML-based MemProf
format.  Note that the YAML parser default-constructs a struct and
then populates one field at a time.
@llvmbot llvmbot added the PGO Profile Guided Optimizations label Nov 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 26, 2024

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

Changes

This patch adds a default constructor to Frame along with a use in
FrameIdConverter.

The real intent is to facilitate deserialization of YAML-based MemProf
format. Note that the YAML parser default-constructs a struct and
then populates one field at a time.


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

1 Files Affected:

  • (modified) llvm/include/llvm/ProfileData/MemProf.h (+6-5)
diff --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h
index dd4d90864a08c4..d64addcfe3ed06 100644
--- a/llvm/include/llvm/ProfileData/MemProf.h
+++ b/llvm/include/llvm/ProfileData/MemProf.h
@@ -212,18 +212,19 @@ using LinearFrameId = uint32_t;
 struct Frame {
   // A uuid (uint64_t) identifying the function. It is obtained by
   // llvm::md5(FunctionName) which returns the lower 64 bits.
-  GlobalValue::GUID Function;
+  GlobalValue::GUID Function = 0;
   // The symbol name for the function. Only populated in the Frame by the reader
   // if requested during initialization. This field should not be serialized.
   std::unique_ptr<std::string> SymbolName;
   // The source line offset of the call from the beginning of parent function.
-  uint32_t LineOffset;
+  uint32_t LineOffset = 0;
   // The source column number of the call to help distinguish multiple calls
   // on the same line.
-  uint32_t Column;
+  uint32_t Column = 0;
   // Whether the current frame is inlined.
-  bool IsInlineFrame;
+  bool IsInlineFrame = false;
 
+  Frame() = default;
   Frame(const Frame &Other) {
     Function = Other.Function;
     SymbolName = Other.SymbolName
@@ -817,7 +818,7 @@ template <typename MapTy> struct FrameIdConverter {
     auto Iter = Map.find(Id);
     if (Iter == Map.end()) {
       LastUnmappedId = Id;
-      return Frame(0, 0, 0, false);
+      return Frame();
     }
     return detail::DerefIterator<Frame>(Iter);
   }

Copy link
Contributor

@snehasish snehasish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@kazutakahirata kazutakahirata merged commit 09e7477 into llvm:main Nov 26, 2024
10 checks passed
@kazutakahirata kazutakahirata deleted the memprof_Frame_default_ctor branch November 26, 2024 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants