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) {
149 std::vector<uint64_t>
Refs = {};
219 std::vector<GlobalValueSummaryYaml> GVSums;
222 if (
Key.getAsInteger(0, KeyInt)) {
226 auto &Elem = V.try_emplace(KeyInt,
false).first->second;
227 for (
auto &GVSum : GVSums) {
231 GVSum.NotEligibleToImport, GVSum.Live, GVSum.IsLocal,
234 GVSum.NoRenameOnPromotion);
236 auto ASum = std::make_unique<AliasSummary>(GVFlags);
237 V.try_emplace(*GVSum.Aliasee,
false);
238 ValueInfo AliaseeVI(
false, &*V.find(*GVSum.Aliasee));
242 ASum->setAliasee(AliaseeVI,
nullptr);
243 Elem.addSummary(std::move(ASum));
247 Refs.
reserve(GVSum.Refs.size());
248 for (
auto &RefGUID : GVSum.Refs) {
249 auto It = V.try_emplace(RefGUID,
false).first;
252 Elem.addSummary(std::make_unique<FunctionSummary>(
255 std::move(GVSum.TypeTestAssumeVCalls),
256 std::move(GVSum.TypeCheckedLoadVCalls),
257 std::move(GVSum.TypeTestAssumeConstVCalls),
258 std::move(GVSum.TypeCheckedLoadConstVCalls),
265 std::vector<GlobalValueSummaryYaml> GVSums;
266 for (
auto &Sum :
P.second.getSummaryList()) {
268 std::vector<uint64_t> Refs;
269 Refs.reserve(FSum->refs().size());
270 for (
auto &VI : FSum->refs())
271 Refs.push_back(VI.getGUID());
273 FSum->flags().Linkage, FSum->flags().Visibility,
274 static_cast<bool>(FSum->flags().NotEligibleToImport),
275 static_cast<bool>(FSum->flags().Live),
276 static_cast<bool>(FSum->flags().DSOLocal),
277 static_cast<bool>(FSum->flags().CanAutoHide),
278 FSum->flags().ImportType,
279 static_cast<bool>(FSum->flags().NoRenameOnPromotion),
280 std::nullopt, Refs, FSum->type_tests(),
281 FSum->type_test_assume_vcalls(), FSum->type_checked_load_vcalls(),
282 FSum->type_test_assume_const_vcalls(),
283 FSum->type_checked_load_const_vcalls()});
285 ASum && ASum->hasAliasee()) {
287 ASum->flags().Linkage, ASum->flags().Visibility,
288 static_cast<bool>(ASum->flags().NotEligibleToImport),
289 static_cast<bool>(ASum->flags().Live),
290 static_cast<bool>(ASum->flags().DSOLocal),
291 static_cast<bool>(ASum->flags().CanAutoHide),
292 ASum->flags().ImportType,
293 static_cast<bool>(ASum->flags().NoRenameOnPromotion),
294 ASum->getAliaseeGUID()});
303 for (
auto &Sum :
P.second.getSummaryList()) {
305 ValueInfo AliaseeVI = Alias->getAliaseeVI();
307 if (AliaseeSL.empty()) {
309 Alias->setAliasee(
EmptyVI,
nullptr);
311 Alias->setAliasee(AliaseeVI, AliaseeSL[0].
get());
325 for (
auto &TidIter : V)
326 io.
mapRequired(TidIter.second.first, TidIter.second.second);
332 io.
mapOptional(
"GlobalValueMap", index.GlobalValueMap);
335 index.GlobalValueMap);
342 for (
auto &[TypeGUID, TypeIdSummaryMap] : TypeIdMap) {
345 StringRef KeyRef = index.TypeIdSaver.
save(TypeIdSummaryMap.first);
346 index.TypeIdMap.insert(
347 {TypeGUID, {KeyRef, std::move(TypeIdSummaryMap.second)}});
352 index.WithGlobalValueDeadStripping);
355 auto CfiFunctionDefs = index.CfiFunctionDefs.
symbols();
357 io.
mapOptional(
"CfiFunctionDefs", CfiFunctionDefs);
358 auto CfiFunctionDecls(index.CfiFunctionDecls.
symbols());
360 io.
mapOptional(
"CfiFunctionDecls", CfiFunctionDecls);
362 std::vector<std::string> CfiFunctionDefs;
363 io.
mapOptional(
"CfiFunctionDefs", CfiFunctionDefs);
364 index.CfiFunctionDefs = {CfiFunctionDefs.begin(), CfiFunctionDefs.end()};
365 std::vector<std::string> CfiFunctionDecls;
366 io.
mapOptional(
"CfiFunctionDecls", CfiFunctionDecls);
367 index.CfiFunctionDecls = {CfiFunctionDecls.begin(),
368 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)
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<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...