[PATCH] D83797: Remove thousands of std::string instances in a helper function that is frequently called.

Nadav Rotem via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 11:17:18 PDT 2020


nadav created this revision.
nadav added reviewers: modocache, hiraditya.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Remove thousands of std::string instances in a helper function that is frequently called. In the common case we don't need to construct an std::string instance when we can just pass the StringRef to TTI.

All of the clang-check tests pass. I discovered this with a Facebook-internal tool.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83797

Files:
  llvm/lib/Transforms/Utils/InjectTLIMappings.cpp


Index: llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
===================================================================
--- llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
+++ llvm/lib/Transforms/Utils/InjectTLIMappings.cpp
@@ -77,11 +77,14 @@
   if (CI.isNoBuiltin() || !CI.getCalledFunction())
     return;
 
-  const std::string ScalarName = std::string(CI.getCalledFunction()->getName());
+  auto NameRef = CI.getCalledFunction()->getName();
+
   // Nothing to be done if the TLI thinks the function is not
   // vectorizable.
-  if (!TLI.isFunctionVectorizable(ScalarName))
+  if (!TLI.isFunctionVectorizable(NameRef))
     return;
+
+  const std::string ScalarName = std::string(NameRef);
   SmallVector<std::string, 8> Mappings;
   VFABI::getVectorVariantNames(CI, Mappings);
   Module *M = CI.getModule();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83797.277908.patch
Type: text/x-patch
Size: 817 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200714/362b91a5/attachment.bin>


More information about the llvm-commits mailing list