@@ -95,24 +95,29 @@ template <> struct MappingTraits<bolt::SuccessorInfo> {
9595
9696namespace bolt {
9797struct PseudoProbeInfo {
98- llvm::yaml::Hex64 GUID;
99- uint64_t Index;
100- uint8_t Type;
98+ uint32_t InlineTreeIndex = 0 ;
99+ uint64_t BlockMask = 0 ; // bitset with probe indices from 1 to 64
100+ std::vector<uint64_t > BlockProbes; // block probes with indices above 64
101+ std::vector<uint64_t > CallProbes;
102+ std::vector<uint64_t > IndCallProbes;
103+ std::vector<uint32_t > InlineTreeNodes;
101104
102105 bool operator ==(const PseudoProbeInfo &Other) const {
103- return GUID == Other.GUID && Index == Other.Index ;
104- }
105- bool operator !=(const PseudoProbeInfo &Other) const {
106- return !(*this == Other);
106+ return InlineTreeIndex == Other.InlineTreeIndex &&
107+ BlockProbes == Other.BlockProbes && CallProbes == Other.CallProbes &&
108+ IndCallProbes == Other.IndCallProbes ;
107109 }
108110};
109111} // end namespace bolt
110112
111113template <> struct MappingTraits <bolt::PseudoProbeInfo> {
112114 static void mapping (IO &YamlIO, bolt::PseudoProbeInfo &PI) {
113- YamlIO.mapRequired (" guid" , PI.GUID );
114- YamlIO.mapRequired (" id" , PI.Index );
115- YamlIO.mapRequired (" type" , PI.Type );
115+ YamlIO.mapOptional (" blx" , PI.BlockMask , 0 );
116+ YamlIO.mapOptional (" blk" , PI.BlockProbes , std::vector<uint64_t >());
117+ YamlIO.mapOptional (" call" , PI.CallProbes , std::vector<uint64_t >());
118+ YamlIO.mapOptional (" icall" , PI.IndCallProbes , std::vector<uint64_t >());
119+ YamlIO.mapOptional (" id" , PI.InlineTreeIndex , 0 );
120+ YamlIO.mapOptional (" ids" , PI.InlineTreeNodes , std::vector<uint32_t >());
116121 }
117122
118123 static const bool flow = true ;
@@ -158,15 +163,35 @@ template <> struct MappingTraits<bolt::BinaryBasicBlockProfile> {
158163 std::vector<bolt::CallSiteInfo>());
159164 YamlIO.mapOptional (" succ" , BBP.Successors ,
160165 std::vector<bolt::SuccessorInfo>());
161- YamlIO.mapOptional (" pseudo_probes " , BBP.PseudoProbes ,
166+ YamlIO.mapOptional (" probes " , BBP.PseudoProbes ,
162167 std::vector<bolt::PseudoProbeInfo>());
163168 }
164169};
165170
171+ namespace bolt {
172+ struct InlineTreeNode {
173+ uint32_t ParentIndexDelta;
174+ uint32_t CallSiteProbe;
175+ // Index in PseudoProbeDesc.GUID, UINT32_MAX for same as previous (omitted)
176+ uint32_t GUIDIndex;
177+ bool operator ==(const InlineTreeNode &) const { return false ; }
178+ };
179+ } // end namespace bolt
180+
181+ template <> struct MappingTraits <bolt::InlineTreeNode> {
182+ static void mapping (IO &YamlIO, bolt::InlineTreeNode &ITI) {
183+ YamlIO.mapOptional (" g" , ITI.GUIDIndex , UINT32_MAX);
184+ YamlIO.mapOptional (" p" , ITI.ParentIndexDelta , 0 );
185+ YamlIO.mapOptional (" cs" , ITI.CallSiteProbe , 0 );
186+ }
187+
188+ static const bool flow = true ;
189+ };
166190} // end namespace yaml
167191} // end namespace llvm
168192
169193LLVM_YAML_IS_SEQUENCE_VECTOR (llvm::yaml::bolt::BinaryBasicBlockProfile)
194+ LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(llvm::yaml::bolt::InlineTreeNode)
170195
171196namespace llvm {
172197namespace yaml {
@@ -179,8 +204,7 @@ struct BinaryFunctionProfile {
179204 llvm::yaml::Hex64 Hash{0 };
180205 uint64_t ExecCount{0 };
181206 std::vector<BinaryBasicBlockProfile> Blocks;
182- llvm::yaml::Hex64 GUID{0 };
183- llvm::yaml::Hex64 PseudoProbeDescHash{0 };
207+ std::vector<InlineTreeNode> InlineTree;
184208 bool Used{false };
185209};
186210} // end namespace bolt
@@ -194,9 +218,8 @@ template <> struct MappingTraits<bolt::BinaryFunctionProfile> {
194218 YamlIO.mapRequired (" nblocks" , BFP.NumBasicBlocks );
195219 YamlIO.mapOptional (" blocks" , BFP.Blocks ,
196220 std::vector<bolt::BinaryBasicBlockProfile>());
197- YamlIO.mapOptional (" guid" , BFP.GUID , (uint64_t )0 );
198- YamlIO.mapOptional (" pseudo_probe_desc_hash" , BFP.PseudoProbeDescHash ,
199- (uint64_t )0 );
221+ YamlIO.mapOptional (" inline_tree" , BFP.InlineTree ,
222+ std::vector<bolt::InlineTreeNode>());
200223 }
201224};
202225
@@ -246,10 +269,33 @@ template <> struct MappingTraits<bolt::BinaryProfileHeader> {
246269 }
247270};
248271
272+ namespace bolt {
273+ struct ProfilePseudoProbeDesc {
274+ std::vector<Hex64> GUID;
275+ std::vector<Hex64> Hash;
276+ std::vector<uint32_t > GUIDHashIdx; // Index of hash for that GUID in Hash
277+
278+ bool operator ==(const ProfilePseudoProbeDesc &Other) const {
279+ // Only treat empty Desc as equal
280+ return GUID.empty () && Other.GUID .empty () && Hash.empty () &&
281+ Other.Hash .empty () && GUIDHashIdx.empty () &&
282+ Other.GUIDHashIdx .empty ();
283+ }
284+ };
285+ } // end namespace bolt
286+
287+ template <> struct MappingTraits <bolt::ProfilePseudoProbeDesc> {
288+ static void mapping (IO &YamlIO, bolt::ProfilePseudoProbeDesc &PD) {
289+ YamlIO.mapRequired (" gs" , PD.GUID );
290+ YamlIO.mapRequired (" gh" , PD.GUIDHashIdx );
291+ YamlIO.mapRequired (" hs" , PD.Hash );
292+ }
293+ };
249294} // end namespace yaml
250295} // end namespace llvm
251296
252297LLVM_YAML_IS_SEQUENCE_VECTOR (llvm::yaml::bolt::BinaryFunctionProfile)
298+ LLVM_YAML_IS_SEQUENCE_VECTOR(llvm::yaml::bolt::ProfilePseudoProbeDesc)
253299
254300namespace llvm {
255301namespace yaml {
@@ -258,13 +304,16 @@ namespace bolt {
258304struct BinaryProfile {
259305 BinaryProfileHeader Header;
260306 std::vector<BinaryFunctionProfile> Functions;
307+ ProfilePseudoProbeDesc PseudoProbeDesc;
261308};
262309} // namespace bolt
263310
264311template <> struct MappingTraits <bolt::BinaryProfile> {
265312 static void mapping (IO &YamlIO, bolt::BinaryProfile &BP) {
266313 YamlIO.mapRequired (" header" , BP.Header );
267314 YamlIO.mapRequired (" functions" , BP.Functions );
315+ YamlIO.mapOptional (" pseudo_probe_desc" , BP.PseudoProbeDesc ,
316+ bolt::ProfilePseudoProbeDesc ());
268317 }
269318};
270319
0 commit comments