From b188f9f59745a34d448a61e1eef056557187a64a Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 16 Jun 2023 07:48:19 -0700 Subject: [PATCH] [BOLT] Use {StringMap,DenseMapBase}::lookup (NFC) --- bolt/include/bolt/Core/BinaryContext.h | 6 ++---- bolt/include/bolt/Core/BinaryFunction.h | 6 +----- bolt/lib/Profile/StaleProfileMatching.cpp | 10 ++-------- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/bolt/include/bolt/Core/BinaryContext.h b/bolt/include/bolt/Core/BinaryContext.h index 9daa2eb..feefd06 100644 --- a/bolt/include/bolt/Core/BinaryContext.h +++ b/bolt/include/bolt/Core/BinaryContext.h @@ -842,13 +842,11 @@ public: /// Return BinaryData for the given \p Name or nullptr if no /// global symbol with that name exists. const BinaryData *getBinaryDataByName(StringRef Name) const { - auto Itr = GlobalSymbols.find(Name); - return Itr != GlobalSymbols.end() ? Itr->second : nullptr; + return GlobalSymbols.lookup(Name); } BinaryData *getBinaryDataByName(StringRef Name) { - auto Itr = GlobalSymbols.find(Name); - return Itr != GlobalSymbols.end() ? Itr->second : nullptr; + return GlobalSymbols.lookup(Name); } /// Return registered PLT entry BinaryData with the given \p Name diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h index dff34a2..c698319 100644 --- a/bolt/include/bolt/Core/BinaryFunction.h +++ b/bolt/include/bolt/Core/BinaryFunction.h @@ -1128,11 +1128,7 @@ public: /// secondary entry point into the function, then return a global symbol /// that represents the secondary entry point. Otherwise return nullptr. MCSymbol *getSecondaryEntryPointSymbol(const MCSymbol *BBLabel) const { - auto I = SecondaryEntryPoints.find(BBLabel); - if (I == SecondaryEntryPoints.end()) - return nullptr; - - return I->second; + return SecondaryEntryPoints.lookup(BBLabel); } /// If the basic block serves as a secondary entry point to the function, diff --git a/bolt/lib/Profile/StaleProfileMatching.cpp b/bolt/lib/Profile/StaleProfileMatching.cpp index f7bd193..b009d57 100644 --- a/bolt/lib/Profile/StaleProfileMatching.cpp +++ b/bolt/lib/Profile/StaleProfileMatching.cpp @@ -445,14 +445,8 @@ void matchWeightsByHashes(const BinaryFunction::BasicBlockOrderType &BlockOrder, const uint64_t SrcIndex = YamlBB.Index; const uint64_t DstIndex = YamlSI.Index; - const FlowBlock *MatchedSrcBlock = - MatchedBlocks.find(SrcIndex) != MatchedBlocks.end() - ? MatchedBlocks[SrcIndex] - : nullptr; - const FlowBlock *MatchedDstBlock = - MatchedBlocks.find(DstIndex) != MatchedBlocks.end() - ? MatchedBlocks[DstIndex] - : nullptr; + const FlowBlock *MatchedSrcBlock = MatchedBlocks.lookup(SrcIndex); + const FlowBlock *MatchedDstBlock = MatchedBlocks.lookup(DstIndex); if (MatchedSrcBlock != nullptr && MatchedDstBlock != nullptr) { // Find a jump between the two blocks -- 2.7.4