Fix test failures introduced by PR #113697 (#116941)
[llvm-project.git] / llvm / tools / llvm-xray / func-id-helper.h
blobd99fb7c1cfb0cb9b8711438297bdbe05c274f6f9
1 //===- func-id-helper.h - XRay Function ID Conversion Helpers -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Defines helper tools dealing with XRay-generated function ids.
11 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H
13 #define LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H
15 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/DebugInfo/Symbolize/SymbolizableModule.h"
17 #include "llvm/DebugInfo/Symbolize/Symbolize.h"
18 #include <unordered_map>
20 namespace llvm {
21 namespace xray {
23 // This class consolidates common operations related to Function IDs.
24 class FuncIdConversionHelper {
25 public:
26 using FunctionAddressMap = std::unordered_map<int32_t, uint64_t>;
28 private:
29 std::string BinaryInstrMap;
30 symbolize::LLVMSymbolizer &Symbolizer;
31 const FunctionAddressMap &FunctionAddresses;
32 mutable llvm::DenseMap<int32_t, std::string> CachedNames;
34 public:
35 FuncIdConversionHelper(std::string BinaryInstrMap,
36 symbolize::LLVMSymbolizer &Symbolizer,
37 const FunctionAddressMap &FunctionAddresses)
38 : BinaryInstrMap(std::move(BinaryInstrMap)), Symbolizer(Symbolizer),
39 FunctionAddresses(FunctionAddresses) {}
41 // Returns the symbol or a string representation of the function id.
42 std::string SymbolOrNumber(int32_t FuncId) const;
44 // Returns the file and column from debug info for the given function id.
45 std::string FileLineAndColumn(int32_t FuncId) const;
48 } // namespace xray
49 } // namespace llvm
51 #endif // LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H