9#ifndef LLVM_IR_MODULESUMMARYINDEXYAML_H
10#define LLVM_IR_MODULESUMMARYINDEXYAML_H
20 io.enumCase(
value,
"Unknown", TypeTestResolution::Unknown);
21 io.enumCase(
value,
"Unsat", TypeTestResolution::Unsat);
22 io.enumCase(
value,
"ByteArray", TypeTestResolution::ByteArray);
23 io.enumCase(
value,
"Inline", TypeTestResolution::Inline);
24 io.enumCase(
value,
"Single", TypeTestResolution::Single);
25 io.enumCase(
value,
"AllOnes", TypeTestResolution::AllOnes);
31 io.mapOptional(
"Kind", res.
TheKind);
33 io.mapOptional(
"AlignLog2", res.
AlignLog2);
34 io.mapOptional(
"SizeM1", res.
SizeM1);
35 io.mapOptional(
"BitMask", res.
BitMask);
44 io.enumCase(
value,
"Indir", WholeProgramDevirtResolution::ByArg::Indir);
45 io.enumCase(
value,
"UniformRetVal",
46 WholeProgramDevirtResolution::ByArg::UniformRetVal);
47 io.enumCase(
value,
"UniqueRetVal",
48 WholeProgramDevirtResolution::ByArg::UniqueRetVal);
49 io.enumCase(
value,
"VirtualConstProp",
50 WholeProgramDevirtResolution::ByArg::VirtualConstProp);
56 io.mapOptional(
"Kind", res.
TheKind);
57 io.mapOptional(
"Info", res.
Info);
58 io.mapOptional(
"Byte", res.
Byte);
59 io.mapOptional(
"Bit", res.
Bit);
65 std::map<std::vector<uint64_t>, WholeProgramDevirtResolution::ByArg>> {
69 std::vector<uint64_t> Args;
70 std::pair<StringRef, StringRef>
P = {
"", Key};
71 while (!
P.second.empty()) {
72 P =
P.second.split(
',');
74 if (
P.first.getAsInteger(0, Arg)) {
75 io.setError(
"key not an integer");
80 io.mapRequired(Key.str().c_str(), V[Args]);
90 Key += llvm::utostr(Arg);
92 io.mapRequired(Key.c_str(),
P.second);
99 io.enumCase(
value,
"Indir", WholeProgramDevirtResolution::Indir);
100 io.enumCase(
value,
"SingleImpl", WholeProgramDevirtResolution::SingleImpl);
101 io.enumCase(
value,
"BranchFunnel",
102 WholeProgramDevirtResolution::BranchFunnel);
108 io.mapOptional(
"Kind", res.
TheKind);
110 io.mapOptional(
"ResByArg", res.
ResByArg);
117 std::map<uint64_t, WholeProgramDevirtResolution> &V) {
119 if (Key.getAsInteger(0, KeyInt)) {
120 io.setError(
"key not an integer");
123 io.mapRequired(Key.str().c_str(), V[KeyInt]);
125 static void output(IO &io, std::map<uint64_t, WholeProgramDevirtResolution> &V) {
127 io.mapRequired(llvm::utostr(
P.first).c_str(),
P.second);
133 io.mapOptional(
"TTRes", summary.
TTRes);
134 io.mapOptional(
"WPDRes", summary.
WPDRes);
146 std::vector<uint64_t>
Refs = {};
162 io.mapOptional(
"GUID",
id.GUID);
163 io.mapOptional(
"Offset",
id.
Offset);
169 io.mapOptional(
"VFunc",
id.VFunc);
170 io.mapOptional(
"Args",
id.Args);
185 io.mapOptional(
"Linkage", summary.
Linkage);
186 io.mapOptional(
"Visibility", summary.
Visibility);
188 io.mapOptional(
"Live", summary.
Live);
189 io.mapOptional(
"Local", summary.
IsLocal);
190 io.mapOptional(
"CanAutoHide", summary.
CanAutoHide);
191 io.mapOptional(
"ImportType", summary.
ImportType);
192 io.mapOptional(
"Aliasee", summary.
Aliasee);
193 io.mapOptional(
"Refs", summary.
Refs);
194 io.mapOptional(
"TypeTests", summary.
TypeTests);
197 io.mapOptional(
"TypeTestAssumeConstVCalls",
199 io.mapOptional(
"TypeCheckedLoadConstVCalls",
215 std::vector<GlobalValueSummaryYaml> GVSums;
216 io.mapRequired(Key.str().c_str(), GVSums);
218 if (Key.getAsInteger(0, KeyInt)) {
219 io.setError(
"key not an integer");
222 auto &Elem = V.try_emplace(KeyInt,
false).first->second;
223 for (
auto &GVSum : GVSums) {
227 GVSum.NotEligibleToImport, GVSum.Live, GVSum.IsLocal,
231 auto ASum = std::make_unique<AliasSummary>(GVFlags);
232 if (!V.count(*GVSum.Aliasee))
233 V.emplace(*GVSum.Aliasee,
false);
234 ValueInfo AliaseeVI(
false, &*V.find(*GVSum.Aliasee));
238 ASum->setAliasee(AliaseeVI,
nullptr);
239 Elem.SummaryList.push_back(std::move(ASum));
243 Refs.
reserve(GVSum.Refs.size());
244 for (
auto &RefGUID : GVSum.Refs) {
245 auto It = V.try_emplace(RefGUID,
false).first;
248 Elem.SummaryList.push_back(std::make_unique<FunctionSummary>(
251 std::move(GVSum.TypeTestAssumeVCalls),
252 std::move(GVSum.TypeCheckedLoadVCalls),
253 std::move(GVSum.TypeTestAssumeConstVCalls),
254 std::move(GVSum.TypeCheckedLoadConstVCalls),
261 std::vector<GlobalValueSummaryYaml> GVSums;
262 for (
auto &Sum :
P.second.SummaryList) {
263 if (
auto *FSum = dyn_cast<FunctionSummary>(Sum.get())) {
264 std::vector<uint64_t> Refs;
265 Refs.reserve(FSum->refs().size());
266 for (
auto &VI : FSum->refs())
267 Refs.push_back(VI.getGUID());
269 FSum->flags().
Linkage, FSum->flags().Visibility,
270 static_cast<bool>(FSum->flags().NotEligibleToImport),
271 static_cast<bool>(FSum->flags().Live),
272 static_cast<bool>(FSum->flags().DSOLocal),
273 static_cast<bool>(FSum->flags().CanAutoHide),
274 FSum->flags().ImportType, std::nullopt, Refs,
275 FSum->type_tests(), FSum->type_test_assume_vcalls(),
276 FSum->type_checked_load_vcalls(),
277 FSum->type_test_assume_const_vcalls(),
278 FSum->type_checked_load_const_vcalls()});
279 }
else if (
auto *ASum = dyn_cast<AliasSummary>(Sum.get());
280 ASum && ASum->hasAliasee()) {
282 ASum->flags().
Linkage, ASum->flags().Visibility,
283 static_cast<bool>(ASum->flags().NotEligibleToImport),
284 static_cast<bool>(ASum->flags().Live),
285 static_cast<bool>(ASum->flags().DSOLocal),
286 static_cast<bool>(ASum->flags().CanAutoHide),
287 ASum->flags().ImportType,
288 ASum->getAliaseeGUID()});
292 io.mapRequired(llvm::utostr(
P.first).c_str(), GVSums);
297 for (
auto &Sum :
P.second.SummaryList) {
298 if (
auto *Alias = dyn_cast<AliasSummary>(Sum.get())) {
299 ValueInfo AliaseeVI = Alias->getAliaseeVI();
301 if (AliaseeSL.empty()) {
303 Alias->setAliasee(
EmptyVI,
nullptr);
305 Alias->setAliasee(AliaseeVI, AliaseeSL[0].
get());
315 io.mapRequired(Key.str().c_str(), TId);
319 for (
auto &TidIter : V)
320 io.mapRequired(TidIter.second.first.str().c_str(), TidIter.second.second);
326 io.mapOptional(
"GlobalValueMap", index.GlobalValueMap);
327 if (!io.outputting())
329 index.GlobalValueMap);
331 if (io.outputting()) {
332 io.mapOptional(
"TypeIdMap", index.TypeIdMap);
335 io.mapOptional(
"TypeIdMap", TypeIdMap);
336 for (
auto &[TypeGUID, TypeIdSummaryMap] : TypeIdMap) {
339 StringRef KeyRef = index.TypeIdSaver.
save(TypeIdSummaryMap.first);
340 index.TypeIdMap.insert(
341 {TypeGUID, {KeyRef, std::move(TypeIdSummaryMap.second)}});
345 io.mapOptional(
"WithGlobalValueDeadStripping",
346 index.WithGlobalValueDeadStripping);
348 if (io.outputting()) {
349 std::vector<std::string> CfiFunctionDefs(index.CfiFunctionDefs.begin(),
350 index.CfiFunctionDefs.end());
351 io.mapOptional(
"CfiFunctionDefs", CfiFunctionDefs);
352 std::vector<std::string> CfiFunctionDecls(index.CfiFunctionDecls.begin(),
353 index.CfiFunctionDecls.end());
354 io.mapOptional(
"CfiFunctionDecls", CfiFunctionDecls);
356 std::vector<std::string> CfiFunctionDefs;
357 io.mapOptional(
"CfiFunctionDefs", CfiFunctionDefs);
358 index.CfiFunctionDefs = {CfiFunctionDefs.begin(), CfiFunctionDefs.end()};
359 std::vector<std::string> CfiFunctionDecls;
360 io.mapOptional(
"CfiFunctionDecls", CfiFunctionDecls);
361 index.CfiFunctionDecls = {CfiFunctionDecls.begin(),
362 CfiFunctionDecls.end()};
Given that RA is a live value
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Function summary information to aid decisions and implementation of importing.
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
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)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
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::map< GlobalValue::GUID, GlobalValueSummaryInfo > GlobalValueSummaryMapTy
Map from global value GUID to corresponding summary structures.
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.
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
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
static void fixAliaseeLinks(GlobalValueSummaryMapTy &V)
static void output(IO &io, GlobalValueSummaryMapTy &V)
static void inputOne(IO &io, StringRef Key, GlobalValueSummaryMapTy &V)
static void output(IO &io, TypeIdSummaryMapTy &V)
static void inputOne(IO &io, StringRef Key, TypeIdSummaryMapTy &V)
static void inputOne(IO &io, StringRef Key, std::map< std::vector< uint64_t >, WholeProgramDevirtResolution::ByArg > &V)
static void output(IO &io, std::map< std::vector< uint64_t >, WholeProgramDevirtResolution::ByArg > &V)
static void inputOne(IO &io, StringRef Key, std::map< uint64_t, WholeProgramDevirtResolution > &V)
static void output(IO &io, std::map< uint64_t, WholeProgramDevirtResolution > &V)
std::vector< FunctionSummary::ConstVCall > TypeTestAssumeConstVCalls
std::vector< FunctionSummary::VFuncId > TypeCheckedLoadVCalls
std::vector< uint64_t > Refs
std::optional< uint64_t > Aliasee
std::vector< FunctionSummary::ConstVCall > TypeCheckedLoadConstVCalls
std::vector< uint64_t > TypeTests
std::vector< FunctionSummary::VFuncId > TypeTestAssumeVCalls
static void mapping(IO &io, FunctionSummary::ConstVCall &id)
static void mapping(IO &io, FunctionSummary::VFuncId &id)
static void mapping(IO &io, GlobalValueSummaryYaml &summary)
static void mapping(IO &io, ModuleSummaryIndex &index)
static void mapping(IO &io, TypeIdSummary &summary)
static void mapping(IO &io, TypeTestResolution &res)
static void mapping(IO &io, WholeProgramDevirtResolution &res)
static void mapping(IO &io, WholeProgramDevirtResolution::ByArg &res)
static void enumeration(IO &io, TypeTestResolution::Kind &value)
static void enumeration(IO &io, WholeProgramDevirtResolution::ByArg::Kind &value)
static void enumeration(IO &io, WholeProgramDevirtResolution::Kind &value)