Skip to content

[llvm] Use llvm::binary_search (NFC) #136228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Apr 18, 2025

@llvm/pr-subscribers-tablegen

@llvm/pr-subscribers-llvm-support

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/136228.diff

6 Files Affected:

  • (modified) llvm/include/llvm/Support/UnicodeCharRanges.h (+1-3)
  • (modified) llvm/lib/Target/Mips/Mips16HardFloat.cpp (+1-2)
  • (modified) llvm/lib/Target/Mips/Mips16ISelLowering.cpp (+2-4)
  • (modified) llvm/lib/Target/Mips/MipsCCState.cpp (+1-2)
  • (modified) llvm/tools/llvm-cov/CodeCoverage.cpp (+1-1)
  • (modified) llvm/utils/TableGen/Common/CodeGenRegisters.cpp (+1-2)
diff --git a/llvm/include/llvm/Support/UnicodeCharRanges.h b/llvm/include/llvm/Support/UnicodeCharRanges.h
index 73d3603b74df0..7f1a9b3ff0c3b 100644
--- a/llvm/include/llvm/Support/UnicodeCharRanges.h
+++ b/llvm/include/llvm/Support/UnicodeCharRanges.h
@@ -61,9 +61,7 @@ class UnicodeCharSet {
 
   /// Returns true if the character set contains the Unicode code point
   /// \p C.
-  bool contains(uint32_t C) const {
-    return std::binary_search(Ranges.begin(), Ranges.end(), C);
-  }
+  bool contains(uint32_t C) const { return llvm::binary_search(Ranges, C); }
 
 private:
   /// Returns true if each of the ranges is a proper closed range
diff --git a/llvm/lib/Target/Mips/Mips16HardFloat.cpp b/llvm/lib/Target/Mips/Mips16HardFloat.cpp
index f7b623785b70c..97a54f979907a 100644
--- a/llvm/lib/Target/Mips/Mips16HardFloat.cpp
+++ b/llvm/lib/Target/Mips/Mips16HardFloat.cpp
@@ -369,8 +369,7 @@ static const char *const IntrinsicInline[] = {
 };
 
 static bool isIntrinsicInline(Function *F) {
-  return std::binary_search(std::begin(IntrinsicInline),
-                            std::end(IntrinsicInline), F->getName());
+  return llvm::binary_search(IntrinsicInline, F->getName());
 }
 
 // Returns of float, double and complex need to be handled with a helper
diff --git a/llvm/lib/Target/Mips/Mips16ISelLowering.cpp b/llvm/lib/Target/Mips/Mips16ISelLowering.cpp
index 1027bcff84f8c..4fca1f71fdb57 100644
--- a/llvm/lib/Target/Mips/Mips16ISelLowering.cpp
+++ b/llvm/lib/Target/Mips/Mips16ISelLowering.cpp
@@ -427,8 +427,7 @@ getOpndList(SmallVectorImpl<SDValue> &Ops,
     if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(CLI.Callee)) {
       Mips16Libcall Find = { RTLIB::UNKNOWN_LIBCALL, S->getSymbol() };
 
-      if (std::binary_search(std::begin(HardFloatLibCalls),
-                             std::end(HardFloatLibCalls), Find))
+      if (llvm::binary_search(HardFloatLibCalls, Find))
         LookupHelper = false;
       else {
         const char *Symbol = S->getSymbol();
@@ -469,8 +468,7 @@ getOpndList(SmallVectorImpl<SDValue> &Ops,
       Mips16Libcall Find = { RTLIB::UNKNOWN_LIBCALL,
                              G->getGlobal()->getName().data() };
 
-      if (std::binary_search(std::begin(HardFloatLibCalls),
-                             std::end(HardFloatLibCalls), Find))
+      if (llvm::binary_search(HardFloatLibCalls, Find))
         LookupHelper = false;
     }
     if (LookupHelper)
diff --git a/llvm/lib/Target/Mips/MipsCCState.cpp b/llvm/lib/Target/Mips/MipsCCState.cpp
index 781bb7c8c7e6d..9e8cd2ea2fd43 100644
--- a/llvm/lib/Target/Mips/MipsCCState.cpp
+++ b/llvm/lib/Target/Mips/MipsCCState.cpp
@@ -30,8 +30,7 @@ bool MipsCCState::isF128SoftLibCall(const char *CallSym) {
   // Check that LibCalls is sorted alphabetically.
   auto Comp = [](const char *S1, const char *S2) { return strcmp(S1, S2) < 0; };
   assert(llvm::is_sorted(LibCalls, Comp));
-  return std::binary_search(std::begin(LibCalls), std::end(LibCalls), CallSym,
-                            Comp);
+  return llvm::binary_search(LibCalls, CallSym, Comp);
 }
 
 /// This function returns true if Ty is fp128, {f128} or i128 which was
diff --git a/llvm/tools/llvm-cov/CodeCoverage.cpp b/llvm/tools/llvm-cov/CodeCoverage.cpp
index a740cdd45b901..c828e25de4b02 100644
--- a/llvm/tools/llvm-cov/CodeCoverage.cpp
+++ b/llvm/tools/llvm-cov/CodeCoverage.cpp
@@ -547,7 +547,7 @@ void CodeCoverageTool::removeUnmappedInputs(const CoverageMapping &Coverage) {
   // The user may have specified source files which aren't in the coverage
   // mapping. Filter these files away.
   llvm::erase_if(SourceFiles, [&](const std::string &SF) {
-    return !std::binary_search(CoveredFiles.begin(), CoveredFiles.end(), SF);
+    return !llvm::binary_search(CoveredFiles, SF);
   });
 }
 
diff --git a/llvm/utils/TableGen/Common/CodeGenRegisters.cpp b/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
index eb142e66faf2f..3479cad10b66c 100644
--- a/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenRegisters.cpp
@@ -922,8 +922,7 @@ bool CodeGenRegisterClass::hasType(const ValueTypeByHwMode &VT) const {
 }
 
 bool CodeGenRegisterClass::contains(const CodeGenRegister *Reg) const {
-  return std::binary_search(Members.begin(), Members.end(), Reg,
-                            deref<std::less<>>());
+  return llvm::binary_search(Members, Reg, deref<std::less<>>());
 }
 
 unsigned CodeGenRegisterClass::getWeight(const CodeGenRegBank &RegBank) const {

@kazutakahirata kazutakahirata merged commit 5928876 into llvm:main Apr 18, 2025
14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_range_binary_search_llvm branch April 18, 2025 04:46
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants