9#ifndef LLVM_IR_MODULESUMMARYINDEXYAML_H
10#define LLVM_IR_MODULESUMMARYINDEXYAML_H
51 io.
enumCase(value,
"VirtualConstProp",
67 std::map<std::vector<uint64_t>, WholeProgramDevirtResolution::ByArg>> {
71 std::vector<uint64_t> Args;
72 std::pair<StringRef, StringRef>
P = {
"",
Key};
73 while (!
P.second.empty()) {
74 P =
P.second.split(
',');
76 if (
P.first.getAsInteger(0, Arg)) {
119 std::map<uint64_t, WholeProgramDevirtResolution> &V) {
121 if (
Key.getAsInteger(0, KeyInt)) {
127 static void output(
IO &io, std::map<uint64_t, WholeProgramDevirtResolution> &V) {
148 std::vector<uint64_t>
Refs = {};
217 std::vector<GlobalValueSummaryYaml> GVSums;
220 if (
Key.getAsInteger(0, KeyInt)) {
224 auto &Elem = V.try_emplace(KeyInt,
false).first->second;
225 for (
auto &GVSum : GVSums) {
229 GVSum.NotEligibleToImport, GVSum.Live, GVSum.IsLocal,
233 auto ASum = std::make_unique<AliasSummary>(GVFlags);
234 V.try_emplace(*GVSum.Aliasee,
false);
235 ValueInfo AliaseeVI(
false, &*V.find(*GVSum.Aliasee));
239 ASum->setAliasee(AliaseeVI,
nullptr);
240 Elem.SummaryList.push_back(std::move(ASum));
244 Refs.
reserve(GVSum.Refs.size());
245 for (
auto &RefGUID : GVSum.Refs) {
246 auto It = V.try_emplace(RefGUID,
false).first;
249 Elem.SummaryList.push_back(std::make_unique<FunctionSummary>(
252 std::move(GVSum.TypeTestAssumeVCalls),
253 std::move(GVSum.TypeCheckedLoadVCalls),
254 std::move(GVSum.TypeTestAssumeConstVCalls),
255 std::move(GVSum.TypeCheckedLoadConstVCalls),
262 std::vector<GlobalValueSummaryYaml> GVSums;
263 for (
auto &Sum :
P.second.SummaryList) {
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()});
298 for (
auto &Sum :
P.second.SummaryList) {
300 ValueInfo AliaseeVI = Alias->getAliaseeVI();
302 if (AliaseeSL.empty()) {
304 Alias->setAliasee(
EmptyVI,
nullptr);
306 Alias->setAliasee(AliaseeVI, AliaseeSL[0].
get());
320 for (
auto &TidIter : V)
321 io.
mapRequired(TidIter.second.first.str().c_str(), TidIter.second.second);
327 io.
mapOptional(
"GlobalValueMap", index.GlobalValueMap);
330 index.GlobalValueMap);
337 for (
auto &[TypeGUID, TypeIdSummaryMap] : TypeIdMap) {
340 StringRef KeyRef = index.TypeIdSaver.
save(TypeIdSummaryMap.first);
341 index.TypeIdMap.insert(
342 {TypeGUID, {KeyRef, std::move(TypeIdSummaryMap.second)}});
347 index.WithGlobalValueDeadStripping);
350 auto CfiFunctionDefs = index.CfiFunctionDefs.
symbols();
352 io.
mapOptional(
"CfiFunctionDefs", CfiFunctionDefs);
353 auto CfiFunctionDecls(index.CfiFunctionDecls.
symbols());
355 io.
mapOptional(
"CfiFunctionDecls", CfiFunctionDecls);
357 std::vector<std::string> CfiFunctionDefs;
358 io.
mapOptional(
"CfiFunctionDefs", CfiFunctionDefs);
359 index.CfiFunctionDefs = {CfiFunctionDefs.begin(), CfiFunctionDefs.end()};
360 std::vector<std::string> CfiFunctionDecls;
361 io.
mapOptional(
"CfiFunctionDecls", CfiFunctionDecls);
362 index.CfiFunctionDecls = {CfiFunctionDecls.begin(),
363 CfiFunctionDecls.end()};
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)
void mapOptional(const char *Key, T &Val)
virtual bool outputting() const =0
void mapRequired(const char *Key, T &Val)
virtual void setError(const Twine &)=0
void enumCase(T &Val, const char *Str, const T ConstVal)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - 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)
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)
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
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)
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)
static void enumeration(IO &io, WholeProgramDevirtResolution::ByArg::Kind &value)
static void enumeration(IO &io, WholeProgramDevirtResolution::Kind &value)
This class should be specialized by any integral type that converts to/from a YAML scalar where there...