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)) {
121 std::map<uint64_t, WholeProgramDevirtResolution> &
V) {
123 if (
Key.getAsInteger(0, KeyInt)) {
129 static void output(
IO &io, std::map<uint64_t, WholeProgramDevirtResolution> &
V) {
151 std::vector<uint64_t>
Refs = {};
221 std::vector<GlobalValueSummaryYaml> GVSums;
224 if (
Key.getAsInteger(0, KeyInt)) {
228 auto &Elem =
V.try_emplace(KeyInt,
false).first->second;
229 for (
auto &GVSum : GVSums) {
233 GVSum.NotEligibleToImport, GVSum.Live, GVSum.IsLocal,
236 GVSum.NoRenameOnPromotion);
238 auto ASum = std::make_unique<AliasSummary>(GVFlags);
239 V.try_emplace(*GVSum.Aliasee,
false);
240 ValueInfo AliaseeVI(
false, &*
V.find(*GVSum.Aliasee));
244 ASum->setAliasee(AliaseeVI,
nullptr);
245 Elem.addSummary(std::move(ASum));
249 Refs.
reserve(GVSum.Refs.size());
250 for (
auto &RefGUID : GVSum.Refs) {
251 auto It =
V.try_emplace(RefGUID,
false).first;
254 Elem.addSummary(std::make_unique<FunctionSummary>(
257 std::move(GVSum.TypeTestAssumeVCalls),
258 std::move(GVSum.TypeCheckedLoadVCalls),
259 std::move(GVSum.TypeTestAssumeConstVCalls),
260 std::move(GVSum.TypeCheckedLoadConstVCalls),
267 for (
const auto &
P :
V.sortedRange()) {
268 std::vector<GlobalValueSummaryYaml> GVSums;
269 for (
auto &Sum :
P.second.getSummaryList()) {
271 std::vector<uint64_t> Refs;
272 Refs.reserve(FSum->refs().size());
273 for (
auto &VI : FSum->refs())
274 Refs.push_back(VI.getGUID());
276 FSum->flags().Linkage, FSum->flags().Visibility,
277 static_cast<bool>(FSum->flags().NotEligibleToImport),
278 static_cast<bool>(FSum->flags().Live),
279 static_cast<bool>(FSum->flags().DSOLocal),
280 static_cast<bool>(FSum->flags().CanAutoHide),
281 FSum->flags().ImportType,
282 static_cast<bool>(FSum->flags().NoRenameOnPromotion),
283 std::nullopt, Refs, FSum->type_tests(),
284 FSum->type_test_assume_vcalls(), FSum->type_checked_load_vcalls(),
285 FSum->type_test_assume_const_vcalls(),
286 FSum->type_checked_load_const_vcalls()});
288 ASum && ASum->hasAliasee()) {
290 ASum->flags().Linkage, ASum->flags().Visibility,
291 static_cast<bool>(ASum->flags().NotEligibleToImport),
292 static_cast<bool>(ASum->flags().Live),
293 static_cast<bool>(ASum->flags().DSOLocal),
294 static_cast<bool>(ASum->flags().CanAutoHide),
295 ASum->flags().ImportType,
296 static_cast<bool>(ASum->flags().NoRenameOnPromotion),
297 ASum->getAliaseeGUID()});
306 for (
auto &Sum :
P.second.getSummaryList()) {
308 ValueInfo AliaseeVI = Alias->getAliaseeVI();
310 if (AliaseeSL.empty()) {
312 Alias->setAliasee(
EmptyVI,
nullptr);
314 Alias->setAliasee(AliaseeVI, AliaseeSL[0].
get());
328 for (
auto &TidIter :
V)
329 io.
mapRequired(TidIter.second.first, TidIter.second.second);
335 std::pair<StringRef, GlobalValue::GUID> &NameAndGUID) {
353 io.
mapOptional(
"GlobalValueMap", index.GlobalValueMap);
356 index.GlobalValueMap);
363 for (
auto &[TypeGUID, TypeIdSummaryMap] : TypeIdMap) {
366 StringRef KeyRef = index.TypeIdSaver.
save(TypeIdSummaryMap.first);
367 index.TypeIdMap.insert(
368 {TypeGUID, {KeyRef, std::move(TypeIdSummaryMap.second)}});
373 index.WithGlobalValueDeadStripping);
377 io.
mapOptional(
"CfiFunctionDefs", CfiFunctionDefs);
379 io.
mapOptional(
"CfiFunctionDecls", CfiFunctionDecls);
381 std::vector<std::pair<StringRef, GlobalValue::GUID>> CfiFunctionDefs;
382 io.
mapOptional(
"CfiFunctionDefs", CfiFunctionDefs);
383 for (
auto &[S,
G] : CfiFunctionDefs)
385 std::vector<std::pair<StringRef, GlobalValue::GUID>> CfiFunctionDecls;
386 io.
mapOptional(
"CfiFunctionDecls", CfiFunctionDecls);
387 for (
auto &[S,
G] : CfiFunctionDecls)
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.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
std::vector< std::pair< StringRef, GlobalValue::GUID > > getSortedSymbols() const
API used for serialization, e.g. YAML.
void addSymbolWithThinLTOGUID(StringRef Name, GlobalValue::GUID GUID)
Add the function name and the GUID that ThinLTO uses for it.
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.
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)
std::pair< llvm::StringRef, llvm::GlobalValue::GUID > StringAndGUID
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)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
GlobalValueSummaryMap GlobalValueSummaryMapTy
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.
@ Speculative
Speculative devirtualization.
@ 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)
static void mapping(IO &io, std::pair< StringRef, GlobalValue::GUID > &NameAndGUID)
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...