File tree Expand file tree Collapse file tree 2 files changed +4
-13
lines changed Expand file tree Collapse file tree 2 files changed +4
-13
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ class YAMLProfileReader : public ProfileReaderBase {
105105 yaml::bolt::BinaryProfile YamlBP;
106106
107107 // / Map a function ID from a YAML profile to a BinaryFunction object.
108- std::vector< BinaryFunction *> YamlProfileToFunction;
108+ DenseMap< uint32_t , BinaryFunction *> YamlProfileToFunction;
109109
110110 using FunctionSet = std::unordered_set<const BinaryFunction *>;
111111 // / To keep track of functions that have a matched profile before the profile
@@ -162,8 +162,6 @@ class YAMLProfileReader : public ProfileReaderBase {
162162 // / Update matched YAML -> BinaryFunction pair.
163163 void matchProfileToFunction (yaml::bolt::BinaryFunctionProfile &YamlBF,
164164 BinaryFunction &BF) {
165- if (YamlBF.Id >= YamlProfileToFunction.size ())
166- YamlProfileToFunction.resize (YamlBF.Id + 1 );
167165 YamlProfileToFunction[YamlBF.Id ] = &BF;
168166 YamlBF.Used = true ;
169167
Original file line number Diff line number Diff line change @@ -238,9 +238,7 @@ bool YAMLProfileReader::parseFunctionProfile(
238238 BB.setExecutionCount (YamlBB.ExecCount );
239239
240240 for (const yaml::bolt::CallSiteInfo &YamlCSI : YamlBB.CallSites ) {
241- BinaryFunction *Callee = YamlCSI.DestId < YamlProfileToFunction.size ()
242- ? YamlProfileToFunction[YamlCSI.DestId ]
243- : nullptr ;
241+ BinaryFunction *Callee = YamlProfileToFunction.lookup (YamlCSI.DestId );
244242 bool IsFunction = Callee ? true : false ;
245243 MCSymbol *CalleeSymbol = nullptr ;
246244 if (IsFunction)
@@ -707,7 +705,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
707705 break ;
708706 }
709707 }
710- YamlProfileToFunction.resize (YamlBP.Functions .size () + 1 );
708+ YamlProfileToFunction.reserve (YamlBP.Functions .size ());
711709
712710 // Computes hash for binary functions.
713711 if (opts::MatchProfileWithFunctionHash) {
@@ -760,12 +758,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
760758 NormalizeByCalls = usesEvent (" branches" );
761759 uint64_t NumUnused = 0 ;
762760 for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions ) {
763- if (YamlBF.Id >= YamlProfileToFunction.size ()) {
764- // Such profile was ignored.
765- ++NumUnused;
766- continue ;
767- }
768- if (BinaryFunction *BF = YamlProfileToFunction[YamlBF.Id ])
761+ if (BinaryFunction *BF = YamlProfileToFunction.lookup (YamlBF.Id ))
769762 parseFunctionProfile (*BF, YamlBF);
770763 else
771764 ++NumUnused;
You can’t perform that action at this time.
0 commit comments