Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

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.
@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2024

@llvm/pr-subscribers-backend-spir-v

Author: Kazu Hirata (kazutakahirata)

Changes

Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.


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

1 Files Affected:

  • (modified) llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp (+2-2)
diff --git a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
index e58366017966a7..d6a59addaf2d0a 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
@@ -20,7 +20,7 @@
 
 using namespace llvm;
 
-static const std::map<std::string, SPIRV::Extension::Extension>
+static const std::map<std::string, SPIRV::Extension::Extension, std::less<>>
     SPIRVExtensionMap = {
         {"SPV_EXT_shader_atomic_float_add",
          SPIRV::Extension::Extension::SPV_EXT_shader_atomic_float_add},
@@ -98,7 +98,7 @@ bool SPIRVExtensionsParser::parse(cl::Option &O, llvm::StringRef ArgName,
       return O.error("Invalid extension list format: " + Token.str());
 
     llvm::StringRef ExtensionName = Token.substr(1);
-    auto NameValuePair = SPIRVExtensionMap.find(ExtensionName.str());
+    auto NameValuePair = SPIRVExtensionMap.find(ExtensionName);
 
     if (NameValuePair == SPIRVExtensionMap.end())
       return O.error("Unknown SPIR-V extension: " + Token.str());

@kazutakahirata kazutakahirata merged commit 71f82bb into llvm:main Nov 8, 2024
11 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_heterogenous_SPIRV branch November 8, 2024 15:33
Groverkss pushed a commit to iree-org/llvm-project that referenced this pull request Nov 15, 2024
Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.
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.

3 participants