Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions llvm/include/llvm/ProfileData/MemProf.h
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,11 @@ template <> struct MappingTraits<memprof::Frame> {
(void)Column;
(void)IsInlineFrame;
}

// Request the inline notation for brevity:
//
// { Function: 123, LineOffset: 11, Column: 10; IsInlineFrame: true }
static const bool flow = true;
};

template <> struct CustomMappingTraits<memprof::PortableMemInfoBlock> {
Expand All @@ -1201,8 +1206,13 @@ template <> struct CustomMappingTraits<memprof::PortableMemInfoBlock> {
Io.setError("Key is not a valid validation event");
}

static void output(IO &Io, memprof::PortableMemInfoBlock &VI) {
llvm_unreachable("To be implemented");
static void output(IO &Io, memprof::PortableMemInfoBlock &MIB) {
auto Schema = MIB.getSchema();
#define MIBEntryDef(NameTag, Name, Type) \
if (Schema.test(llvm::to_underlying(memprof::Meta::Name))) \
Io.mapRequired(#Name, MIB.Name);
#include "llvm/ProfileData/MIBEntryDef.inc"
#undef MIBEntryDef
}
};

Expand Down
34 changes: 34 additions & 0 deletions llvm/unittests/ProfileData/MemProfTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -807,4 +807,38 @@ TEST(MemProf, YAMLParser) {
EXPECT_THAT(Record.CallSiteIds,
ElementsAre(hashCallStack(CS3), hashCallStack(CS4)));
}

TEST(MemProf, YAMLWriterFrame) {
Frame F(12, 34, 56, true);

std::string Out;
llvm::raw_string_ostream OS(Out);
llvm::yaml::Output Yout(OS);
Yout << F;
EXPECT_EQ(Out, R"YAML(---
{ Function: 12, LineOffset: 34, Column: 56, Inline: true }
...
)YAML");
}

TEST(MemProf, YAMLWriterMIB) {
MemInfoBlock MIB;
MIB.AllocCount = 111;
MIB.TotalSize = 222;
MIB.TotalLifetime = 333;
MIB.TotalLifetimeAccessDensity = 444;
PortableMemInfoBlock PMIB(MIB, llvm::memprof::getHotColdSchema());

std::string Out;
llvm::raw_string_ostream OS(Out);
llvm::yaml::Output Yout(OS);
Yout << PMIB;
EXPECT_EQ(Out, R"YAML(---
AllocCount: 111
TotalSize: 222
TotalLifetime: 333
TotalLifetimeAccessDensity: 444
...
)YAML");
}
} // namespace
Loading