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> {
1183
1183
(void )Column;
1184
1184
(void )IsInlineFrame;
1185
1185
}
1186
+
1187
+ // Request the inline notation for brevity:
1188
+ // { Function: 123, LineOffset: 11, Column: 10; IsInlineFrame: true }
1189
+ static const bool flow = true ;
1186
1190
};
1187
1191
1188
1192
template <> struct CustomMappingTraits <memprof::PortableMemInfoBlock> {
@@ -1207,8 +1211,15 @@ template <> struct CustomMappingTraits<memprof::PortableMemInfoBlock> {
1207
1211
Io.setError (" Key is not a valid validation event" );
1208
1212
}
1209
1213
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
1212
1223
}
1213
1224
};
1214
1225
Original file line number Diff line number Diff line change @@ -807,4 +807,40 @@ TEST(MemProf, YAMLParser) {
807
807
EXPECT_THAT (Record.CallSiteIds ,
808
808
ElementsAre (hashCallStack (CS3), hashCallStack (CS4)));
809
809
}
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
+ }
810
846
} // namespace
You can’t perform that action at this time.
0 commit comments