-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[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
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_range_binary_search_llvm
Apr 18, 2025
Merged
[llvm] Use llvm::binary_search (NFC) #136228
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_range_binary_search_llvm
Apr 18, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-tablegen @llvm/pr-subscribers-llvm-support Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/136228.diff 6 Files Affected:
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 {
|
zyn0217
approved these changes
Apr 18, 2025
kuhar
approved these changes
Apr 18, 2025
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.