@@ -961,21 +961,16 @@ namespace {
961
961
struct PGOUseEdge : public PGOEdge {
962
962
using PGOEdge::PGOEdge;
963
963
964
- bool CountValid = false ;
965
- uint64_t CountValue = 0 ;
964
+ std::optional<uint64_t > Count;
966
965
967
966
// Set edge count value
968
- void setEdgeCount (uint64_t Value) {
969
- CountValue = Value;
970
- CountValid = true ;
971
- }
967
+ void setEdgeCount (uint64_t Value) { Count = Value; }
972
968
973
969
// Return the information string for this object.
974
970
std::string infoString () const {
975
- if (!CountValid )
971
+ if (!Count )
976
972
return PGOEdge::infoString ();
977
- return (Twine (PGOEdge::infoString ()) + " Count=" + Twine (CountValue))
978
- .str ();
973
+ return (Twine (PGOEdge::infoString ()) + " Count=" + Twine (*Count)).str ();
979
974
}
980
975
};
981
976
@@ -1022,7 +1017,8 @@ static uint64_t sumEdgeCount(const ArrayRef<PGOUseEdge *> Edges) {
1022
1017
for (const auto &E : Edges) {
1023
1018
if (E->Removed )
1024
1019
continue ;
1025
- Total += E->CountValue ;
1020
+ if (E->Count )
1021
+ Total += *E->Count ;
1026
1022
}
1027
1023
return Total;
1028
1024
}
@@ -1221,7 +1217,7 @@ bool PGOUseFunc::setInstrumentedCounts(
1221
1217
if (DestInfo.Count && DestInfo.InEdges .size () == 1 )
1222
1218
setEdgeCount (E.get (), *DestInfo.Count );
1223
1219
}
1224
- if (E->CountValid )
1220
+ if (E->Count )
1225
1221
continue ;
1226
1222
// E's count should have been set from profile. If not, this meenas E skips
1227
1223
// the instrumentation. We set the count to 0.
@@ -1234,7 +1230,7 @@ bool PGOUseFunc::setInstrumentedCounts(
1234
1230
// unknown edge in Edges vector.
1235
1231
void PGOUseFunc::setEdgeCount (DirectEdges &Edges, uint64_t Value) {
1236
1232
for (auto &E : Edges) {
1237
- if (E->CountValid )
1233
+ if (E->Count )
1238
1234
continue ;
1239
1235
E->setEdgeCount (Value);
1240
1236
@@ -1574,7 +1570,7 @@ void PGOUseFunc::setBranchWeights() {
1574
1570
if (DestBB == nullptr )
1575
1571
continue ;
1576
1572
unsigned SuccNum = GetSuccessorNumber (SrcBB, DestBB);
1577
- uint64_t EdgeCount = E->CountValue ;
1573
+ uint64_t EdgeCount = * E->Count ;
1578
1574
if (EdgeCount > MaxCount)
1579
1575
MaxCount = EdgeCount;
1580
1576
EdgeCounts[SuccNum] = EdgeCount;
0 commit comments