File tree Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Expand file tree Collapse file tree 2 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -1183,6 +1183,10 @@ template <> struct MappingTraits<memprof::Frame> {
11831183 (void )Column;
11841184 (void )IsInlineFrame;
11851185 }
1186+
1187+ // Request the inline notation for brevity:
1188+ // { Function: 123, LineOffset: 11, Column: 10; IsInlineFrame: true }
1189+ static const bool flow = true ;
11861190};
11871191
11881192template <> struct CustomMappingTraits <memprof::PortableMemInfoBlock> {
@@ -1207,8 +1211,15 @@ template <> struct CustomMappingTraits<memprof::PortableMemInfoBlock> {
12071211 Io.setError (" Key is not a valid validation event" );
12081212 }
12091213
1210- static void output (IO &Io, memprof::PortableMemInfoBlock &VI) {
1211- llvm_unreachable (" To be implemented" );
1214+ static void output (IO &Io, memprof::PortableMemInfoBlock &MIB) {
1215+ auto Schema = MIB.getSchema ();
1216+ #define MIBEntryDef (NameTag, Name, Type ) \
1217+ if (Schema.test (llvm::to_underlying (memprof::Meta::Name))) { \
1218+ uint64_t Value = MIB.Name ; \
1219+ Io.mapRequired (#Name, Value); \
1220+ }
1221+ #include " llvm/ProfileData/MIBEntryDef.inc"
1222+ #undef MIBEntryDef
12121223 }
12131224};
12141225
Original file line number Diff line number Diff line change @@ -807,4 +807,40 @@ TEST(MemProf, YAMLParser) {
807807 EXPECT_THAT (Record.CallSiteIds ,
808808 ElementsAre (hashCallStack (CS3), hashCallStack (CS4)));
809809}
810+
811+ template <typename T> std::string serializeInYAML (T &Val) {
812+ std::string Out;
813+ llvm::raw_string_ostream OS (Out);
814+ llvm::yaml::Output Yout (OS);
815+ Yout << Val;
816+ return Out;
817+ }
818+
819+ TEST (MemProf, YAMLWriterFrame) {
820+ Frame F (11 , 22 , 33 , true );
821+
822+ std::string Out = serializeInYAML (F);
823+ EXPECT_EQ (Out, R"YAML( ---
824+ { Function: 11, LineOffset: 22, Column: 33, Inline: true }
825+ ...
826+ )YAML" );
827+ }
828+
829+ TEST (MemProf, YAMLWriterMIB) {
830+ MemInfoBlock MIB;
831+ MIB.AllocCount = 111 ;
832+ MIB.TotalSize = 222 ;
833+ MIB.TotalLifetime = 333 ;
834+ MIB.TotalLifetimeAccessDensity = 444 ;
835+ PortableMemInfoBlock PMIB (MIB, llvm::memprof::getHotColdSchema ());
836+
837+ std::string Out = serializeInYAML (PMIB);
838+ EXPECT_EQ (Out, R"YAML( ---
839+ AllocCount: 111
840+ TotalSize: 222
841+ TotalLifetime: 333
842+ TotalLifetimeAccessDensity: 444
843+ ...
844+ )YAML" );
845+ }
810846} // namespace
You can’t perform that action at this time.
0 commit comments