[PATCH] D43896: [XRay] cache symbolized function names for a repeatedly queried function ID
Martin Pelikán via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 18:03:52 PST 2018
This revision was automatically updated to reflect the committed changes.
pelikan marked an inline comment as done.
Closed by commit rL326407: [XRay] cache symbolized function names for a repeatedly queried function ID (authored by pelikan, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D43896
Files:
llvm/trunk/tools/llvm-xray/func-id-helper.cc
llvm/trunk/tools/llvm-xray/func-id-helper.h
Index: llvm/trunk/tools/llvm-xray/func-id-helper.h
===================================================================
--- llvm/trunk/tools/llvm-xray/func-id-helper.h
+++ llvm/trunk/tools/llvm-xray/func-id-helper.h
@@ -13,6 +13,7 @@
#ifndef LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H
#define LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H
+#include "llvm/ADT/DenseMap.h"
#include "llvm/DebugInfo/Symbolize/Symbolize.h"
#include <unordered_map>
@@ -28,6 +29,7 @@
std::string BinaryInstrMap;
symbolize::LLVMSymbolizer &Symbolizer;
const FunctionAddressMap &FunctionAddresses;
+ mutable llvm::DenseMap<int32_t, std::string> CachedNames;
public:
FuncIdConversionHelper(std::string BinaryInstrMap,
Index: llvm/trunk/tools/llvm-xray/func-id-helper.cc
===================================================================
--- llvm/trunk/tools/llvm-xray/func-id-helper.cc
+++ llvm/trunk/tools/llvm-xray/func-id-helper.cc
@@ -19,6 +19,10 @@
using namespace xray;
std::string FuncIdConversionHelper::SymbolOrNumber(int32_t FuncId) const {
+ auto CacheIt = CachedNames.find(FuncId);
+ if (CacheIt != CachedNames.end())
+ return CacheIt->second;
+
std::ostringstream F;
auto It = FunctionAddresses.find(FuncId);
if (It == FunctionAddresses.end()) {
@@ -37,7 +41,9 @@
F << "@(" << std::hex << It->second << ")";
});
- return F.str();
+ auto S = F.str();
+ CachedNames[FuncId] = S;
+ return S;
}
std::string FuncIdConversionHelper::FileLineAndColumn(int32_t FuncId) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43896.136452.patch
Type: text/x-patch
Size: 1508 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180301/f92050ca/attachment.bin>
More information about the llvm-commits
mailing list