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 for (
const auto &
P : V.sortedRange()) {
266 std::vector<GlobalValueSummaryYaml> GVSums;
267 for (
auto &Sum :
P.second.getSummaryList()) {
269 std::vector<uint64_t> Refs;
270 Refs.reserve(FSum->refs().size());
271 for (
auto &VI : FSum->refs())
272 Refs.push_back(VI.getGUID());
274 FSum->flags().Linkage, FSum->flags().Visibility,
275 static_cast<bool>(FSum->flags().NotEligibleToImport),
276 static_cast<bool>(FSum->flags().Live),
277 static_cast<bool>(FSum->flags().DSOLocal),
278 static_cast<bool>(FSum->flags().CanAutoHide),
279 FSum->flags().ImportType,
280 static_cast<bool>(FSum->flags().NoRenameOnPromotion),
281 std::nullopt, Refs, FSum->type_tests(),
282 FSum->type_test_assume_vcalls(), FSum->type_checked_load_vcalls(),
283 FSum->type_test_assume_const_vcalls(),
284 FSum->type_checked_load_const_vcalls()});
286 ASum && ASum->hasAliasee()) {
288 ASum->flags().Linkage, ASum->flags().Visibility,
289 static_cast<bool>(ASum->flags().NotEligibleToImport),
290 static_cast<bool>(ASum->flags().Live),
291 static_cast<bool>(ASum->flags().DSOLocal),
292 static_cast<bool>(ASum->flags().CanAutoHide),
293 ASum->flags().ImportType,
294 static_cast<bool>(ASum->flags().NoRenameOnPromotion),
295 ASum->getAliaseeGUID()});
304 for (
auto &Sum :
P.second.getSummaryList()) {
306 ValueInfo AliaseeVI = Alias->getAliaseeVI();
308 if (AliaseeSL.empty()) {
310 Alias->setAliasee(
EmptyVI,
nullptr);
312 Alias->setAliasee(AliaseeVI, AliaseeSL[0].
get());
326 for (
auto &TidIter : V)
327 io.
mapRequired(TidIter.second.first, TidIter.second.second);
333 std::pair<StringRef, GlobalValue::GUID> &NameAndGUID) {
351 io.
mapOptional(
"GlobalValueMap", index.GlobalValueMap);
354 index.GlobalValueMap);
361 for (
auto &[TypeGUID, TypeIdSummaryMap] : TypeIdMap) {
364 StringRef KeyRef = index.TypeIdSaver.
save(TypeIdSummaryMap.first);
365 index.TypeIdMap.insert(
366 {TypeGUID, {KeyRef, std::move(TypeIdSummaryMap.second)}});
371 index.WithGlobalValueDeadStripping);
375 io.
mapOptional(
"CfiFunctionDefs", CfiFunctionDefs);
377 io.
mapOptional(
"CfiFunctionDecls", CfiFunctionDecls);
379 std::vector<std::pair<StringRef, GlobalValue::GUID>> CfiFunctionDefs;
380 io.
mapOptional(
"CfiFunctionDefs", CfiFunctionDefs);
381 for (
auto &[S,
G] : CfiFunctionDefs)
383 std::vector<std::pair<StringRef, GlobalValue::GUID>> CfiFunctionDecls;
384 io.
mapOptional(
"CfiFunctionDecls", CfiFunctionDecls);
385 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.
@ 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...