[BOLT] Use std::tie to implement operator< (NFC) (#143560)
std::tie facilitates lexicographical comparisons through std::tuple's built-in operator<.
This commit is contained in:
parent
04cffaae8f
commit
8da9eb235d
@ -52,9 +52,8 @@ public:
|
||||
uint64_t MispredictedCount; /// number of branches mispredicted
|
||||
|
||||
bool operator<(const BinaryBranchInfo &Other) const {
|
||||
return (Count < Other.Count) ||
|
||||
(Count == Other.Count &&
|
||||
MispredictedCount < Other.MispredictedCount);
|
||||
return std::tie(Count, MispredictedCount) <
|
||||
std::tie(Other.Count, Other.MispredictedCount);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -77,9 +77,7 @@ struct MCInstInBFReference {
|
||||
return BF == RHS.BF && Offset == RHS.Offset;
|
||||
}
|
||||
bool operator<(const MCInstInBFReference &RHS) const {
|
||||
if (BF != RHS.BF)
|
||||
return BF < RHS.BF;
|
||||
return Offset < RHS.Offset;
|
||||
return std::tie(BF, Offset) < std::tie(RHS.BF, RHS.Offset);
|
||||
}
|
||||
operator MCInst &() const {
|
||||
assert(BF != nullptr);
|
||||
|
@ -303,9 +303,8 @@ YAMLProfileWriter::convert(const BinaryFunction &BF, bool UseDFS,
|
||||
}
|
||||
// Sort targets in a similar way to getBranchData, see Location::operator<
|
||||
llvm::sort(CSTargets, [](const auto &RHS, const auto &LHS) {
|
||||
if (RHS.first != LHS.first)
|
||||
return RHS.first < LHS.first;
|
||||
return RHS.second.Offset < LHS.second.Offset;
|
||||
return std::tie(RHS.first, RHS.second.Offset) <
|
||||
std::tie(LHS.first, LHS.second.Offset);
|
||||
});
|
||||
for (auto &KV : CSTargets)
|
||||
YamlBB.CallSites.push_back(KV.second);
|
||||
|
Loading…
x
Reference in New Issue
Block a user