LLVM: include/llvm/IR/ModuleSummaryIndexYAML.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9#ifndef LLVM_IR_MODULESUMMARYINDEXYAML_H
10#define LLVM_IR_MODULESUMMARYINDEXYAML_H
11
15#include
16
17namespace llvm {
18namespace yaml {
19
30
41
42template <>
47 io.enumCase(value, "UniformRetVal",
49 io.enumCase(value, "UniqueRetVal",
51 io.enumCase(value, "VirtualConstProp",
53 }
54};
55
64
65template <>
67 std::map<std::vector<uint64_t>, WholeProgramDevirtResolution::ByArg>> {
71 std::vector<uint64_t> Args;
72 std::pair<StringRef, StringRef> P = {"", Key};
73 while (.second.empty()) {
76 if (P.first.getAsInteger(0, Arg)) {
77 io.setError("key not an integer");
78 return;
79 }
80 Args.push_back(Arg);
81 }
83 }
85 IO &io,
87 for (auto &P : V) {
88 std::string Key;
90 if (.empty())
91 Key += ',';
93 }
95 }
96 }
97};
98
103 io.enumCase(value, "BranchFunnel",
105 }
106};
107
115
116template <>
119 std::map<uint64_t, WholeProgramDevirtResolution> &V) {
121 if (Key.getAsInteger(0, KeyInt)) {
122 io.setError("key not an integer");
123 return;
124 }
126 }
127 static void output(IO &io, std::map<uint64_t, WholeProgramDevirtResolution> &V) {
128 for (auto &P : V)
130 }
131};
132
139
141
145
147
148 std::vector<uint64_t> Refs = {};
154};
155
156}
157}
158
159namespace llvm {
160namespace yaml {
161
168
175
176}
177}
178
181
182namespace llvm {
183namespace yaml {
184
205
206}
207}
208
210
211namespace llvm {
212namespace yaml {
213
214
217 std::vector GVSums;
220 if (Key.getAsInteger(0, KeyInt)) {
221 io.setError("key not an integer");
222 return;
223 }
224 auto &Elem = V.try_emplace(KeyInt, false).first->second;
225 for (auto &GVSum : GVSums) {
229 GVSum.NotEligibleToImport, GVSum.Live, GVSum.IsLocal,
230 GVSum.CanAutoHide,
232 if (GVSum.Aliasee) {
233 auto ASum = std::make_unique(GVFlags);
234 V.try_emplace(*GVSum.Aliasee, false);
235 ValueInfo AliaseeVI(false, &*V.find(*GVSum.Aliasee));
236
237
238
239 ASum->setAliasee(AliaseeVI, nullptr);
240 Elem.addSummary(std::move(ASum));
241 continue;
242 }
244 Refs.reserve(GVSum.Refs.size());
245 for (auto &RefGUID : GVSum.Refs) {
246 auto It = V.try_emplace(RefGUID, false).first;
248 }
249 Elem.addSummary(std::make_unique(
252 std::move(GVSum.TypeTestAssumeVCalls),
253 std::move(GVSum.TypeCheckedLoadVCalls),
254 std::move(GVSum.TypeTestAssumeConstVCalls),
255 std::move(GVSum.TypeCheckedLoadConstVCalls),
258 }
259 }
261 for (auto &P : V) {
262 std::vector GVSums;
263 for (auto &Sum : P.second.getSummaryList()) {
265 std::vector<uint64_t> Refs;
266 Refs.reserve(FSum->refs().size());
267 for (auto &VI : FSum->refs())
268 Refs.push_back(VI.getGUID());
270 FSum->flags().Linkage, FSum->flags().Visibility,
271 static_cast<bool>(FSum->flags().NotEligibleToImport),
272 static_cast<bool>(FSum->flags().Live),
273 static_cast<bool>(FSum->flags().DSOLocal),
274 static_cast<bool>(FSum->flags().CanAutoHide),
275 FSum->flags().ImportType, std::nullopt, Refs,
276 FSum->type_tests(), FSum->type_test_assume_vcalls(),
277 FSum->type_checked_load_vcalls(),
278 FSum->type_test_assume_const_vcalls(),
279 FSum->type_checked_load_const_vcalls()});
281 ASum && ASum->hasAliasee()) {
283 ASum->flags().Linkage, ASum->flags().Visibility,
284 static_cast<bool>(ASum->flags().NotEligibleToImport),
285 static_cast<bool>(ASum->flags().Live),
286 static_cast<bool>(ASum->flags().DSOLocal),
287 static_cast<bool>(ASum->flags().CanAutoHide),
288 ASum->flags().ImportType,
289 ASum->getAliaseeGUID()});
290 }
291 }
292 if (!GVSums.empty())
294 }
295 }
297 for (auto &P : V) {
298 for (auto &Sum : P.second.getSummaryList()) {
300 ValueInfo AliaseeVI = Alias->getAliaseeVI();
302 if (AliaseeSL.empty()) {
304 Alias->setAliasee(EmptyVI, nullptr);
305 } else
306 Alias->setAliasee(AliaseeVI, AliaseeSL[0].get());
307 }
308 }
309 }
310 }
311};
312
320 for (auto &TidIter : V)
321 io.mapRequired(TidIter.second.first, TidIter.second.second);
322 }
323};
324
327 io.mapOptional("GlobalValueMap", index.GlobalValueMap);
330 index.GlobalValueMap);
331
333 io.mapOptional("TypeIdMap", index.TypeIdMap);
334 } else {
337 for (auto &[TypeGUID, TypeIdSummaryMap] : TypeIdMap) {
338
339
340 StringRef KeyRef = index.TypeIdSaver.save(TypeIdSummaryMap.first);
341 index.TypeIdMap.insert(
342 {TypeGUID, {KeyRef, std::move(TypeIdSummaryMap.second)}});
343 }
344 }
345
346 io.mapOptional("WithGlobalValueDeadStripping",
347 index.WithGlobalValueDeadStripping);
348
350 auto CfiFunctionDefs = index.CfiFunctionDefs.symbols();
352 io.mapOptional("CfiFunctionDefs", CfiFunctionDefs);
353 auto CfiFunctionDecls(index.CfiFunctionDecls.symbols());
355 io.mapOptional("CfiFunctionDecls", CfiFunctionDecls);
356 } else {
357 std::vectorstd::string CfiFunctionDefs;
358 io.mapOptional("CfiFunctionDefs", CfiFunctionDefs);
359 index.CfiFunctionDefs = {CfiFunctionDefs.begin(), CfiFunctionDefs.end()};
360 std::vectorstd::string CfiFunctionDecls;
361 io.mapOptional("CfiFunctionDecls", CfiFunctionDecls);
362 index.CfiFunctionDecls = {CfiFunctionDecls.begin(),
363 CfiFunctionDecls.end()};
364 }
365 }
366};
367
368}
369}
370
371#endif
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
Utility for declaring that a std::vector of a particular type should be considered a YAML sequence.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
std::vector< StringRef > symbols() const
Function summary information to aid decisions and implementation of importing.
static LLVM_ABI GUID getGUIDAssumingExternalLinkage(StringRef GlobalName)
Return a 64-bit global unique ID constructed from the name of a global symbol.
VisibilityTypes
An enumeration for the kinds of visibility of global values.
LinkageTypes
An enumeration for the kinds of linkage for global values.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
StringRef save(const char *S)
virtual bool outputting() const =0
void enumCase(T &Val, StringRef Str, const T ConstVal)
void mapOptional(StringRef Key, T &Val)
virtual void setError(const Twine &)=0
void mapRequired(StringRef Key, T &Val)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
std::multimap< GlobalValue::GUID, std::pair< StringRef, TypeIdSummary > > TypeIdSummaryMapTy
Map of a type GUID to type id string and summary (multimap used in case of GUID conflicts).
std::string utostr(uint64_t X, bool isNeg=false)
std::map< GlobalValue::GUID, GlobalValueSummaryInfo > GlobalValueSummaryMapTy
Map from global value GUID to corresponding summary structures.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
void sort(IteratorTy Start, IteratorTy End)
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
Implement std::hash so that hash_code can be used in STL containers.
A specification for a virtual function call with all constant integer arguments.
Flags specific to function summaries.
An "identifier" for a virtual function.
Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
std::map< uint64_t, WholeProgramDevirtResolution > WPDRes
Mapping from byte offset to whole-program devirt resolution for that (typeid, byte offset) pair.
Kind
Specifies which kind of type check we should emit for this byte array.
@ Unknown
Unknown (analysis not performed, don't lower)
@ Single
Single element (last example in "Short Inline Bit Vectors")
@ Inline
Inlined bit vector ("Short Inline Bit Vectors")
@ Unsat
Unsatisfiable type (i.e. no global has this type metadata)
@ AllOnes
All-ones bit vector ("Eliminating Bit Vector Checks for All-Ones Bit Vectors")
@ ByteArray
Test a byte array (first example)
unsigned SizeM1BitWidth
Range of size-1 expressed as a bit width.
enum llvm::TypeTestResolution::Kind TheKind
Struct that holds a reference to a particular GUID in a global value summary.
ArrayRef< std::unique_ptr< GlobalValueSummary > > getSummaryList() const
@ UniformRetVal
Uniform return value optimization.
@ VirtualConstProp
Virtual constant propagation.
@ UniqueRetVal
Unique return value optimization.
@ Indir
Just do a regular virtual call.
uint64_t Info
Additional information for the resolution:
enum llvm::WholeProgramDevirtResolution::ByArg::Kind TheKind
enum llvm::WholeProgramDevirtResolution::Kind TheKind
std::map< std::vector< uint64_t >, ByArg > ResByArg
Resolutions for calls with all constant integer arguments (excluding the first argument,...
std::string SingleImplName
@ SingleImpl
Single implementation devirtualization.
@ Indir
Just do a regular virtual call.
@ BranchFunnel
When retpoline mitigation is enabled, use a branch funnel that is defined in the merged module.
static void fixAliaseeLinks(GlobalValueSummaryMapTy &V)
Definition ModuleSummaryIndexYAML.h:296
static void output(IO &io, GlobalValueSummaryMapTy &V)
Definition ModuleSummaryIndexYAML.h:260
static void inputOne(IO &io, StringRef Key, GlobalValueSummaryMapTy &V)
Definition ModuleSummaryIndexYAML.h:216
static void output(IO &io, TypeIdSummaryMapTy &V)
Definition ModuleSummaryIndexYAML.h:319
static void inputOne(IO &io, StringRef Key, TypeIdSummaryMapTy &V)
Definition ModuleSummaryIndexYAML.h:314
static void inputOne(IO &io, StringRef Key, std::map< std::vector< uint64_t >, WholeProgramDevirtResolution::ByArg > &V)
Definition ModuleSummaryIndexYAML.h:68
static void output(IO &io, std::map< std::vector< uint64_t >, WholeProgramDevirtResolution::ByArg > &V)
Definition ModuleSummaryIndexYAML.h:84
static void inputOne(IO &io, StringRef Key, std::map< uint64_t, WholeProgramDevirtResolution > &V)
Definition ModuleSummaryIndexYAML.h:118
static void output(IO &io, std::map< uint64_t, WholeProgramDevirtResolution > &V)
Definition ModuleSummaryIndexYAML.h:127
This class should be specialized by any type that needs to be converted to/from a YAML mapping in the...
std::vector< FunctionSummary::ConstVCall > TypeTestAssumeConstVCalls
Definition ModuleSummaryIndexYAML.h:152
bool NotEligibleToImport
Definition ModuleSummaryIndexYAML.h:143
std::vector< FunctionSummary::VFuncId > TypeCheckedLoadVCalls
Definition ModuleSummaryIndexYAML.h:151
std::vector< uint64_t > Refs
Definition ModuleSummaryIndexYAML.h:148
unsigned ImportType
Definition ModuleSummaryIndexYAML.h:144
std::optional< uint64_t > Aliasee
Definition ModuleSummaryIndexYAML.h:146
unsigned Visibility
Definition ModuleSummaryIndexYAML.h:142
std::vector< FunctionSummary::ConstVCall > TypeCheckedLoadConstVCalls
Definition ModuleSummaryIndexYAML.h:153
std::vector< uint64_t > TypeTests
Definition ModuleSummaryIndexYAML.h:149
bool IsLocal
Definition ModuleSummaryIndexYAML.h:143
std::vector< FunctionSummary::VFuncId > TypeTestAssumeVCalls
Definition ModuleSummaryIndexYAML.h:150
unsigned Linkage
Definition ModuleSummaryIndexYAML.h:142
bool Live
Definition ModuleSummaryIndexYAML.h:143
bool CanAutoHide
Definition ModuleSummaryIndexYAML.h:143
static void mapping(IO &io, FunctionSummary::ConstVCall &id)
Definition ModuleSummaryIndexYAML.h:170
static void mapping(IO &io, FunctionSummary::VFuncId &id)
Definition ModuleSummaryIndexYAML.h:163
static void mapping(IO &io, GlobalValueSummaryYaml &summary)
Definition ModuleSummaryIndexYAML.h:186
static void mapping(IO &io, ModuleSummaryIndex &index)
Definition ModuleSummaryIndexYAML.h:326
static void mapping(IO &io, TypeIdSummary &summary)
Definition ModuleSummaryIndexYAML.h:134
static void mapping(IO &io, TypeTestResolution &res)
Definition ModuleSummaryIndexYAML.h:32
static void mapping(IO &io, WholeProgramDevirtResolution &res)
Definition ModuleSummaryIndexYAML.h:109
static void mapping(IO &io, WholeProgramDevirtResolution::ByArg &res)
Definition ModuleSummaryIndexYAML.h:57
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
static void enumeration(IO &io, TypeTestResolution::Kind &value)
Definition ModuleSummaryIndexYAML.h:21
static void enumeration(IO &io, WholeProgramDevirtResolution::ByArg::Kind &value)
Definition ModuleSummaryIndexYAML.h:44
static void enumeration(IO &io, WholeProgramDevirtResolution::Kind &value)
Definition ModuleSummaryIndexYAML.h:100
This class should be specialized by any integral type that converts to/from a YAML scalar where there...