Index: tools/llvm-xray/func-id-helper.h =================================================================== --- tools/llvm-xray/func-id-helper.h +++ tools/llvm-xray/func-id-helper.h @@ -28,6 +28,7 @@ std::string BinaryInstrMap; symbolize::LLVMSymbolizer &Symbolizer; const FunctionAddressMap &FunctionAddresses; + mutable std::unordered_map CachedNames; public: FuncIdConversionHelper(std::string BinaryInstrMap, Index: tools/llvm-xray/func-id-helper.cc =================================================================== --- tools/llvm-xray/func-id-helper.cc +++ 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 {