LLVM 22.0.0git
CallSiteInfo.h
Go to the documentation of this file.
1//===- CallSiteInfo.h -------------------------------------------*- C++ -*-===//
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#ifndef LLVM_DEBUGINFO_GSYM_CALLSITEINFO_H
10#define LLVM_DEBUGINFO_GSYM_CALLSITEINFO_H
11
13#include "llvm/ADT/StringRef.h"
14#include "llvm/ADT/StringSet.h"
16#include "llvm/Support/Error.h"
17#include <vector>
18
19namespace llvm {
20class DataExtractor;
21class raw_ostream;
22
23namespace yaml {
24struct FunctionsYAML;
25} // namespace yaml
26
27namespace gsym {
28class FileWriter;
29class GsymCreator;
30struct FunctionInfo;
32 enum Flags : uint8_t {
33 None = 0,
34 // This flag specifies that the call site can only call a function within
35 // the same link unit as the call site.
36 InternalCall = 1 << 0,
37 // This flag specifies that the call site can only call a function outside
38 // the link unit that the call site is in.
39 ExternalCall = 1 << 1,
40
42 };
43
44 /// The return offset of the call site - relative to the function start.
46
47 /// Offsets into the string table for function names regex patterns.
48 std::vector<uint32_t> MatchRegex;
49
50 /// Bitwise OR of CallSiteInfo::Flags values
52
53 /// Equality comparison operator for CallSiteInfo.
54 bool operator==(const CallSiteInfo &RHS) const {
55 return ReturnOffset == RHS.ReturnOffset && MatchRegex == RHS.MatchRegex &&
56 Flags == RHS.Flags;
57 }
58
59 /// Inequality comparison operator for CallSiteInfo.
60 bool operator!=(const CallSiteInfo &RHS) const { return !(*this == RHS); }
61
62 /// Decode a CallSiteInfo object from a binary data stream.
63 ///
64 /// \param Data The binary stream to read the data from.
65 /// \param Offset The current offset within the data stream.
66 /// \returns A CallSiteInfo or an error describing the issue.
69
70 /// Encode this CallSiteInfo object into a FileWriter stream.
71 ///
72 /// \param O The binary stream to write the data to.
73 /// \returns An error object that indicates success or failure.
75};
76
78 std::vector<CallSiteInfo> CallSites;
79
80 /// Decode a CallSiteInfoCollection object from a binary data stream.
81 ///
82 /// \param Data The binary stream to read the data from.
83 /// \returns A CallSiteInfoCollection or an error describing the issue.
86
87 /// Encode this CallSiteInfoCollection object into a FileWriter stream.
88 ///
89 /// \param O The binary stream to write the data to.
90 /// \returns An error object that indicates success or failure.
92};
93
95public:
96 /// Constructor that initializes the CallSiteInfoLoader with necessary data
97 /// structures.
98 ///
99 /// \param GCreator A reference to the GsymCreator.
100 CallSiteInfoLoader(GsymCreator &GCreator, std::vector<FunctionInfo> &Funcs)
101 : GCreator(GCreator), Funcs(Funcs) {}
102
103 /// This method reads the specified YAML file, parses its content, and updates
104 /// the `Funcs` vector with call site information based on the YAML data.
105 ///
106 /// \param Funcs A reference to a vector of FunctionInfo objects to be
107 /// populated.
108 /// \param YAMLFile A StringRef representing the path to the YAML
109 /// file to be loaded.
110 /// \returns An `llvm::Error` indicating success or describing any issues
111 /// encountered during the loading process.
113
114private:
115 /// Builds a map from function names to FunctionInfo pointers based on the
116 /// provided `Funcs` vector.
117 ///
118 /// \param Funcs A reference to a vector of FunctionInfo objects.
119 /// \returns A StringMap mapping function names (StringRef) to their
120 /// corresponding FunctionInfo pointers.
121 StringMap<FunctionInfo *> buildFunctionMap();
122
123 /// Processes the parsed YAML functions and updates the `FuncMap` accordingly.
124 ///
125 /// \param FuncYAMLs A constant reference to an llvm::yaml::FunctionsYAML
126 /// object containing parsed YAML data.
127 /// \param FuncMap A reference to a StringMap mapping function names to
128 /// FunctionInfo pointers.
129 /// \returns An `llvm::Error` indicating success or describing any issues
130 /// encountered during processing.
131 llvm::Error processYAMLFunctions(const llvm::yaml::FunctionsYAML &FuncYAMLs,
133
134 /// Reference to the parent Gsym Creator object.
135 GsymCreator &GCreator;
136
137 /// Reference to the vector of FunctionInfo objects to be populated.
138 std::vector<FunctionInfo> &Funcs;
139};
140
141LLVM_ABI raw_ostream &operator<<(raw_ostream &OS, const CallSiteInfo &CSI);
143 const CallSiteInfoCollection &CSIC);
144
145} // namespace gsym
146} // namespace llvm
147
148#endif // LLVM_DEBUGINFO_GSYM_CALLSITEINFO_H
#define LLVM_ABI
Definition: Compiler.h:213
raw_pwrite_stream & OS
StringSet - A set-like wrapper for the StringMap.
Value * RHS
Lightweight error class with error context and mandatory checking.
Definition: Error.h:159
Tagged union holding either a T or a Error.
Definition: Error.h:485
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:133
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
LLVM_ABI llvm::Error loadYAML(StringRef YAMLFile)
This method reads the specified YAML file, parses its content, and updates the Funcs vector with call...
CallSiteInfoLoader(GsymCreator &GCreator, std::vector< FunctionInfo > &Funcs)
Constructor that initializes the CallSiteInfoLoader with necessary data structures.
Definition: CallSiteInfo.h:100
A simplified binary data writer class that doesn't require targets, target definitions,...
Definition: FileWriter.h:30
GsymCreator is used to emit GSYM data to a stand alone file or section within a file.
Definition: GsymCreator.h:135
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
LLVM_ABI raw_ostream & operator<<(raw_ostream &OS, const CallSiteInfo &CSI)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:477
LLVM_ABI llvm::Error encode(FileWriter &O) const
Encode this CallSiteInfoCollection object into a FileWriter stream.
std::vector< CallSiteInfo > CallSites
Definition: CallSiteInfo.h:78
static LLVM_ABI llvm::Expected< CallSiteInfoCollection > decode(DataExtractor &Data)
Decode a CallSiteInfoCollection object from a binary data stream.
LLVM_ABI llvm::Error encode(FileWriter &O) const
Encode this CallSiteInfo object into a FileWriter stream.
std::vector< uint32_t > MatchRegex
Offsets into the string table for function names regex patterns.
Definition: CallSiteInfo.h:48
uint64_t ReturnOffset
The return offset of the call site - relative to the function start.
Definition: CallSiteInfo.h:45
bool operator!=(const CallSiteInfo &RHS) const
Inequality comparison operator for CallSiteInfo.
Definition: CallSiteInfo.h:60
static LLVM_ABI llvm::Expected< CallSiteInfo > decode(DataExtractor &Data, uint64_t &Offset)
Decode a CallSiteInfo object from a binary data stream.
bool operator==(const CallSiteInfo &RHS) const
Equality comparison operator for CallSiteInfo.
Definition: CallSiteInfo.h:54
Function information in GSYM files encodes information for one contiguous address range.
Definition: FunctionInfo.h:93