Skip to content

Commit 09e7477

Browse files
[memprof] Add a default constructor to Frame (#117790)
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.
1 parent 9fde1a4 commit 09e7477

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

llvm/include/llvm/ProfileData/MemProf.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,18 +212,19 @@ using LinearFrameId = uint32_t;
212212
struct Frame {
213213
// A uuid (uint64_t) identifying the function. It is obtained by
214214
// llvm::md5(FunctionName) which returns the lower 64 bits.
215-
GlobalValue::GUID Function;
215+
GlobalValue::GUID Function = 0;
216216
// The symbol name for the function. Only populated in the Frame by the reader
217217
// if requested during initialization. This field should not be serialized.
218218
std::unique_ptr<std::string> SymbolName;
219219
// The source line offset of the call from the beginning of parent function.
220-
uint32_t LineOffset;
220+
uint32_t LineOffset = 0;
221221
// The source column number of the call to help distinguish multiple calls
222222
// on the same line.
223-
uint32_t Column;
223+
uint32_t Column = 0;
224224
// Whether the current frame is inlined.
225-
bool IsInlineFrame;
225+
bool IsInlineFrame = false;
226226

227+
Frame() = default;
227228
Frame(const Frame &Other) {
228229
Function = Other.Function;
229230
SymbolName = Other.SymbolName
@@ -817,7 +818,7 @@ template <typename MapTy> struct FrameIdConverter {
817818
auto Iter = Map.find(Id);
818819
if (Iter == Map.end()) {
819820
LastUnmappedId = Id;
820-
return Frame(0, 0, 0, false);
821+
return Frame();
821822
}
822823
return detail::DerefIterator<Frame>(Iter);
823824
}

0 commit comments

Comments
 (0)