-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Driver] Use heterogenous lookups with std::set (NFC) #115259
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
[Driver] Use heterogenous lookups with std::set (NFC) #115259
Conversation
Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string.
@llvm/pr-subscribers-clang-driver Author: Kazu Hirata (kazutakahirata) ChangesHeterogenous lookups allow us to call find with StringRef, avoiding a Full diff: https://github.com/llvm/llvm-project/pull/115259.diff 1 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/HIPUtility.cpp b/clang/lib/Driver/ToolChains/HIPUtility.cpp
index c8075cbfe36b35..3f81c3cb0f80e8 100644
--- a/clang/lib/Driver/ToolChains/HIPUtility.cpp
+++ b/clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -148,8 +148,8 @@ class HIPUndefinedFatBinSymbols {
bool Verbose;
std::set<std::string> FatBinSymbols;
std::set<std::string> GPUBinHandleSymbols;
- std::set<std::string> DefinedFatBinSymbols;
- std::set<std::string> DefinedGPUBinHandleSymbols;
+ std::set<std::string, std::less<>> DefinedFatBinSymbols;
+ std::set<std::string, std::less<>> DefinedGPUBinHandleSymbols;
const std::string FatBinPrefix = "__hip_fatbin";
const std::string GPUBinHandlePrefix = "__hip_gpubin_handle";
@@ -260,11 +260,10 @@ class HIPUndefinedFatBinSymbols {
// Add undefined symbols if they are not in the defined sets
if (isFatBinSymbol &&
- DefinedFatBinSymbols.find(Name.str()) == DefinedFatBinSymbols.end())
+ DefinedFatBinSymbols.find(Name) == DefinedFatBinSymbols.end())
FatBinSymbols.insert(Name.str());
- else if (isGPUBinHandleSymbol &&
- DefinedGPUBinHandleSymbols.find(Name.str()) ==
- DefinedGPUBinHandleSymbols.end())
+ else if (isGPUBinHandleSymbol && DefinedGPUBinHandleSymbols.find(Name) ==
+ DefinedGPUBinHandleSymbols.end())
GPUBinHandleSymbols.insert(Name.str());
}
}
|
@llvm/pr-subscribers-clang Author: Kazu Hirata (kazutakahirata) ChangesHeterogenous lookups allow us to call find with StringRef, avoiding a Full diff: https://github.com/llvm/llvm-project/pull/115259.diff 1 Files Affected:
diff --git a/clang/lib/Driver/ToolChains/HIPUtility.cpp b/clang/lib/Driver/ToolChains/HIPUtility.cpp
index c8075cbfe36b35..3f81c3cb0f80e8 100644
--- a/clang/lib/Driver/ToolChains/HIPUtility.cpp
+++ b/clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -148,8 +148,8 @@ class HIPUndefinedFatBinSymbols {
bool Verbose;
std::set<std::string> FatBinSymbols;
std::set<std::string> GPUBinHandleSymbols;
- std::set<std::string> DefinedFatBinSymbols;
- std::set<std::string> DefinedGPUBinHandleSymbols;
+ std::set<std::string, std::less<>> DefinedFatBinSymbols;
+ std::set<std::string, std::less<>> DefinedGPUBinHandleSymbols;
const std::string FatBinPrefix = "__hip_fatbin";
const std::string GPUBinHandlePrefix = "__hip_gpubin_handle";
@@ -260,11 +260,10 @@ class HIPUndefinedFatBinSymbols {
// Add undefined symbols if they are not in the defined sets
if (isFatBinSymbol &&
- DefinedFatBinSymbols.find(Name.str()) == DefinedFatBinSymbols.end())
+ DefinedFatBinSymbols.find(Name) == DefinedFatBinSymbols.end())
FatBinSymbols.insert(Name.str());
- else if (isGPUBinHandleSymbol &&
- DefinedGPUBinHandleSymbols.find(Name.str()) ==
- DefinedGPUBinHandleSymbols.end())
+ else if (isGPUBinHandleSymbol && DefinedGPUBinHandleSymbols.find(Name) ==
+ DefinedGPUBinHandleSymbols.end())
GPUBinHandleSymbols.insert(Name.str());
}
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG
Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string.
Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.