[llvm] [Symbolizer, DebugInfo] Clean up LLVMSymbolizer API: const string& -> StringRef (PR #104541)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 16 04:13:51 PDT 2024


================
@@ -604,13 +604,13 @@ LLVMSymbolizer::createModuleInfo(const ObjectFile *Obj,
 }
 
 Expected<SymbolizableModule *>
-LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) {
-  std::string BinaryName = ModuleName;
-  std::string ArchName = Opts.DefaultArch;
+LLVMSymbolizer::getOrCreateModuleInfo(StringRef ModuleName) {
+  StringRef BinaryName = ModuleName;
+  StringRef ArchName = Opts.DefaultArch;
----------------
itrofimow wrote:

In my use case I have literally tens of millions of addresses to symbolize over ~50-100 different binaries (you can think of it as a hand-made analogue of `perf record -a` with subsequent `perf script`).

Not that it matters too much, but creating a `std::string BinaryName` from `ModuleName` (allocation + deallocation + memcpy) for every address is wasteful, given that the actual `std::string` is only needed ~50-100 times (the amount of binaries in question) to insert into maps.

https://github.com/llvm/llvm-project/pull/104541


More information about the llvm-commits mailing list