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.
@kazutakahirata kazutakahirata requested a review from nikic November 11, 2024 03:53
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Nov 11, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 11, 2024

@llvm/pr-subscribers-clang

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/115682.diff

1 Files Affected:

  • (modified) clang/utils/TableGen/NeonEmitter.cpp (+3-3)
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index 7081e5c9ae93e8..68ca31e27e0a41 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -340,7 +340,7 @@ class Intrinsic {
   /// The index of the key type passed to CGBuiltin.cpp for polymorphic calls.
   int PolymorphicKeyType;
   /// The local variables defined.
-  std::map<std::string, Variable> Variables;
+  std::map<std::string, Variable, std::less<>> Variables;
   /// NeededEarly - set if any other intrinsic depends on this intrinsic.
   bool NeededEarly;
   /// UseMacro - set if we should implement using a macro or unset for a
@@ -1548,8 +1548,8 @@ Intrinsic::DagEmitter::emitDagCast(const DagInit *DI, bool IsBitCast) {
     //   5. The value "H" or "D" to half or double the bitwidth.
     //   6. The value "8" to convert to 8-bit (signed) integer lanes.
     if (!DI->getArgNameStr(ArgIdx).empty()) {
-      assert_with_loc(Intr.Variables.find(std::string(
-                          DI->getArgNameStr(ArgIdx))) != Intr.Variables.end(),
+      assert_with_loc(Intr.Variables.find(DI->getArgNameStr(ArgIdx)) !=
+                          Intr.Variables.end(),
                       "Variable not found");
       castToType =
           Intr.Variables[std::string(DI->getArgNameStr(ArgIdx))].getType();

@kazutakahirata kazutakahirata merged commit 1735291 into llvm:main Nov 11, 2024
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_heterogenous_TableGen branch November 11, 2024 15:34
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

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants