[llvm-objcopy] - Remove python invocations from 2 test cases.
[llvm-complete.git] / tools / llvm-xray / func-id-helper.h
blobc6ce198170d51a04f64d0f768d845815c0eefef3
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/Symbolize.h"
17 #include <unordered_map>
19 namespace llvm {
20 namespace xray {
22 // This class consolidates common operations related to Function IDs.
23 class FuncIdConversionHelper {
24 public:
25 using FunctionAddressMap = std::unordered_map<int32_t, uint64_t>;
27 private:
28 std::string BinaryInstrMap;
29 symbolize::LLVMSymbolizer &Symbolizer;
30 const FunctionAddressMap &FunctionAddresses;
31 mutable llvm::DenseMap<int32_t, std::string> CachedNames;
33 public:
34 FuncIdConversionHelper(std::string BinaryInstrMap,
35 symbolize::LLVMSymbolizer &Symbolizer,
36 const FunctionAddressMap &FunctionAddresses)
37 : BinaryInstrMap(std::move(BinaryInstrMap)), Symbolizer(Symbolizer),
38 FunctionAddresses(FunctionAddresses) {}
40 // Returns the symbol or a string representation of the function id.
41 std::string SymbolOrNumber(int32_t FuncId) const;
43 // Returns the file and column from debug info for the given function id.
44 std::string FileLineAndColumn(int32_t FuncId) const;
47 } // namespace xray
48 } // namespace llvm
50 #endif // LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H