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