diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -1468,13 +1468,10 @@ NumTraces += parseLBRSample(Sample, NeedsSkylakeFix); } - for (const auto &LBR : BranchLBRs) { - const Trace &Trace = LBR.first; - if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Trace.From)) - BF->setHasProfileAvailable(); - if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Trace.To)) - BF->setHasProfileAvailable(); - } + for (const Trace &Trace : llvm::make_first_range(BranchLBRs)) + for (const uint64_t Addr : {Trace.From, Trace.To}) + if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Addr)) + BF->setHasProfileAvailable(); auto printColored = [](raw_ostream &OS, float Percent, float T1, float T2) { OS << " ("; @@ -1710,12 +1707,9 @@ if (std::error_code EC = AggrEntry.getError()) return EC; - if (BinaryFunction *BF = - getBinaryFunctionContainingAddress(AggrEntry->From.Offset)) - BF->setHasProfileAvailable(); - if (BinaryFunction *BF = - getBinaryFunctionContainingAddress(AggrEntry->To.Offset)) - BF->setHasProfileAvailable(); + for (const uint64_t Addr : {AggrEntry->From.Offset, AggrEntry->To.Offset}) + if (BinaryFunction *BF = getBinaryFunctionContainingAddress(Addr)) + BF->setHasProfileAvailable(); AggregatedLBRs.emplace_back(std::move(AggrEntry.get())); } diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp --- a/bolt/lib/Profile/YAMLProfileReader.cpp +++ b/bolt/lib/Profile/YAMLProfileReader.cpp @@ -62,13 +62,9 @@ } bool YAMLProfileReader::hasLocalsWithFileName() const { - for (const StringMapEntry &KV : - ProfileNameToProfile) { - const StringRef &FuncName = KV.getKey(); - if (FuncName.count('/') == 2 && FuncName[0] != '/') - return true; - } - return false; + return llvm::any_of(ProfileNameToProfile.keys(), [](StringRef FuncName) { + return FuncName.count('/') == 2 && FuncName[0] != '/'; + }); } bool YAMLProfileReader::parseFunctionProfile(