Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
ModuleSummaryIndex.h
Go to the documentation of this file.
1//===- llvm/ModuleSummaryIndex.h - Module Summary Index ---------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9/// @file
10/// ModuleSummaryIndex.h This file contains the declarations the classes that
11/// hold the module index and summary for function importing.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_IR_MODULESUMMARYINDEX_H
16#define LLVM_IR_MODULESUMMARYINDEX_H
17
18#include "llvm/ADT/ArrayRef.h"
19#include "llvm/ADT/DenseMap.h"
20#include "llvm/ADT/STLExtras.h"
21#include "llvm/ADT/SmallString.h"
22#include "llvm/ADT/SmallVector.h"
23#include "llvm/ADT/StringExtras.h"
24#include "llvm/ADT/StringMap.h"
25#include "llvm/ADT/StringRef.h"
26#include "llvm/IR/ConstantRange.h"
27#include "llvm/IR/GlobalValue.h"
28#include "llvm/IR/Module.h"
29#include "llvm/Support/Allocator.h"
30#include "llvm/Support/MathExtras.h"
31#include "llvm/Support/ScaledNumber.h"
32#include "llvm/Support/StringSaver.h"
33#include "llvm/Support/raw_ostream.h"
34#include <algorithm>
35#include <array>
36#include <cassert>
37#include <cstddef>
38#include <cstdint>
39#include <map>
40#include <memory>
41#include <optional>
42#include <set>
43#include <string>
44#include <unordered_set>
45#include <utility>
46#include <vector>
47
48namespacellvm {
49
50template <class GraphType>structGraphTraits;
51
52namespaceyaml {
53
54template <typename T>structMappingTraits;
55
56}// end namespace yaml
57
58/// Class to accumulate and hold information about a callee.
59structCalleeInfo {
60enum classHotnessType :uint8_t {
61Unknown = 0,
62Cold = 1,
63None = 2,
64Hot = 3,
65Critical = 4
66 };
67
68// The size of the bit-field might need to be adjusted if more values are
69// added to HotnessType enum.
70uint32_tHotness : 3;
71
72// True if at least one of the calls to the callee is a tail call.
73boolHasTailCall : 1;
74
75 /// The value stored in RelBlockFreq has to be interpreted as the digits of
76 /// a scaled number with a scale of \p -ScaleShift.
77staticconstexprunsignedRelBlockFreqBits = 28;
78uint32_tRelBlockFreq :RelBlockFreqBits;
79staticconstexpr int32_tScaleShift = 8;
80staticconstexpruint64_tMaxRelBlockFreq = (1 <<RelBlockFreqBits) - 1;
81
82CalleeInfo()
83 :Hotness(static_cast<uint32_t>(HotnessType::Unknown)),
84HasTailCall(false),RelBlockFreq(0) {}
85explicitCalleeInfo(HotnessTypeHotness,bool HasTC,uint64_t RelBF)
86 :Hotness(static_cast<uint32_t>(Hotness)),HasTailCall(HasTC),
87RelBlockFreq(RelBF) {}
88
89voidupdateHotness(constHotnessType OtherHotness) {
90Hotness = std::max(Hotness,static_cast<uint32_t>(OtherHotness));
91 }
92
93boolhasTailCall() const{returnHasTailCall; }
94
95voidsetHasTailCall(constbool HasTC) {HasTailCall = HasTC; }
96
97HotnessTypegetHotness() const{returnHotnessType(Hotness); }
98
99 /// Update \p RelBlockFreq from \p BlockFreq and \p EntryFreq
100 ///
101 /// BlockFreq is divided by EntryFreq and added to RelBlockFreq. To represent
102 /// fractional values, the result is represented as a fixed point number with
103 /// scale of -ScaleShift.
104voidupdateRelBlockFreq(uint64_t BlockFreq,uint64_t EntryFreq) {
105if (EntryFreq == 0)
106return;
107usingScaled64 =ScaledNumber<uint64_t>;
108 Scaled64 Temp(BlockFreq,ScaleShift);
109 Temp /= Scaled64::get(EntryFreq);
110
111uint64_t Sum =
112 SaturatingAdd<uint64_t>(Temp.toInt<uint64_t>(),RelBlockFreq);
113 Sum = std::min(Sum,uint64_t(MaxRelBlockFreq));
114RelBlockFreq =static_cast<uint32_t>(Sum);
115 }
116};
117
118inlineconstchar *getHotnessName(CalleeInfo::HotnessType HT) {
119switch (HT) {
120caseCalleeInfo::HotnessType::Unknown:
121return"unknown";
122caseCalleeInfo::HotnessType::Cold:
123return"cold";
124caseCalleeInfo::HotnessType::None:
125return"none";
126caseCalleeInfo::HotnessType::Hot:
127return"hot";
128caseCalleeInfo::HotnessType::Critical:
129return"critical";
130 }
131llvm_unreachable("invalid hotness");
132}
133
134classGlobalValueSummary;
135
136usingGlobalValueSummaryList = std::vector<std::unique_ptr<GlobalValueSummary>>;
137
138structalignas(8)GlobalValueSummaryInfo {
139unionNameOrGV {
140NameOrGV(bool HaveGVs) {
141if (HaveGVs)
142GV =nullptr;
143else
144Name ="";
145 }
146
147 /// The GlobalValue corresponding to this summary. This is only used in
148 /// per-module summaries and when the IR is available. E.g. when module
149 /// analysis is being run, or when parsing both the IR and the summary
150 /// from assembly.
151constGlobalValue *GV;
152
153 /// Summary string representation. This StringRef points to BC module
154 /// string table and is valid until module data is stored in memory.
155 /// This is guaranteed to happen until runThinLTOBackend function is
156 /// called, so it is safe to use this field during thin link. This field
157 /// is only valid if summary index was loaded from BC file.
158StringRefName;
159 }U;
160
161inlineGlobalValueSummaryInfo(bool HaveGVs);
162
163 /// List of global value summary structures for a particular value held
164 /// in the GlobalValueMap. Requires a vector in the case of multiple
165 /// COMDAT values of the same name.
166GlobalValueSummaryListSummaryList;
167};
168
169/// Map from global value GUID to corresponding summary structures. Use a
170/// std::map rather than a DenseMap so that pointers to the map's value_type
171/// (which are used by ValueInfo) are not invalidated by insertion. Also it will
172/// likely incur less overhead, as the value type is not very small and the size
173/// of the map is unknown, resulting in inefficiencies due to repeated
174/// insertions and resizing.
175usingGlobalValueSummaryMapTy =
176 std::map<GlobalValue::GUID, GlobalValueSummaryInfo>;
177
178/// Struct that holds a reference to a particular GUID in a global value
179/// summary.
180structValueInfo {
181enumFlags {HaveGV = 1,ReadOnly = 2,WriteOnly = 4 };
182PointerIntPair<const GlobalValueSummaryMapTy::value_type *, 3, int>
183RefAndFlags;
184
185ValueInfo() =default;
186ValueInfo(bool HaveGVs,const GlobalValueSummaryMapTy::value_type *R) {
187RefAndFlags.setPointer(R);
188RefAndFlags.setInt(HaveGVs);
189 }
190
191explicitoperatorbool() const{returngetRef(); }
192
193GlobalValue::GUIDgetGUID() const{returngetRef()->first; }
194constGlobalValue *getValue() const{
195assert(haveGVs());
196returngetRef()->second.U.GV;
197 }
198
199ArrayRef<std::unique_ptr<GlobalValueSummary>>getSummaryList() const{
200returngetRef()->second.SummaryList;
201 }
202
203// Even if the index is built with GVs available, we may not have one for
204// summary entries synthesized for profiled indirect call targets.
205boolhasName() const{return !haveGVs() ||getValue(); }
206
207StringRefname() const{
208assert(!haveGVs() ||getRef()->second.U.GV);
209returnhaveGVs() ?getRef()->second.U.GV->getName()
210 :getRef()->second.U.Name;
211 }
212
213boolhaveGVs() const{returnRefAndFlags.getInt() &HaveGV; }
214boolisReadOnly() const{
215assert(isValidAccessSpecifier());
216returnRefAndFlags.getInt() &ReadOnly;
217 }
218boolisWriteOnly() const{
219assert(isValidAccessSpecifier());
220returnRefAndFlags.getInt() &WriteOnly;
221 }
222unsignedgetAccessSpecifier() const{
223assert(isValidAccessSpecifier());
224returnRefAndFlags.getInt() & (ReadOnly |WriteOnly);
225 }
226boolisValidAccessSpecifier() const{
227unsigned BadAccessMask =ReadOnly |WriteOnly;
228return (RefAndFlags.getInt() & BadAccessMask) != BadAccessMask;
229 }
230voidsetReadOnly() {
231// We expect ro/wo attribute to set only once during
232// ValueInfo lifetime.
233assert(getAccessSpecifier() == 0);
234RefAndFlags.setInt(RefAndFlags.getInt() |ReadOnly);
235 }
236voidsetWriteOnly() {
237assert(getAccessSpecifier() == 0);
238RefAndFlags.setInt(RefAndFlags.getInt() |WriteOnly);
239 }
240
241const GlobalValueSummaryMapTy::value_type *getRef() const{
242returnRefAndFlags.getPointer();
243 }
244
245 /// Returns the most constraining visibility among summaries. The
246 /// visibilities, ordered from least to most constraining, are: default,
247 /// protected and hidden.
248GlobalValue::VisibilityTypesgetELFVisibility()const;
249
250 /// Checks if all summaries are DSO local (have the flag set). When DSOLocal
251 /// propagation has been done, set the parameter to enable fast check.
252boolisDSOLocal(bool WithDSOLocalPropagation =false)const;
253
254 /// Checks if all copies are eligible for auto-hiding (have flag set).
255boolcanAutoHide()const;
256};
257
258inlineraw_ostream &operator<<(raw_ostream &OS,constValueInfo &VI) {
259OS << VI.getGUID();
260if (!VI.name().empty())
261OS <<" (" << VI.name() <<")";
262returnOS;
263}
264
265inlinebooloperator==(constValueInfo &A,constValueInfo &B) {
266assert(A.getRef() &&B.getRef() &&
267"Need ValueInfo with non-null Ref for comparison");
268returnA.getRef() ==B.getRef();
269}
270
271inlinebooloperator!=(constValueInfo &A,constValueInfo &B) {
272assert(A.getRef() &&B.getRef() &&
273"Need ValueInfo with non-null Ref for comparison");
274returnA.getRef() !=B.getRef();
275}
276
277inlinebooloperator<(constValueInfo &A,constValueInfo &B) {
278assert(A.getRef() &&B.getRef() &&
279"Need ValueInfo with non-null Ref to compare GUIDs");
280returnA.getGUID() <B.getGUID();
281}
282
283template <>structDenseMapInfo<ValueInfo> {
284staticinlineValueInfogetEmptyKey() {
285returnValueInfo(false, (GlobalValueSummaryMapTy::value_type *)-8);
286 }
287
288staticinlineValueInfogetTombstoneKey() {
289returnValueInfo(false, (GlobalValueSummaryMapTy::value_type *)-16);
290 }
291
292staticinlineboolisSpecialKey(ValueInfo V) {
293return V == getTombstoneKey() || V == getEmptyKey();
294 }
295
296staticboolisEqual(ValueInfo L,ValueInfo R) {
297// We are not supposed to mix ValueInfo(s) with different HaveGVs flag
298// in a same container.
299assert(isSpecialKey(L) || isSpecialKey(R) || (L.haveGVs() == R.haveGVs()));
300return L.getRef() == R.getRef();
301 }
302staticunsignedgetHashValue(ValueInfoI) {return (uintptr_t)I.getRef(); }
303};
304
305// For optional hinted size reporting, holds a pair of the full stack id
306// (pre-trimming, from the full context in the profile), and the associated
307// total profiled size.
308structContextTotalSize {
309uint64_tFullStackId;
310uint64_tTotalSize;
311};
312
313/// Summary of memprof callsite metadata.
314structCallsiteInfo {
315// Actual callee function.
316ValueInfoCallee;
317
318// Used to record whole program analysis cloning decisions.
319// The ThinLTO backend will need to create as many clones as there are entries
320// in the vector (it is expected and should be confirmed that all such
321// summaries in the same FunctionSummary have the same number of entries).
322// Each index records version info for the corresponding clone of this
323// function. The value is the callee clone it calls (becomes the appended
324// suffix id). Index 0 is the original version, and a value of 0 calls the
325// original callee.
326SmallVector<unsigned>Clones{0};
327
328// Represents stack ids in this context, recorded as indices into the
329// StackIds vector in the summary index, which in turn holds the full 64-bit
330// stack ids. This reduces memory as there are in practice far fewer unique
331// stack ids than stack id references.
332SmallVector<unsigned>StackIdIndices;
333
334CallsiteInfo(ValueInfoCallee,SmallVector<unsigned>StackIdIndices)
335 :Callee(Callee),StackIdIndices(std::move(StackIdIndices)) {}
336CallsiteInfo(ValueInfoCallee,SmallVector<unsigned>Clones,
337SmallVector<unsigned>StackIdIndices)
338 :Callee(Callee),Clones(std::move(Clones)),
339StackIdIndices(std::move(StackIdIndices)) {}
340};
341
342inlineraw_ostream &operator<<(raw_ostream &OS,constCallsiteInfo &SNI) {
343OS <<"Callee: " << SNI.Callee;
344boolFirst =true;
345OS <<" Clones: ";
346for (auto V : SNI.Clones) {
347if (!First)
348OS <<", ";
349First =false;
350OS << V;
351 }
352First =true;
353OS <<" StackIds: ";
354for (auto Id : SNI.StackIdIndices) {
355if (!First)
356OS <<", ";
357First =false;
358OS << Id;
359 }
360returnOS;
361}
362
363// Allocation type assigned to an allocation reached by a given context.
364// More can be added, now this is cold, notcold and hot.
365// Values should be powers of two so that they can be ORed, in particular to
366// track allocations that have different behavior with different calling
367// contexts.
368enum classAllocationType :uint8_t {
369None = 0,
370NotCold = 1,
371Cold = 2,
372Hot = 4,
373All = 7// This should always be set to the OR of all values.
374};
375
376/// Summary of a single MIB in a memprof metadata on allocations.
377structMIBInfo {
378// The allocation type for this profiled context.
379AllocationTypeAllocType;
380
381// Represents stack ids in this context, recorded as indices into the
382// StackIds vector in the summary index, which in turn holds the full 64-bit
383// stack ids. This reduces memory as there are in practice far fewer unique
384// stack ids than stack id references.
385SmallVector<unsigned>StackIdIndices;
386
387MIBInfo(AllocationTypeAllocType,SmallVector<unsigned>StackIdIndices)
388 :AllocType(AllocType),StackIdIndices(std::move(StackIdIndices)) {}
389};
390
391inlineraw_ostream &operator<<(raw_ostream &OS,constMIBInfo &MIB) {
392OS <<"AllocType " << (unsigned)MIB.AllocType;
393boolFirst =true;
394OS <<" StackIds: ";
395for (auto Id : MIB.StackIdIndices) {
396if (!First)
397OS <<", ";
398First =false;
399OS << Id;
400 }
401returnOS;
402}
403
404/// Summary of memprof metadata on allocations.
405structAllocInfo {
406// Used to record whole program analysis cloning decisions.
407// The ThinLTO backend will need to create as many clones as there are entries
408// in the vector (it is expected and should be confirmed that all such
409// summaries in the same FunctionSummary have the same number of entries).
410// Each index records version info for the corresponding clone of this
411// function. The value is the allocation type of the corresponding allocation.
412// Index 0 is the original version. Before cloning, index 0 may have more than
413// one allocation type.
414SmallVector<uint8_t>Versions;
415
416// Vector of MIBs in this memprof metadata.
417 std::vector<MIBInfo>MIBs;
418
419// If requested, keep track of full stack contexts and total profiled sizes
420// for each MIB. This will be a vector of the same length and order as the
421// MIBs vector, if non-empty. Note that each MIB in the summary can have
422// multiple of these as we trim the contexts when possible during matching.
423// For hinted size reporting we, however, want the original pre-trimmed full
424// stack context id for better correlation with the profile.
425 std::vector<std::vector<ContextTotalSize>>ContextSizeInfos;
426
427AllocInfo(std::vector<MIBInfo>MIBs) :MIBs(std::move(MIBs)) {
428Versions.push_back(0);
429 }
430AllocInfo(SmallVector<uint8_t>Versions, std::vector<MIBInfo>MIBs)
431 :Versions(std::move(Versions)),MIBs(std::move(MIBs)) {}
432};
433
434inlineraw_ostream &operator<<(raw_ostream &OS,constAllocInfo &AE) {
435boolFirst =true;
436OS <<"Versions: ";
437for (auto V : AE.Versions) {
438if (!First)
439OS <<", ";
440First =false;
441OS << (unsigned)V;
442 }
443OS <<" MIB:\n";
444for (auto &M : AE.MIBs) {
445OS <<"\t\t" << M <<"\n";
446 }
447if (!AE.ContextSizeInfos.empty()) {
448OS <<"\tContextSizeInfo per MIB:\n";
449for (auto Infos : AE.ContextSizeInfos) {
450OS <<"\t\t";
451bool FirstInfo =true;
452for (auto [FullStackId, TotalSize] : Infos) {
453if (!FirstInfo)
454OS <<", ";
455 FirstInfo =false;
456OS <<"{ " << FullStackId <<", " << TotalSize <<" }";
457 }
458OS <<"\n";
459 }
460 }
461returnOS;
462}
463
464/// Function and variable summary information to aid decisions and
465/// implementation of importing.
466classGlobalValueSummary {
467public:
468 /// Sububclass discriminator (for dyn_cast<> et al.)
469enumSummaryKind :unsigned {AliasKind,FunctionKind,GlobalVarKind };
470
471enumImportKind :unsigned {
472// The global value definition corresponding to the summary should be
473// imported from source module
474Definition = 0,
475
476// When its definition doesn't exist in the destination module and not
477// imported (e.g., function is too large to be inlined), the global value
478// declaration corresponding to the summary should be imported, or the
479// attributes from summary should be annotated on the function declaration.
480Declaration = 1,
481 };
482
483 /// Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
484structGVFlags {
485 /// The linkage type of the associated global value.
486 ///
487 /// One use is to flag values that have local linkage types and need to
488 /// have module identifier appended before placing into the combined
489 /// index, to disambiguate from other values with the same name.
490 /// In the future this will be used to update and optimize linkage
491 /// types based on global summary-based analysis.
492unsignedLinkage : 4;
493
494 /// Indicates the visibility.
495unsignedVisibility : 2;
496
497 /// Indicate if the global value cannot be imported (e.g. it cannot
498 /// be renamed or references something that can't be renamed).
499unsignedNotEligibleToImport : 1;
500
501 /// In per-module summary, indicate that the global value must be considered
502 /// a live root for index-based liveness analysis. Used for special LLVM
503 /// values such as llvm.global_ctors that the linker does not know about.
504 ///
505 /// In combined summary, indicate that the global value is live.
506unsignedLive : 1;
507
508 /// Indicates that the linker resolved the symbol to a definition from
509 /// within the same linkage unit.
510unsignedDSOLocal : 1;
511
512 /// In the per-module summary, indicates that the global value is
513 /// linkonce_odr and global unnamed addr (so eligible for auto-hiding
514 /// via hidden visibility). In the combined summary, indicates that the
515 /// prevailing linkonce_odr copy can be auto-hidden via hidden visibility
516 /// when it is upgraded to weak_odr in the backend. This is legal when
517 /// all copies are eligible for auto-hiding (i.e. all copies were
518 /// linkonce_odr global unnamed addr. If any copy is not (e.g. it was
519 /// originally weak_odr, we cannot auto-hide the prevailing copy as it
520 /// means the symbol was externally visible.
521unsignedCanAutoHide : 1;
522
523 /// This field is written by the ThinLTO indexing step to postlink combined
524 /// summary. The value is interpreted as 'ImportKind' enum defined above.
525unsignedImportType : 1;
526
527 /// Convenience Constructors
528explicitGVFlags(GlobalValue::LinkageTypesLinkage,
529GlobalValue::VisibilityTypesVisibility,
530boolNotEligibleToImport,boolLive,bool IsLocal,
531boolCanAutoHide,ImportKindImportType)
532 :Linkage(Linkage),Visibility(Visibility),
533NotEligibleToImport(NotEligibleToImport),Live(Live),
534DSOLocal(IsLocal),CanAutoHide(CanAutoHide),
535ImportType(static_cast<unsigned>(ImportType)) {}
536 };
537
538private:
539 /// Kind of summary for use in dyn_cast<> et al.
540SummaryKind Kind;
541
542 GVFlags Flags;
543
544 /// This is the hash of the name of the symbol in the original file. It is
545 /// identical to the GUID for global symbols, but differs for local since the
546 /// GUID includes the module level id in the hash.
547GlobalValue::GUID OriginalName = 0;
548
549 /// Path of module IR containing value's definition, used to locate
550 /// module during importing.
551 ///
552 /// This is only used during parsing of the combined index, or when
553 /// parsing the per-module index for creation of the combined summary index,
554 /// not during writing of the per-module index which doesn't contain a
555 /// module path string table.
556StringRef ModulePath;
557
558 /// List of values referenced by this global value's definition
559 /// (either by the initializer of a global variable, or referenced
560 /// from within a function). This does not include functions called, which
561 /// are listed in the derived FunctionSummary object.
562 /// We use SmallVector<ValueInfo, 0> instead of std::vector<ValueInfo> for its
563 /// smaller memory footprint.
564SmallVector<ValueInfo, 0> RefEdgeList;
565
566protected:
567GlobalValueSummary(SummaryKind K,GVFlags Flags,
568SmallVectorImpl<ValueInfo> &&Refs)
569 : Kind(K), Flags(Flags), RefEdgeList(std::move(Refs)) {
570assert((K !=AliasKind || Refs.empty()) &&
571"Expect no references for AliasSummary");
572 }
573
574public:
575virtual~GlobalValueSummary() =default;
576
577 /// Returns the hash of the original name, it is identical to the GUID for
578 /// externally visible symbols, but not for local ones.
579GlobalValue::GUIDgetOriginalName() const{return OriginalName; }
580
581 /// Initialize the original name hash in this summary.
582voidsetOriginalName(GlobalValue::GUIDName) { OriginalName =Name; }
583
584 /// Which kind of summary subclass this is.
585SummaryKindgetSummaryKind() const{return Kind; }
586
587 /// Set the path to the module containing this function, for use in
588 /// the combined index.
589voidsetModulePath(StringRef ModPath) { ModulePath = ModPath; }
590
591 /// Get the path to the module containing this function.
592StringRefmodulePath() const{return ModulePath; }
593
594 /// Get the flags for this GlobalValue (see \p struct GVFlags).
595GVFlagsflags() const{return Flags; }
596
597 /// Return linkage type recorded for this global value.
598GlobalValue::LinkageTypeslinkage() const{
599returnstatic_cast<GlobalValue::LinkageTypes>(Flags.Linkage);
600 }
601
602 /// Sets the linkage to the value determined by global summary-based
603 /// optimization. Will be applied in the ThinLTO backends.
604voidsetLinkage(GlobalValue::LinkageTypesLinkage) {
605 Flags.Linkage =Linkage;
606 }
607
608 /// Return true if this global value can't be imported.
609boolnotEligibleToImport() const{return Flags.NotEligibleToImport; }
610
611boolisLive() const{return Flags.Live; }
612
613voidsetLive(boolLive) { Flags.Live =Live; }
614
615voidsetDSOLocal(boolLocal) { Flags.DSOLocal =Local; }
616
617boolisDSOLocal() const{return Flags.DSOLocal; }
618
619voidsetCanAutoHide(bool CanAutoHide) { Flags.CanAutoHide = CanAutoHide; }
620
621boolcanAutoHide() const{return Flags.CanAutoHide; }
622
623boolshouldImportAsDecl() const{
624return Flags.ImportType ==GlobalValueSummary::ImportKind::Declaration;
625 }
626
627voidsetImportKind(ImportKind IK) { Flags.ImportType = IK; }
628
629GlobalValueSummary::ImportKindimportType() const{
630returnstatic_cast<ImportKind>(Flags.ImportType);
631 }
632
633GlobalValue::VisibilityTypesgetVisibility() const{
634return (GlobalValue::VisibilityTypes)Flags.Visibility;
635 }
636voidsetVisibility(GlobalValue::VisibilityTypes Vis) {
637 Flags.Visibility = (unsigned)Vis;
638 }
639
640 /// Flag that this global value cannot be imported.
641voidsetNotEligibleToImport() { Flags.NotEligibleToImport =true; }
642
643 /// Return the list of values referenced by this global value definition.
644ArrayRef<ValueInfo>refs() const{return RefEdgeList; }
645
646 /// If this is an alias summary, returns the summary of the aliased object (a
647 /// global variable or function), otherwise returns itself.
648GlobalValueSummary *getBaseObject();
649constGlobalValueSummary *getBaseObject()const;
650
651friendclassModuleSummaryIndex;
652};
653
654GlobalValueSummaryInfo::GlobalValueSummaryInfo(bool HaveGVs) : U(HaveGVs) {}
655
656/// Alias summary information.
657classAliasSummary :publicGlobalValueSummary {
658ValueInfo AliaseeValueInfo;
659
660 /// This is the Aliasee in the same module as alias (could get from VI, trades
661 /// memory for time). Note that this pointer may be null (and the value info
662 /// empty) when we have a distributed index where the alias is being imported
663 /// (as a copy of the aliasee), but the aliasee is not.
664GlobalValueSummary *AliaseeSummary =nullptr;
665
666public:
667AliasSummary(GVFlags Flags)
668 :GlobalValueSummary(AliasKind, Flags,SmallVector<ValueInfo, 0>{}) {}
669
670 /// Check if this is an alias summary.
671staticboolclassof(constGlobalValueSummary *GVS) {
672return GVS->getSummaryKind() ==AliasKind;
673 }
674
675voidsetAliasee(ValueInfo &AliaseeVI,GlobalValueSummary *Aliasee) {
676 AliaseeValueInfo = AliaseeVI;
677 AliaseeSummary = Aliasee;
678 }
679
680boolhasAliasee() const{
681assert(!!AliaseeSummary == (AliaseeValueInfo &&
682 !AliaseeValueInfo.getSummaryList().empty()) &&
683"Expect to have both aliasee summary and summary list or neither");
684return !!AliaseeSummary;
685 }
686
687constGlobalValueSummary &getAliasee() const{
688assert(AliaseeSummary &&"Unexpected missing aliasee summary");
689return *AliaseeSummary;
690 }
691
692GlobalValueSummary &getAliasee() {
693returnconst_cast<GlobalValueSummary &>(
694static_cast<constAliasSummary *>(this)->getAliasee());
695 }
696ValueInfogetAliaseeVI() const{
697assert(AliaseeValueInfo &&"Unexpected missing aliasee");
698return AliaseeValueInfo;
699 }
700GlobalValue::GUIDgetAliaseeGUID() const{
701assert(AliaseeValueInfo &&"Unexpected missing aliasee");
702return AliaseeValueInfo.getGUID();
703 }
704};
705
706constinlineGlobalValueSummary *GlobalValueSummary::getBaseObject() const{
707if (auto *AS = dyn_cast<AliasSummary>(this))
708return &AS->getAliasee();
709returnthis;
710}
711
712inlineGlobalValueSummary *GlobalValueSummary::getBaseObject() {
713if (auto *AS = dyn_cast<AliasSummary>(this))
714return &AS->getAliasee();
715returnthis;
716}
717
718/// Function summary information to aid decisions and implementation of
719/// importing.
720classFunctionSummary :publicGlobalValueSummary {
721public:
722 /// <CalleeValueInfo, CalleeInfo> call edge pair.
723usingEdgeTy = std::pair<ValueInfo, CalleeInfo>;
724
725 /// Types for -force-summary-edges-cold debugging option.
726enumForceSummaryHotnessType :unsigned {
727FSHT_None,
728FSHT_AllNonCritical,
729FSHT_All
730 };
731
732 /// An "identifier" for a virtual function. This contains the type identifier
733 /// represented as a GUID and the offset from the address point to the virtual
734 /// function pointer, where "address point" is as defined in the Itanium ABI:
735 /// https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vtable-general
736structVFuncId {
737GlobalValue::GUIDGUID;
738uint64_tOffset;
739 };
740
741 /// A specification for a virtual function call with all constant integer
742 /// arguments. This is used to perform virtual constant propagation on the
743 /// summary.
744structConstVCall {
745VFuncIdVFunc;
746 std::vector<uint64_t>Args;
747 };
748
749 /// All type identifier related information. Because these fields are
750 /// relatively uncommon we only allocate space for them if necessary.
751structTypeIdInfo {
752 /// List of type identifiers used by this function in llvm.type.test
753 /// intrinsics referenced by something other than an llvm.assume intrinsic,
754 /// represented as GUIDs.
755 std::vector<GlobalValue::GUID>TypeTests;
756
757 /// List of virtual calls made by this function using (respectively)
758 /// llvm.assume(llvm.type.test) or llvm.type.checked.load intrinsics that do
759 /// not have all constant integer arguments.
760 std::vector<VFuncId>TypeTestAssumeVCalls,TypeCheckedLoadVCalls;
761
762 /// List of virtual calls made by this function using (respectively)
763 /// llvm.assume(llvm.type.test) or llvm.type.checked.load intrinsics with
764 /// all constant integer arguments.
765 std::vector<ConstVCall>TypeTestAssumeConstVCalls,
766TypeCheckedLoadConstVCalls;
767 };
768
769 /// Flags specific to function summaries.
770structFFlags {
771// Function attribute flags. Used to track if a function accesses memory,
772// recurses or aliases.
773unsignedReadNone : 1;
774unsignedReadOnly : 1;
775unsignedNoRecurse : 1;
776unsignedReturnDoesNotAlias : 1;
777
778// Indicate if the global value cannot be inlined.
779unsignedNoInline : 1;
780// Indicate if function should be always inlined.
781unsignedAlwaysInline : 1;
782// Indicate if function never raises an exception. Can be modified during
783// thinlink function attribute propagation
784unsignedNoUnwind : 1;
785// Indicate if function contains instructions that mayThrow
786unsignedMayThrow : 1;
787
788// If there are calls to unknown targets (e.g. indirect)
789unsignedHasUnknownCall : 1;
790
791// Indicate if a function must be an unreachable function.
792//
793// This bit is sufficient but not necessary;
794// if this bit is on, the function must be regarded as unreachable;
795// if this bit is off, the function might be reachable or unreachable.
796unsignedMustBeUnreachable : 1;
797
798FFlags &operator&=(constFFlags &RHS) {
799 this->ReadNone &= RHS.ReadNone;
800 this->ReadOnly &= RHS.ReadOnly;
801 this->NoRecurse &= RHS.NoRecurse;
802 this->ReturnDoesNotAlias &= RHS.ReturnDoesNotAlias;
803 this->NoInline &= RHS.NoInline;
804 this->AlwaysInline &= RHS.AlwaysInline;
805 this->NoUnwind &= RHS.NoUnwind;
806 this->MayThrow &= RHS.MayThrow;
807 this->HasUnknownCall &= RHS.HasUnknownCall;
808 this->MustBeUnreachable &= RHS.MustBeUnreachable;
809return *this;
810 }
811
812boolanyFlagSet() {
813return this->ReadNone | this->ReadOnly | this->NoRecurse |
814 this->ReturnDoesNotAlias | this->NoInline | this->AlwaysInline |
815 this->NoUnwind | this->MayThrow | this->HasUnknownCall |
816 this->MustBeUnreachable;
817 }
818
819operator std::string() {
820 std::string Output;
821raw_string_ostreamOS(Output);
822OS <<"funcFlags: (";
823OS <<"readNone: " << this->ReadNone;
824 OS <<", readOnly: " << this->ReadOnly;
825 OS <<", noRecurse: " << this->NoRecurse;
826 OS <<", returnDoesNotAlias: " << this->ReturnDoesNotAlias;
827 OS <<", noInline: " << this->NoInline;
828 OS <<", alwaysInline: " << this->AlwaysInline;
829 OS <<", noUnwind: " << this->NoUnwind;
830 OS <<", mayThrow: " << this->MayThrow;
831 OS <<", hasUnknownCall: " << this->HasUnknownCall;
832 OS <<", mustBeUnreachable: " << this->MustBeUnreachable;
833 OS <<")";
834return Output;
835 }
836 };
837
838 /// Describes the uses of a parameter by the function.
839structParamAccess {
840staticconstexpruint32_tRangeWidth = 64;
841
842 /// Describes the use of a value in a call instruction, specifying the
843 /// call's target, the value's parameter number, and the possible range of
844 /// offsets from the beginning of the value that are passed.
845structCall {
846uint64_tParamNo = 0;
847ValueInfoCallee;
848ConstantRangeOffsets{/*BitWidth=*/RangeWidth,/*isFullSet=*/true};
849
850Call() =default;
851Call(uint64_tParamNo,ValueInfoCallee,constConstantRange &Offsets)
852 :ParamNo(ParamNo),Callee(Callee),Offsets(Offsets) {}
853 };
854
855uint64_tParamNo = 0;
856 /// The range contains byte offsets from the parameter pointer which
857 /// accessed by the function. In the per-module summary, it only includes
858 /// accesses made by the function instructions. In the combined summary, it
859 /// also includes accesses by nested function calls.
860ConstantRangeUse{/*BitWidth=*/RangeWidth,/*isFullSet=*/true};
861 /// In the per-module summary, it summarizes the byte offset applied to each
862 /// pointer parameter before passing to each corresponding callee.
863 /// In the combined summary, it's empty and information is propagated by
864 /// inter-procedural analysis and applied to the Use field.
865 std::vector<Call>Calls;
866
867ParamAccess() =default;
868ParamAccess(uint64_tParamNo,constConstantRange &Use)
869 :ParamNo(ParamNo),Use(Use) {}
870 };
871
872 /// Create an empty FunctionSummary (with specified call edges).
873 /// Used to represent external nodes and the dummy root node.
874staticFunctionSummary
875makeDummyFunctionSummary(SmallVectorImpl<FunctionSummary::EdgeTy> &&Edges) {
876returnFunctionSummary(
877FunctionSummary::GVFlags(
878GlobalValue::LinkageTypes::AvailableExternallyLinkage,
879GlobalValue::DefaultVisibility,
880/*NotEligibleToImport=*/true,/*Live=*/true,/*IsLocal=*/false,
881/*CanAutoHide=*/false,GlobalValueSummary::ImportKind::Definition),
882/*NumInsts=*/0,FunctionSummary::FFlags{},SmallVector<ValueInfo, 0>(),
883 std::move(Edges), std::vector<GlobalValue::GUID>(),
884 std::vector<FunctionSummary::VFuncId>(),
885 std::vector<FunctionSummary::VFuncId>(),
886 std::vector<FunctionSummary::ConstVCall>(),
887 std::vector<FunctionSummary::ConstVCall>(),
888 std::vector<FunctionSummary::ParamAccess>(),
889 std::vector<CallsiteInfo>(), std::vector<AllocInfo>());
890 }
891
892 /// A dummy node to reference external functions that aren't in the index
893staticFunctionSummaryExternalNode;
894
895private:
896 /// Number of instructions (ignoring debug instructions, e.g.) computed
897 /// during the initial compile step when the summary index is first built.
898unsigned InstCount;
899
900 /// Function summary specific flags.
901FFlags FunFlags;
902
903 /// List of <CalleeValueInfo, CalleeInfo> call edge pairs from this function.
904 /// We use SmallVector<ValueInfo, 0> instead of std::vector<ValueInfo> for its
905 /// smaller memory footprint.
906SmallVector<EdgeTy, 0> CallGraphEdgeList;
907
908 std::unique_ptr<TypeIdInfo> TIdInfo;
909
910 /// Uses for every parameter to this function.
911usingParamAccessesTy = std::vector<ParamAccess>;
912 std::unique_ptr<ParamAccessesTy> ParamAccesses;
913
914 /// Optional list of memprof callsite metadata summaries. The correspondence
915 /// between the callsite summary and the callsites in the function is implied
916 /// by the order in the vector (and can be validated by comparing the stack
917 /// ids in the CallsiteInfo to those in the instruction callsite metadata).
918 /// As a memory savings optimization, we only create these for the prevailing
919 /// copy of a symbol when creating the combined index during LTO.
920usingCallsitesTy = std::vector<CallsiteInfo>;
921 std::unique_ptr<CallsitesTy> Callsites;
922
923 /// Optional list of allocation memprof metadata summaries. The correspondence
924 /// between the alloc memprof summary and the allocation callsites in the
925 /// function is implied by the order in the vector (and can be validated by
926 /// comparing the stack ids in the AllocInfo to those in the instruction
927 /// memprof metadata).
928 /// As a memory savings optimization, we only create these for the prevailing
929 /// copy of a symbol when creating the combined index during LTO.
930usingAllocsTy = std::vector<AllocInfo>;
931 std::unique_ptr<AllocsTy> Allocs;
932
933public:
934FunctionSummary(GVFlags Flags,unsigned NumInsts,FFlags FunFlags,
935SmallVectorImpl<ValueInfo> &&Refs,
936SmallVectorImpl<EdgeTy> &&CGEdges,
937 std::vector<GlobalValue::GUID> TypeTests,
938 std::vector<VFuncId> TypeTestAssumeVCalls,
939 std::vector<VFuncId> TypeCheckedLoadVCalls,
940 std::vector<ConstVCall> TypeTestAssumeConstVCalls,
941 std::vector<ConstVCall> TypeCheckedLoadConstVCalls,
942 std::vector<ParamAccess> Params, CallsitesTy CallsiteList,
943 AllocsTy AllocList)
944 :GlobalValueSummary(FunctionKind, Flags,std::move(Refs)),
945 InstCount(NumInsts), FunFlags(FunFlags),
946 CallGraphEdgeList(std::move(CGEdges)) {
947if (!TypeTests.empty() || !TypeTestAssumeVCalls.empty() ||
948 !TypeCheckedLoadVCalls.empty() || !TypeTestAssumeConstVCalls.empty() ||
949 !TypeCheckedLoadConstVCalls.empty())
950 TIdInfo = std::make_unique<TypeIdInfo>(
951TypeIdInfo{std::move(TypeTests), std::move(TypeTestAssumeVCalls),
952 std::move(TypeCheckedLoadVCalls),
953 std::move(TypeTestAssumeConstVCalls),
954 std::move(TypeCheckedLoadConstVCalls)});
955if (!Params.empty())
956 ParamAccesses = std::make_unique<ParamAccessesTy>(std::move(Params));
957if (!CallsiteList.empty())
958 Callsites = std::make_unique<CallsitesTy>(std::move(CallsiteList));
959if (!AllocList.empty())
960 Allocs = std::make_unique<AllocsTy>(std::move(AllocList));
961 }
962// Gets the number of readonly and writeonly refs in RefEdgeList
963 std::pair<unsigned, unsigned>specialRefCounts()const;
964
965 /// Check if this is a function summary.
966staticboolclassof(constGlobalValueSummary *GVS) {
967return GVS->getSummaryKind() ==FunctionKind;
968 }
969
970 /// Get function summary flags.
971FFlagsfflags() const{return FunFlags; }
972
973voidsetNoRecurse() { FunFlags.NoRecurse =true; }
974
975voidsetNoUnwind() { FunFlags.NoUnwind =true; }
976
977 /// Get the instruction count recorded for this function.
978unsignedinstCount() const{return InstCount; }
979
980 /// Return the list of <CalleeValueInfo, CalleeInfo> pairs.
981ArrayRef<EdgeTy>calls() const{return CallGraphEdgeList; }
982
983SmallVector<EdgeTy, 0> &mutableCalls() {return CallGraphEdgeList; }
984
985voidaddCall(EdgeTyE) { CallGraphEdgeList.push_back(E); }
986
987 /// Returns the list of type identifiers used by this function in
988 /// llvm.type.test intrinsics other than by an llvm.assume intrinsic,
989 /// represented as GUIDs.
990ArrayRef<GlobalValue::GUID>type_tests() const{
991if (TIdInfo)
992return TIdInfo->TypeTests;
993return {};
994 }
995
996 /// Returns the list of virtual calls made by this function using
997 /// llvm.assume(llvm.type.test) intrinsics that do not have all constant
998 /// integer arguments.
999ArrayRef<VFuncId>type_test_assume_vcalls() const{
1000if (TIdInfo)
1001return TIdInfo->TypeTestAssumeVCalls;
1002return {};
1003 }
1004
1005 /// Returns the list of virtual calls made by this function using
1006 /// llvm.type.checked.load intrinsics that do not have all constant integer
1007 /// arguments.
1008ArrayRef<VFuncId>type_checked_load_vcalls() const{
1009if (TIdInfo)
1010return TIdInfo->TypeCheckedLoadVCalls;
1011return {};
1012 }
1013
1014 /// Returns the list of virtual calls made by this function using
1015 /// llvm.assume(llvm.type.test) intrinsics with all constant integer
1016 /// arguments.
1017ArrayRef<ConstVCall>type_test_assume_const_vcalls() const{
1018if (TIdInfo)
1019return TIdInfo->TypeTestAssumeConstVCalls;
1020return {};
1021 }
1022
1023 /// Returns the list of virtual calls made by this function using
1024 /// llvm.type.checked.load intrinsics with all constant integer arguments.
1025ArrayRef<ConstVCall>type_checked_load_const_vcalls() const{
1026if (TIdInfo)
1027return TIdInfo->TypeCheckedLoadConstVCalls;
1028return {};
1029 }
1030
1031 /// Returns the list of known uses of pointer parameters.
1032ArrayRef<ParamAccess>paramAccesses() const{
1033if (ParamAccesses)
1034return *ParamAccesses;
1035return {};
1036 }
1037
1038 /// Sets the list of known uses of pointer parameters.
1039voidsetParamAccesses(std::vector<ParamAccess> NewParams) {
1040if (NewParams.empty())
1041 ParamAccesses.reset();
1042elseif (ParamAccesses)
1043 *ParamAccesses = std::move(NewParams);
1044else
1045 ParamAccesses = std::make_unique<ParamAccessesTy>(std::move(NewParams));
1046 }
1047
1048 /// Add a type test to the summary. This is used by WholeProgramDevirt if we
1049 /// were unable to devirtualize a checked call.
1050voidaddTypeTest(GlobalValue::GUIDGuid) {
1051if (!TIdInfo)
1052 TIdInfo = std::make_unique<TypeIdInfo>();
1053 TIdInfo->TypeTests.push_back(Guid);
1054 }
1055
1056constTypeIdInfo *getTypeIdInfo() const{return TIdInfo.get(); };
1057
1058ArrayRef<CallsiteInfo>callsites() const{
1059if (Callsites)
1060return *Callsites;
1061return {};
1062 }
1063
1064 CallsitesTy &mutableCallsites() {
1065assert(Callsites);
1066return *Callsites;
1067 }
1068
1069voidaddCallsite(CallsiteInfo &Callsite) {
1070if (!Callsites)
1071 Callsites = std::make_unique<CallsitesTy>();
1072 Callsites->push_back(Callsite);
1073 }
1074
1075ArrayRef<AllocInfo>allocs() const{
1076if (Allocs)
1077return *Allocs;
1078return {};
1079 }
1080
1081 AllocsTy &mutableAllocs() {
1082assert(Allocs);
1083return *Allocs;
1084 }
1085
1086friendstructGraphTraits<ValueInfo>;
1087};
1088
1089template <>structDenseMapInfo<FunctionSummary::VFuncId> {
1090staticFunctionSummary::VFuncIdgetEmptyKey() {return {0,uint64_t(-1)}; }
1091
1092staticFunctionSummary::VFuncIdgetTombstoneKey() {
1093return {0,uint64_t(-2)};
1094 }
1095
1096staticboolisEqual(FunctionSummary::VFuncId L,FunctionSummary::VFuncId R) {
1097return L.GUID == R.GUID && L.Offset == R.Offset;
1098 }
1099
1100staticunsignedgetHashValue(FunctionSummary::VFuncIdI) {returnI.GUID; }
1101};
1102
1103template <>structDenseMapInfo<FunctionSummary::ConstVCall> {
1104staticFunctionSummary::ConstVCallgetEmptyKey() {
1105return {{0,uint64_t(-1)}, {}};
1106 }
1107
1108staticFunctionSummary::ConstVCallgetTombstoneKey() {
1109return {{0,uint64_t(-2)}, {}};
1110 }
1111
1112staticboolisEqual(FunctionSummary::ConstVCall L,
1113FunctionSummary::ConstVCall R) {
1114returnDenseMapInfo<FunctionSummary::VFuncId>::isEqual(L.VFunc, R.VFunc) &&
1115 L.Args == R.Args;
1116 }
1117
1118staticunsignedgetHashValue(FunctionSummary::ConstVCallI) {
1119returnI.VFunc.GUID;
1120 }
1121};
1122
1123/// The ValueInfo and offset for a function within a vtable definition
1124/// initializer array.
1125structVirtFuncOffset {
1126VirtFuncOffset(ValueInfo VI,uint64_tOffset)
1127 :FuncVI(VI),VTableOffset(Offset) {}
1128
1129ValueInfoFuncVI;
1130uint64_tVTableOffset;
1131};
1132/// List of functions referenced by a particular vtable definition.
1133usingVTableFuncList = std::vector<VirtFuncOffset>;
1134
1135/// Global variable summary information to aid decisions and
1136/// implementation of importing.
1137///
1138/// Global variable summary has two extra flag, telling if it is
1139/// readonly or writeonly. Both readonly and writeonly variables
1140/// can be optimized in the backed: readonly variables can be
1141/// const-folded, while writeonly vars can be completely eliminated
1142/// together with corresponding stores. We let both things happen
1143/// by means of internalizing such variables after ThinLTO import.
1144classGlobalVarSummary :publicGlobalValueSummary {
1145private:
1146 /// For vtable definitions this holds the list of functions and
1147 /// their corresponding offsets within the initializer array.
1148 std::unique_ptr<VTableFuncList> VTableFuncs;
1149
1150public:
1151structGVarFlags {
1152GVarFlags(bool ReadOnly,bool WriteOnly,boolConstant,
1153GlobalObject::VCallVisibility Vis)
1154 :MaybeReadOnly(ReadOnly),MaybeWriteOnly(WriteOnly),
1155Constant(Constant),VCallVisibility(Vis) {}
1156
1157// If true indicates that this global variable might be accessed
1158// purely by non-volatile load instructions. This in turn means
1159// it can be internalized in source and destination modules during
1160// thin LTO import because it neither modified nor its address
1161// is taken.
1162unsignedMaybeReadOnly : 1;
1163// If true indicates that variable is possibly only written to, so
1164// its value isn't loaded and its address isn't taken anywhere.
1165// False, when 'Constant' attribute is set.
1166unsignedMaybeWriteOnly : 1;
1167// Indicates that value is a compile-time constant. Global variable
1168// can be 'Constant' while not being 'ReadOnly' on several occasions:
1169// - it is volatile, (e.g mapped device address)
1170// - its address is taken, meaning that unlike 'ReadOnly' vars we can't
1171// internalize it.
1172// Constant variables are always imported thus giving compiler an
1173// opportunity to make some extra optimizations. Readonly constants
1174// are also internalized.
1175unsignedConstant : 1;
1176// Set from metadata on vtable definitions during the module summary
1177// analysis.
1178unsignedVCallVisibility : 2;
1179 }VarFlags;
1180
1181GlobalVarSummary(GVFlags Flags,GVarFlagsVarFlags,
1182SmallVectorImpl<ValueInfo> &&Refs)
1183 :GlobalValueSummary(GlobalVarKind, Flags,std::move(Refs)),
1184VarFlags(VarFlags) {}
1185
1186 /// Check if this is a global variable summary.
1187staticboolclassof(constGlobalValueSummary *GVS) {
1188return GVS->getSummaryKind() ==GlobalVarKind;
1189 }
1190
1191GVarFlagsvarflags() const{returnVarFlags; }
1192voidsetReadOnly(bool RO) {VarFlags.MaybeReadOnly = RO; }
1193voidsetWriteOnly(bool WO) {VarFlags.MaybeWriteOnly = WO; }
1194boolmaybeReadOnly() const{returnVarFlags.MaybeReadOnly; }
1195boolmaybeWriteOnly() const{returnVarFlags.MaybeWriteOnly; }
1196boolisConstant() const{returnVarFlags.Constant; }
1197voidsetVCallVisibility(GlobalObject::VCallVisibility Vis) {
1198VarFlags.VCallVisibility = Vis;
1199 }
1200GlobalObject::VCallVisibilitygetVCallVisibility() const{
1201return (GlobalObject::VCallVisibility)VarFlags.VCallVisibility;
1202 }
1203
1204voidsetVTableFuncs(VTableFuncList Funcs) {
1205assert(!VTableFuncs);
1206 VTableFuncs = std::make_unique<VTableFuncList>(std::move(Funcs));
1207 }
1208
1209ArrayRef<VirtFuncOffset>vTableFuncs() const{
1210if (VTableFuncs)
1211return *VTableFuncs;
1212return {};
1213 }
1214};
1215
1216structTypeTestResolution {
1217 /// Specifies which kind of type check we should emit for this byte array.
1218 /// See http://clang.llvm.org/docs/ControlFlowIntegrityDesign.html for full
1219 /// details on each kind of check; the enumerators are described with
1220 /// reference to that document.
1221enumKind {
1222Unsat,///< Unsatisfiable type (i.e. no global has this type metadata)
1223ByteArray,///< Test a byte array (first example)
1224Inline,///< Inlined bit vector ("Short Inline Bit Vectors")
1225Single,///< Single element (last example in "Short Inline Bit Vectors")
1226AllOnes,///< All-ones bit vector ("Eliminating Bit Vector Checks for
1227 /// All-Ones Bit Vectors")
1228Unknown,///< Unknown (analysis not performed, don't lower)
1229 }TheKind =Unknown;
1230
1231 /// Range of size-1 expressed as a bit width. For example, if the size is in
1232 /// range [1,256], this number will be 8. This helps generate the most compact
1233 /// instruction sequences.
1234unsignedSizeM1BitWidth = 0;
1235
1236// The following fields are only used if the target does not support the use
1237// of absolute symbols to store constants. Their meanings are the same as the
1238// corresponding fields in LowerTypeTestsModule::TypeIdLowering in
1239// LowerTypeTests.cpp.
1240
1241uint64_tAlignLog2 = 0;
1242uint64_tSizeM1 = 0;
1243uint8_tBitMask = 0;
1244uint64_tInlineBits = 0;
1245};
1246
1247structWholeProgramDevirtResolution {
1248enumKind {
1249Indir,///< Just do a regular virtual call
1250SingleImpl,///< Single implementation devirtualization
1251BranchFunnel,///< When retpoline mitigation is enabled, use a branch funnel
1252 ///< that is defined in the merged module. Otherwise same as
1253 ///< Indir.
1254 }TheKind =Indir;
1255
1256 std::stringSingleImplName;
1257
1258structByArg {
1259enumKind {
1260Indir,///< Just do a regular virtual call
1261UniformRetVal,///< Uniform return value optimization
1262UniqueRetVal,///< Unique return value optimization
1263VirtualConstProp,///< Virtual constant propagation
1264 }TheKind =Indir;
1265
1266 /// Additional information for the resolution:
1267 /// - UniformRetVal: the uniform return value.
1268 /// - UniqueRetVal: the return value associated with the unique vtable (0 or
1269 /// 1).
1270uint64_tInfo = 0;
1271
1272// The following fields are only used if the target does not support the use
1273// of absolute symbols to store constants.
1274
1275uint32_tByte = 0;
1276uint32_tBit = 0;
1277 };
1278
1279 /// Resolutions for calls with all constant integer arguments (excluding the
1280 /// first argument, "this"), where the key is the argument vector.
1281 std::map<std::vector<uint64_t>,ByArg>ResByArg;
1282};
1283
1284structTypeIdSummary {
1285TypeTestResolutionTTRes;
1286
1287 /// Mapping from byte offset to whole-program devirt resolution for that
1288 /// (typeid, byte offset) pair.
1289 std::map<uint64_t, WholeProgramDevirtResolution>WPDRes;
1290};
1291
1292/// 160 bits SHA1
1293usingModuleHash = std::array<uint32_t, 5>;
1294
1295/// Type used for iterating through the global value summary map.
1296usingconst_gvsummary_iterator = GlobalValueSummaryMapTy::const_iterator;
1297usinggvsummary_iterator = GlobalValueSummaryMapTy::iterator;
1298
1299/// String table to hold/own module path strings, as well as a hash
1300/// of the module. The StringMap makes a copy of and owns inserted strings.
1301usingModulePathStringTableTy =StringMap<ModuleHash>;
1302
1303/// Map of global value GUID to its summary, used to identify values defined in
1304/// a particular module, and provide efficient access to their summary.
1305usingGVSummaryMapTy =DenseMap<GlobalValue::GUID, GlobalValueSummary *>;
1306
1307/// Map of a module name to the GUIDs and summaries we will import from that
1308/// module.
1309usingModuleToSummariesForIndexTy =
1310 std::map<std::string, GVSummaryMapTy, std::less<>>;
1311
1312/// A set of global value summary pointers.
1313usingGVSummaryPtrSet = std::unordered_set<GlobalValueSummary *>;
1314
1315/// Map of a type GUID to type id string and summary (multimap used
1316/// in case of GUID conflicts).
1317usingTypeIdSummaryMapTy =
1318 std::multimap<GlobalValue::GUID, std::pair<StringRef, TypeIdSummary>>;
1319
1320/// The following data structures summarize type metadata information.
1321/// For type metadata overview see https://llvm.org/docs/TypeMetadata.html.
1322/// Each type metadata includes both the type identifier and the offset of
1323/// the address point of the type (the address held by objects of that type
1324/// which may not be the beginning of the virtual table). Vtable definitions
1325/// are decorated with type metadata for the types they are compatible with.
1326///
1327/// Holds information about vtable definitions decorated with type metadata:
1328/// the vtable definition value and its address point offset in a type
1329/// identifier metadata it is decorated (compatible) with.
1330structTypeIdOffsetVtableInfo {
1331TypeIdOffsetVtableInfo(uint64_tOffset,ValueInfo VI)
1332 :AddressPointOffset(Offset),VTableVI(VI) {}
1333
1334uint64_tAddressPointOffset;
1335ValueInfoVTableVI;
1336};
1337/// List of vtable definitions decorated by a particular type identifier,
1338/// and their corresponding offsets in that type identifier's metadata.
1339/// Note that each type identifier may be compatible with multiple vtables, due
1340/// to inheritance, which is why this is a vector.
1341usingTypeIdCompatibleVtableInfo = std::vector<TypeIdOffsetVtableInfo>;
1342
1343/// Class to hold module path string table and global value map,
1344/// and encapsulate methods for operating on them.
1345classModuleSummaryIndex {
1346private:
1347 /// Map from value name to list of summary instances for values of that
1348 /// name (may be duplicates in the COMDAT case, e.g.).
1349GlobalValueSummaryMapTy GlobalValueMap;
1350
1351 /// Holds strings for combined index, mapping to the corresponding module ID.
1352ModulePathStringTableTy ModulePathStringTable;
1353
1354BumpPtrAllocator TypeIdSaverAlloc;
1355UniqueStringSaver TypeIdSaver;
1356
1357 /// Mapping from type identifier GUIDs to type identifier and its summary
1358 /// information. Produced by thin link.
1359TypeIdSummaryMapTy TypeIdMap;
1360
1361 /// Mapping from type identifier to information about vtables decorated
1362 /// with that type identifier's metadata. Produced by per module summary
1363 /// analysis and consumed by thin link. For more information, see description
1364 /// above where TypeIdCompatibleVtableInfo is defined.
1365 std::map<StringRef, TypeIdCompatibleVtableInfo, std::less<>>
1366 TypeIdCompatibleVtableMap;
1367
1368 /// Mapping from original ID to GUID. If original ID can map to multiple
1369 /// GUIDs, it will be mapped to 0.
1370DenseMap<GlobalValue::GUID, GlobalValue::GUID> OidGuidMap;
1371
1372 /// Indicates that summary-based GlobalValue GC has run, and values with
1373 /// GVFlags::Live==false are really dead. Otherwise, all values must be
1374 /// considered live.
1375bool WithGlobalValueDeadStripping =false;
1376
1377 /// Indicates that summary-based attribute propagation has run and
1378 /// GVarFlags::MaybeReadonly / GVarFlags::MaybeWriteonly are really
1379 /// read/write only.
1380bool WithAttributePropagation =false;
1381
1382 /// Indicates that summary-based DSOLocal propagation has run and the flag in
1383 /// every summary of a GV is synchronized.
1384bool WithDSOLocalPropagation =false;
1385
1386 /// Indicates that we have whole program visibility.
1387bool WithWholeProgramVisibility =false;
1388
1389 /// Indicates that summary-based synthetic entry count propagation has run
1390bool HasSyntheticEntryCounts =false;
1391
1392 /// Indicates that we linked with allocator supporting hot/cold new operators.
1393bool WithSupportsHotColdNew =false;
1394
1395 /// Indicates that distributed backend should skip compilation of the
1396 /// module. Flag is suppose to be set by distributed ThinLTO indexing
1397 /// when it detected that the module is not needed during the final
1398 /// linking. As result distributed backend should just output a minimal
1399 /// valid object file.
1400bool SkipModuleByDistributedBackend =false;
1401
1402 /// If true then we're performing analysis of IR module, or parsing along with
1403 /// the IR from assembly. The value of 'false' means we're reading summary
1404 /// from BC or YAML source. Affects the type of value stored in NameOrGV
1405 /// union.
1406bool HaveGVs;
1407
1408// True if the index was created for a module compiled with -fsplit-lto-unit.
1409bool EnableSplitLTOUnit;
1410
1411// True if the index was created for a module compiled with -funified-lto
1412bool UnifiedLTO;
1413
1414// True if some of the modules were compiled with -fsplit-lto-unit and
1415// some were not. Set when the combined index is created during the thin link.
1416bool PartiallySplitLTOUnits =false;
1417
1418 /// True if some of the FunctionSummary contains a ParamAccess.
1419bool HasParamAccess =false;
1420
1421 std::set<std::string, std::less<>> CfiFunctionDefs;
1422 std::set<std::string, std::less<>> CfiFunctionDecls;
1423
1424// Used in cases where we want to record the name of a global, but
1425// don't have the string owned elsewhere (e.g. the Strtab on a module).
1426BumpPtrAllocator Alloc;
1427StringSaver Saver;
1428
1429// The total number of basic blocks in the module in the per-module summary or
1430// the total number of basic blocks in the LTO unit in the combined index.
1431// FIXME: Putting this in the distributed ThinLTO index files breaks LTO
1432// backend caching on any BB change to any linked file. It is currently not
1433// used except in the case of a SamplePGO partial profile, and should be
1434// reevaluated/redesigned to allow more effective incremental builds in that
1435// case.
1436uint64_t BlockCount = 0;
1437
1438// List of unique stack ids (hashes). We use a 4B index of the id in the
1439// stack id lists on the alloc and callsite summaries for memory savings,
1440// since the number of unique ids is in practice much smaller than the
1441// number of stack id references in the summaries.
1442 std::vector<uint64_t> StackIds;
1443
1444// Temporary map while building StackIds list. Clear when index is completely
1445// built via releaseTemporaryMemory.
1446DenseMap<uint64_t, unsigned> StackIdToIndex;
1447
1448// YAML I/O support.
1449friendyaml::MappingTraits<ModuleSummaryIndex>;
1450
1451 GlobalValueSummaryMapTy::value_type *
1452 getOrInsertValuePtr(GlobalValue::GUID GUID) {
1453return &*GlobalValueMap.emplace(GUID,GlobalValueSummaryInfo(HaveGVs))
1454 .first;
1455 }
1456
1457public:
1458// See HaveGVs variable comment.
1459ModuleSummaryIndex(bool HaveGVs,bool EnableSplitLTOUnit =false,
1460bool UnifiedLTO =false)
1461 : TypeIdSaver(TypeIdSaverAlloc), HaveGVs(HaveGVs),
1462 EnableSplitLTOUnit(EnableSplitLTOUnit), UnifiedLTO(UnifiedLTO),
1463 Saver(Alloc) {}
1464
1465// Current version for the module summary in bitcode files.
1466// The BitcodeSummaryVersion should be bumped whenever we introduce changes
1467// in the way some record are interpreted, like flags for instance.
1468// Note that incrementing this may require changes in both BitcodeReader.cpp
1469// and BitcodeWriter.cpp.
1470staticconstexpruint64_tBitcodeSummaryVersion = 12;
1471
1472// Regular LTO module name for ASM writer
1473staticconstexprconstchar *getRegularLTOModuleName() {
1474return"[Regular LTO]";
1475 }
1476
1477boolhaveGVs() const{return HaveGVs; }
1478
1479uint64_tgetFlags()const;
1480voidsetFlags(uint64_t Flags);
1481
1482uint64_tgetBlockCount() const{return BlockCount; }
1483voidaddBlockCount(uint64_tC) { BlockCount +=C; }
1484voidsetBlockCount(uint64_tC) { BlockCount =C; }
1485
1486gvsummary_iteratorbegin() {return GlobalValueMap.begin(); }
1487const_gvsummary_iteratorbegin() const{return GlobalValueMap.begin(); }
1488gvsummary_iteratorend() {return GlobalValueMap.end(); }
1489const_gvsummary_iteratorend() const{return GlobalValueMap.end(); }
1490size_tsize() const{return GlobalValueMap.size(); }
1491
1492const std::vector<uint64_t> &stackIds() const{return StackIds; }
1493
1494unsignedaddOrGetStackIdIndex(uint64_t StackId) {
1495auto Inserted = StackIdToIndex.insert({StackId, StackIds.size()});
1496if (Inserted.second)
1497 StackIds.push_back(StackId);
1498return Inserted.first->second;
1499 }
1500
1501uint64_tgetStackIdAtIndex(unsignedIndex) const{
1502assert(StackIds.size() >Index);
1503return StackIds[Index];
1504 }
1505
1506// Facility to release memory from data structures only needed during index
1507// construction (including while building combined index). Currently this only
1508// releases the temporary map used while constructing a correspondence between
1509// stack ids and their index in the StackIds vector. Mostly impactful when
1510// building a large combined index.
1511voidreleaseTemporaryMemory() {
1512assert(StackIdToIndex.size() == StackIds.size());
1513 StackIdToIndex.clear();
1514 StackIds.shrink_to_fit();
1515 }
1516
1517 /// Convenience function for doing a DFS on a ValueInfo. Marks the function in
1518 /// the FunctionHasParent map.
1519staticvoiddiscoverNodes(ValueInfo V,
1520 std::map<ValueInfo, bool> &FunctionHasParent) {
1521if (!V.getSummaryList().size())
1522return;// skip external functions that don't have summaries
1523
1524// Mark discovered if we haven't yet
1525auto S = FunctionHasParent.emplace(V,false);
1526
1527// Stop if we've already discovered this node
1528if (!S.second)
1529return;
1530
1531FunctionSummary *F =
1532 dyn_cast<FunctionSummary>(V.getSummaryList().front().get());
1533assert(F !=nullptr &&"Expected FunctionSummary node");
1534
1535for (constauto &C :F->calls()) {
1536// Insert node if necessary
1537auto S = FunctionHasParent.emplace(C.first,true);
1538
1539// Skip nodes that we're sure have parents
1540if (!S.second && S.first->second)
1541continue;
1542
1543if (S.second)
1544discoverNodes(C.first, FunctionHasParent);
1545else
1546 S.first->second =true;
1547 }
1548 }
1549
1550// Calculate the callgraph root
1551FunctionSummarycalculateCallGraphRoot() {
1552// Functions that have a parent will be marked in FunctionHasParent pair.
1553// Once we've marked all functions, the functions in the map that are false
1554// have no parent (so they're the roots)
1555 std::map<ValueInfo, bool> FunctionHasParent;
1556
1557for (auto &S : *this) {
1558// Skip external functions
1559if (!S.second.SummaryList.size() ||
1560 !isa<FunctionSummary>(S.second.SummaryList.front().get()))
1561continue;
1562discoverNodes(ValueInfo(HaveGVs, &S), FunctionHasParent);
1563 }
1564
1565SmallVector<FunctionSummary::EdgeTy, 0> Edges;
1566// create edges to all roots in the Index
1567for (auto &P : FunctionHasParent) {
1568if (P.second)
1569continue;// skip over non-root nodes
1570 Edges.push_back(std::make_pair(P.first,CalleeInfo{}));
1571 }
1572returnFunctionSummary::makeDummyFunctionSummary(std::move(Edges));
1573 }
1574
1575boolwithGlobalValueDeadStripping() const{
1576return WithGlobalValueDeadStripping;
1577 }
1578voidsetWithGlobalValueDeadStripping() {
1579 WithGlobalValueDeadStripping =true;
1580 }
1581
1582boolwithAttributePropagation() const{return WithAttributePropagation; }
1583voidsetWithAttributePropagation() {
1584 WithAttributePropagation =true;
1585 }
1586
1587boolwithDSOLocalPropagation() const{return WithDSOLocalPropagation; }
1588voidsetWithDSOLocalPropagation() { WithDSOLocalPropagation =true; }
1589
1590boolwithWholeProgramVisibility() const{return WithWholeProgramVisibility; }
1591voidsetWithWholeProgramVisibility() { WithWholeProgramVisibility =true; }
1592
1593boolisReadOnly(constGlobalVarSummary *GVS) const{
1594return WithAttributePropagation && GVS->maybeReadOnly();
1595 }
1596boolisWriteOnly(constGlobalVarSummary *GVS) const{
1597return WithAttributePropagation && GVS->maybeWriteOnly();
1598 }
1599
1600boolwithSupportsHotColdNew() const{return WithSupportsHotColdNew; }
1601voidsetWithSupportsHotColdNew() { WithSupportsHotColdNew =true; }
1602
1603boolskipModuleByDistributedBackend() const{
1604return SkipModuleByDistributedBackend;
1605 }
1606voidsetSkipModuleByDistributedBackend() {
1607 SkipModuleByDistributedBackend =true;
1608 }
1609
1610boolenableSplitLTOUnit() const{return EnableSplitLTOUnit; }
1611voidsetEnableSplitLTOUnit() { EnableSplitLTOUnit =true; }
1612
1613boolhasUnifiedLTO() const{return UnifiedLTO; }
1614voidsetUnifiedLTO() { UnifiedLTO =true; }
1615
1616boolpartiallySplitLTOUnits() const{return PartiallySplitLTOUnits; }
1617voidsetPartiallySplitLTOUnits() { PartiallySplitLTOUnits =true; }
1618
1619boolhasParamAccess() const{return HasParamAccess; }
1620
1621boolisGlobalValueLive(constGlobalValueSummary *GVS) const{
1622return !WithGlobalValueDeadStripping || GVS->isLive();
1623 }
1624boolisGUIDLive(GlobalValue::GUID GUID)const;
1625
1626 /// Return a ValueInfo for the index value_type (convenient when iterating
1627 /// index).
1628ValueInfogetValueInfo(const GlobalValueSummaryMapTy::value_type &R) const{
1629returnValueInfo(HaveGVs, &R);
1630 }
1631
1632 /// Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
1633ValueInfogetValueInfo(GlobalValue::GUID GUID) const{
1634autoI = GlobalValueMap.find(GUID);
1635returnValueInfo(HaveGVs,I == GlobalValueMap.end() ?nullptr : &*I);
1636 }
1637
1638 /// Return a ValueInfo for \p GUID.
1639ValueInfogetOrInsertValueInfo(GlobalValue::GUID GUID) {
1640returnValueInfo(HaveGVs, getOrInsertValuePtr(GUID));
1641 }
1642
1643// Save a string in the Index. Use before passing Name to
1644// getOrInsertValueInfo when the string isn't owned elsewhere (e.g. on the
1645// module's Strtab).
1646StringRefsaveString(StringRefString) {return Saver.save(String); }
1647
1648 /// Return a ValueInfo for \p GUID setting value \p Name.
1649ValueInfogetOrInsertValueInfo(GlobalValue::GUID GUID,StringRefName) {
1650assert(!HaveGVs);
1651auto VP = getOrInsertValuePtr(GUID);
1652 VP->second.U.Name =Name;
1653returnValueInfo(HaveGVs, VP);
1654 }
1655
1656 /// Return a ValueInfo for \p GV and mark it as belonging to GV.
1657ValueInfogetOrInsertValueInfo(constGlobalValue *GV) {
1658assert(HaveGVs);
1659auto VP = getOrInsertValuePtr(GV->getGUID());
1660 VP->second.U.GV = GV;
1661returnValueInfo(HaveGVs, VP);
1662 }
1663
1664 /// Return the GUID for \p OriginalId in the OidGuidMap.
1665GlobalValue::GUIDgetGUIDFromOriginalID(GlobalValue::GUID OriginalID) const{
1666constautoI = OidGuidMap.find(OriginalID);
1667returnI == OidGuidMap.end() ? 0 :I->second;
1668 }
1669
1670 std::set<std::string, std::less<>> &cfiFunctionDefs() {
1671return CfiFunctionDefs;
1672 }
1673const std::set<std::string, std::less<>> &cfiFunctionDefs() const{
1674return CfiFunctionDefs;
1675 }
1676
1677 std::set<std::string, std::less<>> &cfiFunctionDecls() {
1678return CfiFunctionDecls;
1679 }
1680const std::set<std::string, std::less<>> &cfiFunctionDecls() const{
1681return CfiFunctionDecls;
1682 }
1683
1684 /// Add a global value summary for a value.
1685voidaddGlobalValueSummary(constGlobalValue &GV,
1686 std::unique_ptr<GlobalValueSummary> Summary) {
1687addGlobalValueSummary(getOrInsertValueInfo(&GV), std::move(Summary));
1688 }
1689
1690 /// Add a global value summary for a value of the given name.
1691voidaddGlobalValueSummary(StringRefValueName,
1692 std::unique_ptr<GlobalValueSummary> Summary) {
1693addGlobalValueSummary(getOrInsertValueInfo(GlobalValue::getGUID(ValueName)),
1694 std::move(Summary));
1695 }
1696
1697 /// Add a global value summary for the given ValueInfo.
1698voidaddGlobalValueSummary(ValueInfo VI,
1699 std::unique_ptr<GlobalValueSummary> Summary) {
1700if (constFunctionSummary *FS = dyn_cast<FunctionSummary>(Summary.get()))
1701 HasParamAccess |= !FS->paramAccesses().empty();
1702addOriginalName(VI.getGUID(), Summary->getOriginalName());
1703// Here we have a notionally const VI, but the value it points to is owned
1704// by the non-const *this.
1705const_cast<GlobalValueSummaryMapTy::value_type *>(VI.getRef())
1706 ->second.SummaryList.push_back(std::move(Summary));
1707 }
1708
1709 /// Add an original name for the value of the given GUID.
1710voidaddOriginalName(GlobalValue::GUID ValueGUID,
1711GlobalValue::GUID OrigGUID) {
1712if (OrigGUID == 0 || ValueGUID == OrigGUID)
1713return;
1714auto [It, Inserted] = OidGuidMap.try_emplace(OrigGUID, ValueGUID);
1715if (!Inserted && It->second != ValueGUID)
1716 It->second = 0;
1717 }
1718
1719 /// Find the summary for ValueInfo \p VI in module \p ModuleId, or nullptr if
1720 /// not found.
1721GlobalValueSummary *findSummaryInModule(ValueInfo VI,StringRef ModuleId) const{
1722auto SummaryList = VI.getSummaryList();
1723auto Summary =
1724llvm::find_if(SummaryList,
1725 [&](const std::unique_ptr<GlobalValueSummary> &Summary) {
1726return Summary->modulePath() == ModuleId;
1727 });
1728if (Summary == SummaryList.end())
1729returnnullptr;
1730return Summary->get();
1731 }
1732
1733 /// Find the summary for global \p GUID in module \p ModuleId, or nullptr if
1734 /// not found.
1735GlobalValueSummary *findSummaryInModule(GlobalValue::GUID ValueGUID,
1736StringRef ModuleId) const{
1737autoCalleeInfo =getValueInfo(ValueGUID);
1738if (!CalleeInfo)
1739returnnullptr;// This function does not have a summary
1740returnfindSummaryInModule(CalleeInfo, ModuleId);
1741 }
1742
1743 /// Returns the first GlobalValueSummary for \p GV, asserting that there
1744 /// is only one if \p PerModuleIndex.
1745GlobalValueSummary *getGlobalValueSummary(constGlobalValue &GV,
1746bool PerModuleIndex =true) const{
1747assert(GV.hasName() &&"Can't get GlobalValueSummary for GV with no name");
1748returngetGlobalValueSummary(GV.getGUID(), PerModuleIndex);
1749 }
1750
1751 /// Returns the first GlobalValueSummary for \p ValueGUID, asserting that
1752 /// there
1753 /// is only one if \p PerModuleIndex.
1754GlobalValueSummary *getGlobalValueSummary(GlobalValue::GUID ValueGUID,
1755bool PerModuleIndex =true)const;
1756
1757 /// Table of modules, containing module hash and id.
1758constStringMap<ModuleHash> &modulePaths() const{
1759return ModulePathStringTable;
1760 }
1761
1762 /// Table of modules, containing hash and id.
1763StringMap<ModuleHash> &modulePaths() {return ModulePathStringTable; }
1764
1765 /// Get the module SHA1 hash recorded for the given module path.
1766constModuleHash &getModuleHash(constStringRef ModPath) const{
1767auto It = ModulePathStringTable.find(ModPath);
1768assert(It != ModulePathStringTable.end() &&"Module not registered");
1769return It->second;
1770 }
1771
1772 /// Convenience method for creating a promoted global name
1773 /// for the given value name of a local, and its original module's ID.
1774static std::stringgetGlobalNameForLocal(StringRefName,ModuleHash ModHash) {
1775 std::string Suffix = utostr((uint64_t(ModHash[0]) << 32) |
1776 ModHash[1]);// Take the first 64 bits
1777returngetGlobalNameForLocal(Name, Suffix);
1778 }
1779
1780static std::stringgetGlobalNameForLocal(StringRefName,StringRef Suffix) {
1781SmallString<256> NewName(Name);
1782 NewName +=".llvm.";
1783 NewName += Suffix;
1784return std::string(NewName);
1785 }
1786
1787 /// Helper to obtain the unpromoted name for a global value (or the original
1788 /// name if not promoted). Split off the rightmost ".llvm.${hash}" suffix,
1789 /// because it is possible in certain clients (not clang at the moment) for
1790 /// two rounds of ThinLTO optimization and therefore promotion to occur.
1791staticStringRefgetOriginalNameBeforePromote(StringRefName) {
1792 std::pair<StringRef, StringRef> Pair =Name.rsplit(".llvm.");
1793return Pair.first;
1794 }
1795
1796typedefModulePathStringTableTy::value_typeModuleInfo;
1797
1798 /// Add a new module with the given \p Hash, mapped to the given \p
1799 /// ModID, and return a reference to the module.
1800ModuleInfo *addModule(StringRef ModPath,ModuleHash Hash =ModuleHash{{0}}) {
1801return &*ModulePathStringTable.insert({ModPath, Hash}).first;
1802 }
1803
1804 /// Return module entry for module with the given \p ModPath.
1805ModuleInfo *getModule(StringRef ModPath) {
1806auto It = ModulePathStringTable.find(ModPath);
1807assert(It != ModulePathStringTable.end() &&"Module not registered");
1808return &*It;
1809 }
1810
1811 /// Return module entry for module with the given \p ModPath.
1812constModuleInfo *getModule(StringRef ModPath) const{
1813auto It = ModulePathStringTable.find(ModPath);
1814assert(It != ModulePathStringTable.end() &&"Module not registered");
1815return &*It;
1816 }
1817
1818 /// Check if the given Module has any functions available for exporting
1819 /// in the index. We consider any module present in the ModulePathStringTable
1820 /// to have exported functions.
1821boolhasExportedFunctions(constModule &M) const{
1822return ModulePathStringTable.count(M.getModuleIdentifier());
1823 }
1824
1825constTypeIdSummaryMapTy &typeIds() const{return TypeIdMap; }
1826
1827 /// Return an existing or new TypeIdSummary entry for \p TypeId.
1828 /// This accessor can mutate the map and therefore should not be used in
1829 /// the ThinLTO backends.
1830TypeIdSummary &getOrInsertTypeIdSummary(StringRef TypeId) {
1831auto TidIter = TypeIdMap.equal_range(GlobalValue::getGUID(TypeId));
1832for (auto &[GUID, TypeIdPair] :make_range(TidIter))
1833if (TypeIdPair.first == TypeId)
1834return TypeIdPair.second;
1835auto It = TypeIdMap.insert({GlobalValue::getGUID(TypeId),
1836 {TypeIdSaver.save(TypeId),TypeIdSummary()}});
1837return It->second.second;
1838 }
1839
1840 /// This returns either a pointer to the type id summary (if present in the
1841 /// summary map) or null (if not present). This may be used when importing.
1842constTypeIdSummary *getTypeIdSummary(StringRef TypeId) const{
1843auto TidIter = TypeIdMap.equal_range(GlobalValue::getGUID(TypeId));
1844for (constauto &[GUID, TypeIdPair] :make_range(TidIter))
1845if (TypeIdPair.first == TypeId)
1846return &TypeIdPair.second;
1847returnnullptr;
1848 }
1849
1850TypeIdSummary *getTypeIdSummary(StringRef TypeId) {
1851returnconst_cast<TypeIdSummary *>(
1852static_cast<constModuleSummaryIndex *>(this)->getTypeIdSummary(
1853 TypeId));
1854 }
1855
1856constauto &typeIdCompatibleVtableMap() const{
1857return TypeIdCompatibleVtableMap;
1858 }
1859
1860 /// Return an existing or new TypeIdCompatibleVtableMap entry for \p TypeId.
1861 /// This accessor can mutate the map and therefore should not be used in
1862 /// the ThinLTO backends.
1863TypeIdCompatibleVtableInfo &
1864getOrInsertTypeIdCompatibleVtableSummary(StringRef TypeId) {
1865return TypeIdCompatibleVtableMap[TypeIdSaver.save(TypeId)];
1866 }
1867
1868 /// For the given \p TypeId, this returns the TypeIdCompatibleVtableMap
1869 /// entry if present in the summary map. This may be used when importing.
1870 std::optional<TypeIdCompatibleVtableInfo>
1871getTypeIdCompatibleVtableSummary(StringRef TypeId) const{
1872autoI = TypeIdCompatibleVtableMap.find(TypeId);
1873if (I == TypeIdCompatibleVtableMap.end())
1874return std::nullopt;
1875returnI->second;
1876 }
1877
1878 /// Collect for the given module the list of functions it defines
1879 /// (GUID -> Summary).
1880voidcollectDefinedFunctionsForModule(StringRef ModulePath,
1881GVSummaryMapTy &GVSummaryMap)const;
1882
1883 /// Collect for each module the list of Summaries it defines (GUID ->
1884 /// Summary).
1885template <class Map>
1886void
1887collectDefinedGVSummariesPerModule(Map &ModuleToDefinedGVSummaries) const{
1888for (constauto &GlobalList : *this) {
1889auto GUID = GlobalList.first;
1890for (constauto &Summary : GlobalList.second.SummaryList) {
1891 ModuleToDefinedGVSummaries[Summary->modulePath()][GUID] = Summary.get();
1892 }
1893 }
1894 }
1895
1896 /// Print to an output stream.
1897voidprint(raw_ostream &OS,bool IsForDebug =false)const;
1898
1899 /// Dump to stderr (for debugging).
1900voiddump()const;
1901
1902 /// Export summary to dot file for GraphViz.
1903void
1904exportToDot(raw_ostream &OS,
1905constDenseSet<GlobalValue::GUID> &GUIDPreservedSymbols)const;
1906
1907 /// Print out strongly connected components for debugging.
1908voiddumpSCCs(raw_ostream &OS);
1909
1910 /// Do the access attribute and DSOLocal propagation in combined index.
1911voidpropagateAttributes(constDenseSet<GlobalValue::GUID> &PreservedSymbols);
1912
1913 /// Checks if we can import global variable from another module.
1914boolcanImportGlobalVar(constGlobalValueSummary *S,bool AnalyzeRefs)const;
1915
1916 /// Same as above but checks whether the global var is importable as a
1917 /// declaration.
1918boolcanImportGlobalVar(constGlobalValueSummary *S,bool AnalyzeRefs,
1919bool &CanImportDecl)const;
1920};
1921
1922/// GraphTraits definition to build SCC for the index
1923template <>structGraphTraits<ValueInfo> {
1924typedefValueInfoNodeRef;
1925usingEdgeRef =FunctionSummary::EdgeTy &;
1926
1927staticNodeRefvalueInfoFromEdge(FunctionSummary::EdgeTy &P) {
1928returnP.first;
1929 }
1930usingChildIteratorType =
1931mapped_iterator<SmallVector<FunctionSummary::EdgeTy, 0>::iterator,
1932decltype(&valueInfoFromEdge)>;
1933
1934usingChildEdgeIteratorType =
1935SmallVector<FunctionSummary::EdgeTy, 0>::iterator;
1936
1937staticNodeRefgetEntryNode(ValueInfo V) {return V; }
1938
1939staticChildIteratorTypechild_begin(NodeRefN) {
1940if (!N.getSummaryList().size())// handle external function
1941returnChildIteratorType(
1942FunctionSummary::ExternalNode.CallGraphEdgeList.begin(),
1943 &valueInfoFromEdge);
1944FunctionSummary *F =
1945 cast<FunctionSummary>(N.getSummaryList().front()->getBaseObject());
1946returnChildIteratorType(F->CallGraphEdgeList.begin(), &valueInfoFromEdge);
1947 }
1948
1949staticChildIteratorTypechild_end(NodeRefN) {
1950if (!N.getSummaryList().size())// handle external function
1951returnChildIteratorType(
1952FunctionSummary::ExternalNode.CallGraphEdgeList.end(),
1953 &valueInfoFromEdge);
1954FunctionSummary *F =
1955 cast<FunctionSummary>(N.getSummaryList().front()->getBaseObject());
1956returnChildIteratorType(F->CallGraphEdgeList.end(), &valueInfoFromEdge);
1957 }
1958
1959staticChildEdgeIteratorTypechild_edge_begin(NodeRefN) {
1960if (!N.getSummaryList().size())// handle external function
1961returnFunctionSummary::ExternalNode.CallGraphEdgeList.begin();
1962
1963FunctionSummary *F =
1964 cast<FunctionSummary>(N.getSummaryList().front()->getBaseObject());
1965returnF->CallGraphEdgeList.begin();
1966 }
1967
1968staticChildEdgeIteratorTypechild_edge_end(NodeRefN) {
1969if (!N.getSummaryList().size())// handle external function
1970returnFunctionSummary::ExternalNode.CallGraphEdgeList.end();
1971
1972FunctionSummary *F =
1973 cast<FunctionSummary>(N.getSummaryList().front()->getBaseObject());
1974returnF->CallGraphEdgeList.end();
1975 }
1976
1977staticNodeRefedge_dest(EdgeRefE) {returnE.first; }
1978};
1979
1980template <>
1981structGraphTraits<ModuleSummaryIndex *> :publicGraphTraits<ValueInfo> {
1982staticNodeRefgetEntryNode(ModuleSummaryIndex *I) {
1983 std::unique_ptr<GlobalValueSummary> Root =
1984 std::make_unique<FunctionSummary>(I->calculateCallGraphRoot());
1985GlobalValueSummaryInfoG(I->haveGVs());
1986G.SummaryList.push_back(std::move(Root));
1987staticautoP =
1988 GlobalValueSummaryMapTy::value_type(GlobalValue::GUID(0), std::move(G));
1989returnValueInfo(I->haveGVs(), &P);
1990 }
1991};
1992}// end namespace llvm
1993
1994#endif// LLVM_IR_MODULESUMMARYINDEX_H
for
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
Definition:AArch64ExpandPseudoInsts.cpp:115
StringMap.h
This file defines the StringMap class.
Allocator.h
This file defines the BumpPtrAllocator interface.
ArrayRef.h
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
ConstantRange.h
Linkage
DXIL Finalize Linkage
Definition:DXILFinalizeLinkage.cpp:58
Live
Looks at all the uses of the given value Returns the Liveness deduced from the uses of this value Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses If the result is Live
Definition:DeadArgumentElimination.cpp:472
DenseMap.h
This file defines the DenseMap class.
Name
std::string Name
Definition:ELFObjHandler.cpp:77
Index
uint32_t Index
Definition:ELFObjHandler.cpp:83
HashFunctionMode::Local
@ Local
GlobalValue.h
PreservedSymbols
static const char * PreservedSymbols[]
Definition:IRSymtab.cpp:49
Module.h
Module.h This file contains the declarations for the Module class.
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
G
#define G(x, y, z)
Definition:MD5.cpp:56
MathExtras.h
AllocType
AllocType
Definition:MemoryBuiltins.cpp:59
P
#define P(N)
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
STLExtras.h
This file contains some templates that are useful if you are working with the STL at all.
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
ScaledNumber.h
SmallString.h
This file defines the SmallString class.
SmallVector.h
This file defines the SmallVector class.
StringExtras.h
This file contains some functions that are useful when dealing with strings.
StringRef.h
StringSaver.h
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
T
bool
llvm::AliasSummary
Alias summary information.
Definition:ModuleSummaryIndex.h:657
llvm::AliasSummary::getAliaseeGUID
GlobalValue::GUID getAliaseeGUID() const
Definition:ModuleSummaryIndex.h:700
llvm::AliasSummary::getAliasee
const GlobalValueSummary & getAliasee() const
Definition:ModuleSummaryIndex.h:687
llvm::AliasSummary::getAliaseeVI
ValueInfo getAliaseeVI() const
Definition:ModuleSummaryIndex.h:696
llvm::AliasSummary::classof
static bool classof(const GlobalValueSummary *GVS)
Check if this is an alias summary.
Definition:ModuleSummaryIndex.h:671
llvm::AliasSummary::AliasSummary
AliasSummary(GVFlags Flags)
Definition:ModuleSummaryIndex.h:667
llvm::AliasSummary::hasAliasee
bool hasAliasee() const
Definition:ModuleSummaryIndex.h:680
llvm::AliasSummary::getAliasee
GlobalValueSummary & getAliasee()
Definition:ModuleSummaryIndex.h:692
llvm::AliasSummary::setAliasee
void setAliasee(ValueInfo &AliaseeVI, GlobalValueSummary *Aliasee)
Definition:ModuleSummaryIndex.h:675
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition:ArrayRef.h:41
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition:Allocator.h:66
llvm::ConstantRange
This class represents a range of values.
Definition:ConstantRange.h:47
llvm::Constant
This is an important base class in LLVM.
Definition:Constant.h:42
llvm::DenseMapBase::find
iterator find(const_arg_type_t< KeyT > Val)
Definition:DenseMap.h:156
llvm::DenseMapBase::try_emplace
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Definition:DenseMap.h:226
llvm::DenseMapBase::size
unsigned size() const
Definition:DenseMap.h:99
llvm::DenseMapBase::end
iterator end()
Definition:DenseMap.h:84
llvm::DenseMapBase::insert
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Definition:DenseMap.h:211
llvm::DenseMapBase::clear
void clear()
Definition:DenseMap.h:110
llvm::DenseMap
Definition:DenseMap.h:727
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition:DenseSet.h:278
llvm::FunctionSummary
Function summary information to aid decisions and implementation of importing.
Definition:ModuleSummaryIndex.h:720
llvm::FunctionSummary::ExternalNode
static FunctionSummary ExternalNode
A dummy node to reference external functions that aren't in the index.
Definition:ModuleSummaryIndex.h:893
llvm::FunctionSummary::addCallsite
void addCallsite(CallsiteInfo &Callsite)
Definition:ModuleSummaryIndex.h:1069
llvm::FunctionSummary::makeDummyFunctionSummary
static FunctionSummary makeDummyFunctionSummary(SmallVectorImpl< FunctionSummary::EdgeTy > &&Edges)
Create an empty FunctionSummary (with specified call edges).
Definition:ModuleSummaryIndex.h:875
llvm::FunctionSummary::FunctionSummary
FunctionSummary(GVFlags Flags, unsigned NumInsts, FFlags FunFlags, SmallVectorImpl< ValueInfo > &&Refs, SmallVectorImpl< EdgeTy > &&CGEdges, std::vector< GlobalValue::GUID > TypeTests, std::vector< VFuncId > TypeTestAssumeVCalls, std::vector< VFuncId > TypeCheckedLoadVCalls, std::vector< ConstVCall > TypeTestAssumeConstVCalls, std::vector< ConstVCall > TypeCheckedLoadConstVCalls, std::vector< ParamAccess > Params, CallsitesTy CallsiteList, AllocsTy AllocList)
Definition:ModuleSummaryIndex.h:934
llvm::FunctionSummary::type_test_assume_vcalls
ArrayRef< VFuncId > type_test_assume_vcalls() const
Returns the list of virtual calls made by this function using llvm.assume(llvm.type....
Definition:ModuleSummaryIndex.h:999
llvm::FunctionSummary::mutableAllocs
AllocsTy & mutableAllocs()
Definition:ModuleSummaryIndex.h:1081
llvm::FunctionSummary::setNoRecurse
void setNoRecurse()
Definition:ModuleSummaryIndex.h:973
llvm::FunctionSummary::addCall
void addCall(EdgeTy E)
Definition:ModuleSummaryIndex.h:985
llvm::FunctionSummary::type_test_assume_const_vcalls
ArrayRef< ConstVCall > type_test_assume_const_vcalls() const
Returns the list of virtual calls made by this function using llvm.assume(llvm.type....
Definition:ModuleSummaryIndex.h:1017
llvm::FunctionSummary::EdgeTy
std::pair< ValueInfo, CalleeInfo > EdgeTy
<CalleeValueInfo, CalleeInfo> call edge pair.
Definition:ModuleSummaryIndex.h:723
llvm::FunctionSummary::specialRefCounts
std::pair< unsigned, unsigned > specialRefCounts() const
Definition:ModuleSummaryIndex.cpp:78
llvm::FunctionSummary::mutableCalls
SmallVector< EdgeTy, 0 > & mutableCalls()
Definition:ModuleSummaryIndex.h:983
llvm::FunctionSummary::allocs
ArrayRef< AllocInfo > allocs() const
Definition:ModuleSummaryIndex.h:1075
llvm::FunctionSummary::callsites
ArrayRef< CallsiteInfo > callsites() const
Definition:ModuleSummaryIndex.h:1058
llvm::FunctionSummary::setNoUnwind
void setNoUnwind()
Definition:ModuleSummaryIndex.h:975
llvm::FunctionSummary::addTypeTest
void addTypeTest(GlobalValue::GUID Guid)
Add a type test to the summary.
Definition:ModuleSummaryIndex.h:1050
llvm::FunctionSummary::type_checked_load_vcalls
ArrayRef< VFuncId > type_checked_load_vcalls() const
Returns the list of virtual calls made by this function using llvm.type.checked.load intrinsics that ...
Definition:ModuleSummaryIndex.h:1008
llvm::FunctionSummary::setParamAccesses
void setParamAccesses(std::vector< ParamAccess > NewParams)
Sets the list of known uses of pointer parameters.
Definition:ModuleSummaryIndex.h:1039
llvm::FunctionSummary::instCount
unsigned instCount() const
Get the instruction count recorded for this function.
Definition:ModuleSummaryIndex.h:978
llvm::FunctionSummary::getTypeIdInfo
const TypeIdInfo * getTypeIdInfo() const
Definition:ModuleSummaryIndex.h:1056
llvm::FunctionSummary::type_checked_load_const_vcalls
ArrayRef< ConstVCall > type_checked_load_const_vcalls() const
Returns the list of virtual calls made by this function using llvm.type.checked.load intrinsics with ...
Definition:ModuleSummaryIndex.h:1025
llvm::FunctionSummary::calls
ArrayRef< EdgeTy > calls() const
Return the list of <CalleeValueInfo, CalleeInfo> pairs.
Definition:ModuleSummaryIndex.h:981
llvm::FunctionSummary::paramAccesses
ArrayRef< ParamAccess > paramAccesses() const
Returns the list of known uses of pointer parameters.
Definition:ModuleSummaryIndex.h:1032
llvm::FunctionSummary::mutableCallsites
CallsitesTy & mutableCallsites()
Definition:ModuleSummaryIndex.h:1064
llvm::FunctionSummary::ForceSummaryHotnessType
ForceSummaryHotnessType
Types for -force-summary-edges-cold debugging option.
Definition:ModuleSummaryIndex.h:726
llvm::FunctionSummary::FSHT_None
@ FSHT_None
Definition:ModuleSummaryIndex.h:727
llvm::FunctionSummary::FSHT_AllNonCritical
@ FSHT_AllNonCritical
Definition:ModuleSummaryIndex.h:728
llvm::FunctionSummary::FSHT_All
@ FSHT_All
Definition:ModuleSummaryIndex.h:729
llvm::FunctionSummary::fflags
FFlags fflags() const
Get function summary flags.
Definition:ModuleSummaryIndex.h:971
llvm::FunctionSummary::type_tests
ArrayRef< GlobalValue::GUID > type_tests() const
Returns the list of type identifiers used by this function in llvm.type.test intrinsics other than by...
Definition:ModuleSummaryIndex.h:990
llvm::FunctionSummary::classof
static bool classof(const GlobalValueSummary *GVS)
Check if this is a function summary.
Definition:ModuleSummaryIndex.h:966
llvm::GlobalObject::VCallVisibility
VCallVisibility
Definition:GlobalObject.h:32
llvm::GlobalValueSummary
Function and variable summary information to aid decisions and implementation of importing.
Definition:ModuleSummaryIndex.h:466
llvm::GlobalValueSummary::ImportKind
ImportKind
Definition:ModuleSummaryIndex.h:471
llvm::GlobalValueSummary::Declaration
@ Declaration
Definition:ModuleSummaryIndex.h:480
llvm::GlobalValueSummary::Definition
@ Definition
Definition:ModuleSummaryIndex.h:474
llvm::GlobalValueSummary::SummaryKind
SummaryKind
Sububclass discriminator (for dyn_cast<> et al.)
Definition:ModuleSummaryIndex.h:469
llvm::GlobalValueSummary::GlobalVarKind
@ GlobalVarKind
Definition:ModuleSummaryIndex.h:469
llvm::GlobalValueSummary::FunctionKind
@ FunctionKind
Definition:ModuleSummaryIndex.h:469
llvm::GlobalValueSummary::AliasKind
@ AliasKind
Definition:ModuleSummaryIndex.h:469
llvm::GlobalValueSummary::isDSOLocal
bool isDSOLocal() const
Definition:ModuleSummaryIndex.h:617
llvm::GlobalValueSummary::setLive
void setLive(bool Live)
Definition:ModuleSummaryIndex.h:613
llvm::GlobalValueSummary::flags
GVFlags flags() const
Get the flags for this GlobalValue (see struct GVFlags).
Definition:ModuleSummaryIndex.h:595
llvm::GlobalValueSummary::setDSOLocal
void setDSOLocal(bool Local)
Definition:ModuleSummaryIndex.h:615
llvm::GlobalValueSummary::modulePath
StringRef modulePath() const
Get the path to the module containing this function.
Definition:ModuleSummaryIndex.h:592
llvm::GlobalValueSummary::getBaseObject
GlobalValueSummary * getBaseObject()
If this is an alias summary, returns the summary of the aliased object (a global variable or function...
Definition:ModuleSummaryIndex.h:712
llvm::GlobalValueSummary::getSummaryKind
SummaryKind getSummaryKind() const
Which kind of summary subclass this is.
Definition:ModuleSummaryIndex.h:585
llvm::GlobalValueSummary::getOriginalName
GlobalValue::GUID getOriginalName() const
Returns the hash of the original name, it is identical to the GUID for externally visible symbols,...
Definition:ModuleSummaryIndex.h:579
llvm::GlobalValueSummary::getVisibility
GlobalValue::VisibilityTypes getVisibility() const
Definition:ModuleSummaryIndex.h:633
llvm::GlobalValueSummary::refs
ArrayRef< ValueInfo > refs() const
Return the list of values referenced by this global value definition.
Definition:ModuleSummaryIndex.h:644
llvm::GlobalValueSummary::shouldImportAsDecl
bool shouldImportAsDecl() const
Definition:ModuleSummaryIndex.h:623
llvm::GlobalValueSummary::setLinkage
void setLinkage(GlobalValue::LinkageTypes Linkage)
Sets the linkage to the value determined by global summary-based optimization.
Definition:ModuleSummaryIndex.h:604
llvm::GlobalValueSummary::setVisibility
void setVisibility(GlobalValue::VisibilityTypes Vis)
Definition:ModuleSummaryIndex.h:636
llvm::GlobalValueSummary::~GlobalValueSummary
virtual ~GlobalValueSummary()=default
llvm::GlobalValueSummary::importType
GlobalValueSummary::ImportKind importType() const
Definition:ModuleSummaryIndex.h:629
llvm::GlobalValueSummary::setModulePath
void setModulePath(StringRef ModPath)
Set the path to the module containing this function, for use in the combined index.
Definition:ModuleSummaryIndex.h:589
llvm::GlobalValueSummary::setNotEligibleToImport
void setNotEligibleToImport()
Flag that this global value cannot be imported.
Definition:ModuleSummaryIndex.h:641
llvm::GlobalValueSummary::setCanAutoHide
void setCanAutoHide(bool CanAutoHide)
Definition:ModuleSummaryIndex.h:619
llvm::GlobalValueSummary::GlobalValueSummary
GlobalValueSummary(SummaryKind K, GVFlags Flags, SmallVectorImpl< ValueInfo > &&Refs)
Definition:ModuleSummaryIndex.h:567
llvm::GlobalValueSummary::isLive
bool isLive() const
Definition:ModuleSummaryIndex.h:611
llvm::GlobalValueSummary::linkage
GlobalValue::LinkageTypes linkage() const
Return linkage type recorded for this global value.
Definition:ModuleSummaryIndex.h:598
llvm::GlobalValueSummary::notEligibleToImport
bool notEligibleToImport() const
Return true if this global value can't be imported.
Definition:ModuleSummaryIndex.h:609
llvm::GlobalValueSummary::setImportKind
void setImportKind(ImportKind IK)
Definition:ModuleSummaryIndex.h:627
llvm::GlobalValueSummary::setOriginalName
void setOriginalName(GlobalValue::GUID Name)
Initialize the original name hash in this summary.
Definition:ModuleSummaryIndex.h:582
llvm::GlobalValueSummary::canAutoHide
bool canAutoHide() const
Definition:ModuleSummaryIndex.h:621
llvm::GlobalValue
Definition:GlobalValue.h:48
llvm::GlobalValue::getGUID
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition:Globals.cpp:75
llvm::GlobalValue::getGUID
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition:GlobalValue.h:596
llvm::GlobalValue::VisibilityTypes
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Definition:GlobalValue.h:66
llvm::GlobalValue::DefaultVisibility
@ DefaultVisibility
The GV is visible.
Definition:GlobalValue.h:67
llvm::GlobalValue::LinkageTypes
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition:GlobalValue.h:51
llvm::GlobalValue::AvailableExternallyLinkage
@ AvailableExternallyLinkage
Available for inspection, not emission.
Definition:GlobalValue.h:53
llvm::GlobalVarSummary
Global variable summary information to aid decisions and implementation of importing.
Definition:ModuleSummaryIndex.h:1144
llvm::GlobalVarSummary::setWriteOnly
void setWriteOnly(bool WO)
Definition:ModuleSummaryIndex.h:1193
llvm::GlobalVarSummary::isConstant
bool isConstant() const
Definition:ModuleSummaryIndex.h:1196
llvm::GlobalVarSummary::maybeWriteOnly
bool maybeWriteOnly() const
Definition:ModuleSummaryIndex.h:1195
llvm::GlobalVarSummary::setVCallVisibility
void setVCallVisibility(GlobalObject::VCallVisibility Vis)
Definition:ModuleSummaryIndex.h:1197
llvm::GlobalVarSummary::VarFlags
struct llvm::GlobalVarSummary::GVarFlags VarFlags
llvm::GlobalVarSummary::varflags
GVarFlags varflags() const
Definition:ModuleSummaryIndex.h:1191
llvm::GlobalVarSummary::maybeReadOnly
bool maybeReadOnly() const
Definition:ModuleSummaryIndex.h:1194
llvm::GlobalVarSummary::setReadOnly
void setReadOnly(bool RO)
Definition:ModuleSummaryIndex.h:1192
llvm::GlobalVarSummary::vTableFuncs
ArrayRef< VirtFuncOffset > vTableFuncs() const
Definition:ModuleSummaryIndex.h:1209
llvm::GlobalVarSummary::GlobalVarSummary
GlobalVarSummary(GVFlags Flags, GVarFlags VarFlags, SmallVectorImpl< ValueInfo > &&Refs)
Definition:ModuleSummaryIndex.h:1181
llvm::GlobalVarSummary::getVCallVisibility
GlobalObject::VCallVisibility getVCallVisibility() const
Definition:ModuleSummaryIndex.h:1200
llvm::GlobalVarSummary::classof
static bool classof(const GlobalValueSummary *GVS)
Check if this is a global variable summary.
Definition:ModuleSummaryIndex.h:1187
llvm::GlobalVarSummary::setVTableFuncs
void setVTableFuncs(VTableFuncList Funcs)
Definition:ModuleSummaryIndex.h:1204
llvm::ModuleSummaryIndex
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Definition:ModuleSummaryIndex.h:1345
llvm::ModuleSummaryIndex::withAttributePropagation
bool withAttributePropagation() const
Definition:ModuleSummaryIndex.h:1582
llvm::ModuleSummaryIndex::getOrInsertTypeIdSummary
TypeIdSummary & getOrInsertTypeIdSummary(StringRef TypeId)
Return an existing or new TypeIdSummary entry for TypeId.
Definition:ModuleSummaryIndex.h:1830
llvm::ModuleSummaryIndex::getTypeIdCompatibleVtableSummary
std::optional< TypeIdCompatibleVtableInfo > getTypeIdCompatibleVtableSummary(StringRef TypeId) const
For the given TypeId, this returns the TypeIdCompatibleVtableMap entry if present in the summary map.
Definition:ModuleSummaryIndex.h:1871
llvm::ModuleSummaryIndex::end
gvsummary_iterator end()
Definition:ModuleSummaryIndex.h:1488
llvm::ModuleSummaryIndex::addGlobalValueSummary
void addGlobalValueSummary(ValueInfo VI, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for the given ValueInfo.
Definition:ModuleSummaryIndex.h:1698
llvm::ModuleSummaryIndex::ModuleInfo
ModulePathStringTableTy::value_type ModuleInfo
Definition:ModuleSummaryIndex.h:1796
llvm::ModuleSummaryIndex::getBlockCount
uint64_t getBlockCount() const
Definition:ModuleSummaryIndex.h:1482
llvm::ModuleSummaryIndex::getOrInsertValueInfo
ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID)
Return a ValueInfo for GUID.
Definition:ModuleSummaryIndex.h:1639
llvm::ModuleSummaryIndex::withGlobalValueDeadStripping
bool withGlobalValueDeadStripping() const
Definition:ModuleSummaryIndex.h:1575
llvm::ModuleSummaryIndex::discoverNodes
static void discoverNodes(ValueInfo V, std::map< ValueInfo, bool > &FunctionHasParent)
Convenience function for doing a DFS on a ValueInfo.
Definition:ModuleSummaryIndex.h:1519
llvm::ModuleSummaryIndex::saveString
StringRef saveString(StringRef String)
Definition:ModuleSummaryIndex.h:1646
llvm::ModuleSummaryIndex::withWholeProgramVisibility
bool withWholeProgramVisibility() const
Definition:ModuleSummaryIndex.h:1590
llvm::ModuleSummaryIndex::typeIds
const TypeIdSummaryMapTy & typeIds() const
Definition:ModuleSummaryIndex.h:1825
llvm::ModuleSummaryIndex::getOriginalNameBeforePromote
static StringRef getOriginalNameBeforePromote(StringRef Name)
Helper to obtain the unpromoted name for a global value (or the original name if not promoted).
Definition:ModuleSummaryIndex.h:1791
llvm::ModuleSummaryIndex::getTypeIdSummary
const TypeIdSummary * getTypeIdSummary(StringRef TypeId) const
This returns either a pointer to the type id summary (if present in the summary map) or null (if not ...
Definition:ModuleSummaryIndex.h:1842
llvm::ModuleSummaryIndex::isGUIDLive
bool isGUIDLive(GlobalValue::GUID GUID) const
Definition:ModuleSummaryIndex.cpp:189
llvm::ModuleSummaryIndex::begin
gvsummary_iterator begin()
Definition:ModuleSummaryIndex.h:1486
llvm::ModuleSummaryIndex::end
const_gvsummary_iterator end() const
Definition:ModuleSummaryIndex.h:1489
llvm::ModuleSummaryIndex::isReadOnly
bool isReadOnly(const GlobalVarSummary *GVS) const
Definition:ModuleSummaryIndex.h:1593
llvm::ModuleSummaryIndex::setFlags
void setFlags(uint64_t Flags)
Definition:ModuleSummaryIndex.cpp:117
llvm::ModuleSummaryIndex::begin
const_gvsummary_iterator begin() const
Definition:ModuleSummaryIndex.h:1487
llvm::ModuleSummaryIndex::isWriteOnly
bool isWriteOnly(const GlobalVarSummary *GVS) const
Definition:ModuleSummaryIndex.h:1596
llvm::ModuleSummaryIndex::addBlockCount
void addBlockCount(uint64_t C)
Definition:ModuleSummaryIndex.h:1483
llvm::ModuleSummaryIndex::setPartiallySplitLTOUnits
void setPartiallySplitLTOUnits()
Definition:ModuleSummaryIndex.h:1617
llvm::ModuleSummaryIndex::stackIds
const std::vector< uint64_t > & stackIds() const
Definition:ModuleSummaryIndex.h:1492
llvm::ModuleSummaryIndex::findSummaryInModule
GlobalValueSummary * findSummaryInModule(GlobalValue::GUID ValueGUID, StringRef ModuleId) const
Find the summary for global GUID in module ModuleId, or nullptr if not found.
Definition:ModuleSummaryIndex.h:1735
llvm::ModuleSummaryIndex::releaseTemporaryMemory
void releaseTemporaryMemory()
Definition:ModuleSummaryIndex.h:1511
llvm::ModuleSummaryIndex::setBlockCount
void setBlockCount(uint64_t C)
Definition:ModuleSummaryIndex.h:1484
llvm::ModuleSummaryIndex::getValueInfo
ValueInfo getValueInfo(const GlobalValueSummaryMapTy::value_type &R) const
Return a ValueInfo for the index value_type (convenient when iterating index).
Definition:ModuleSummaryIndex.h:1628
llvm::ModuleSummaryIndex::getModuleHash
const ModuleHash & getModuleHash(const StringRef ModPath) const
Get the module SHA1 hash recorded for the given module path.
Definition:ModuleSummaryIndex.h:1766
llvm::ModuleSummaryIndex::getRegularLTOModuleName
static constexpr const char * getRegularLTOModuleName()
Definition:ModuleSummaryIndex.h:1473
llvm::ModuleSummaryIndex::setEnableSplitLTOUnit
void setEnableSplitLTOUnit()
Definition:ModuleSummaryIndex.h:1611
llvm::ModuleSummaryIndex::addGlobalValueSummary
void addGlobalValueSummary(StringRef ValueName, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for a value of the given name.
Definition:ModuleSummaryIndex.h:1691
llvm::ModuleSummaryIndex::ModuleSummaryIndex
ModuleSummaryIndex(bool HaveGVs, bool EnableSplitLTOUnit=false, bool UnifiedLTO=false)
Definition:ModuleSummaryIndex.h:1459
llvm::ModuleSummaryIndex::partiallySplitLTOUnits
bool partiallySplitLTOUnits() const
Definition:ModuleSummaryIndex.h:1616
llvm::ModuleSummaryIndex::collectDefinedFunctionsForModule
void collectDefinedFunctionsForModule(StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const
Collect for the given module the list of functions it defines (GUID -> Summary).
Definition:ModuleSummaryIndex.cpp:161
llvm::ModuleSummaryIndex::cfiFunctionDecls
const std::set< std::string, std::less<> > & cfiFunctionDecls() const
Definition:ModuleSummaryIndex.h:1680
llvm::ModuleSummaryIndex::typeIdCompatibleVtableMap
const auto & typeIdCompatibleVtableMap() const
Definition:ModuleSummaryIndex.h:1856
llvm::ModuleSummaryIndex::dumpSCCs
void dumpSCCs(raw_ostream &OS)
Print out strongly connected components for debugging.
Definition:ModuleSummaryIndex.cpp:378
llvm::ModuleSummaryIndex::isGlobalValueLive
bool isGlobalValueLive(const GlobalValueSummary *GVS) const
Definition:ModuleSummaryIndex.h:1621
llvm::ModuleSummaryIndex::enableSplitLTOUnit
bool enableSplitLTOUnit() const
Definition:ModuleSummaryIndex.h:1610
llvm::ModuleSummaryIndex::setWithSupportsHotColdNew
void setWithSupportsHotColdNew()
Definition:ModuleSummaryIndex.h:1601
llvm::ModuleSummaryIndex::getModule
const ModuleInfo * getModule(StringRef ModPath) const
Return module entry for module with the given ModPath.
Definition:ModuleSummaryIndex.h:1812
llvm::ModuleSummaryIndex::propagateAttributes
void propagateAttributes(const DenseSet< GlobalValue::GUID > &PreservedSymbols)
Do the access attribute and DSOLocal propagation in combined index.
Definition:ModuleSummaryIndex.cpp:259
llvm::ModuleSummaryIndex::haveGVs
bool haveGVs() const
Definition:ModuleSummaryIndex.h:1477
llvm::ModuleSummaryIndex::setSkipModuleByDistributedBackend
void setSkipModuleByDistributedBackend()
Definition:ModuleSummaryIndex.h:1606
llvm::ModuleSummaryIndex::cfiFunctionDefs
const std::set< std::string, std::less<> > & cfiFunctionDefs() const
Definition:ModuleSummaryIndex.h:1673
llvm::ModuleSummaryIndex::setWithAttributePropagation
void setWithAttributePropagation()
Definition:ModuleSummaryIndex.h:1583
llvm::ModuleSummaryIndex::modulePaths
const StringMap< ModuleHash > & modulePaths() const
Table of modules, containing module hash and id.
Definition:ModuleSummaryIndex.h:1758
llvm::ModuleSummaryIndex::withSupportsHotColdNew
bool withSupportsHotColdNew() const
Definition:ModuleSummaryIndex.h:1600
llvm::ModuleSummaryIndex::dump
void dump() const
Dump to stderr (for debugging).
Definition:AsmWriter.cpp:5356
llvm::ModuleSummaryIndex::addModule
ModuleInfo * addModule(StringRef ModPath, ModuleHash Hash=ModuleHash{{0}})
Add a new module with the given Hash, mapped to the given ModID, and return a reference to the module...
Definition:ModuleSummaryIndex.h:1800
llvm::ModuleSummaryIndex::size
size_t size() const
Definition:ModuleSummaryIndex.h:1490
llvm::ModuleSummaryIndex::collectDefinedGVSummariesPerModule
void collectDefinedGVSummariesPerModule(Map &ModuleToDefinedGVSummaries) const
Collect for each module the list of Summaries it defines (GUID -> Summary).
Definition:ModuleSummaryIndex.h:1887
llvm::ModuleSummaryIndex::addGlobalValueSummary
void addGlobalValueSummary(const GlobalValue &GV, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for a value.
Definition:ModuleSummaryIndex.h:1685
llvm::ModuleSummaryIndex::hasExportedFunctions
bool hasExportedFunctions(const Module &M) const
Check if the given Module has any functions available for exporting in the index.
Definition:ModuleSummaryIndex.h:1821
llvm::ModuleSummaryIndex::cfiFunctionDefs
std::set< std::string, std::less<> > & cfiFunctionDefs()
Definition:ModuleSummaryIndex.h:1670
llvm::ModuleSummaryIndex::getGlobalNameForLocal
static std::string getGlobalNameForLocal(StringRef Name, ModuleHash ModHash)
Convenience method for creating a promoted global name for the given value name of a local,...
Definition:ModuleSummaryIndex.h:1774
llvm::ModuleSummaryIndex::BitcodeSummaryVersion
static constexpr uint64_t BitcodeSummaryVersion
Definition:ModuleSummaryIndex.h:1470
llvm::ModuleSummaryIndex::withDSOLocalPropagation
bool withDSOLocalPropagation() const
Definition:ModuleSummaryIndex.h:1587
llvm::ModuleSummaryIndex::exportToDot
void exportToDot(raw_ostream &OS, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols) const
Export summary to dot file for GraphViz.
Definition:ModuleSummaryIndex.cpp:559
llvm::ModuleSummaryIndex::hasUnifiedLTO
bool hasUnifiedLTO() const
Definition:ModuleSummaryIndex.h:1613
llvm::ModuleSummaryIndex::hasParamAccess
bool hasParamAccess() const
Definition:ModuleSummaryIndex.h:1619
llvm::ModuleSummaryIndex::setWithDSOLocalPropagation
void setWithDSOLocalPropagation()
Definition:ModuleSummaryIndex.h:1588
llvm::ModuleSummaryIndex::getStackIdAtIndex
uint64_t getStackIdAtIndex(unsigned Index) const
Definition:ModuleSummaryIndex.h:1501
llvm::ModuleSummaryIndex::modulePaths
StringMap< ModuleHash > & modulePaths()
Table of modules, containing hash and id.
Definition:ModuleSummaryIndex.h:1763
llvm::ModuleSummaryIndex::print
void print(raw_ostream &OS, bool IsForDebug=false) const
Print to an output stream.
Definition:AsmWriter.cpp:5283
llvm::ModuleSummaryIndex::skipModuleByDistributedBackend
bool skipModuleByDistributedBackend() const
Definition:ModuleSummaryIndex.h:1603
llvm::ModuleSummaryIndex::setUnifiedLTO
void setUnifiedLTO()
Definition:ModuleSummaryIndex.h:1614
llvm::ModuleSummaryIndex::getOrInsertValueInfo
ValueInfo getOrInsertValueInfo(const GlobalValue *GV)
Return a ValueInfo for GV and mark it as belonging to GV.
Definition:ModuleSummaryIndex.h:1657
llvm::ModuleSummaryIndex::cfiFunctionDecls
std::set< std::string, std::less<> > & cfiFunctionDecls()
Definition:ModuleSummaryIndex.h:1677
llvm::ModuleSummaryIndex::findSummaryInModule
GlobalValueSummary * findSummaryInModule(ValueInfo VI, StringRef ModuleId) const
Find the summary for ValueInfo VI in module ModuleId, or nullptr if not found.
Definition:ModuleSummaryIndex.h:1721
llvm::ModuleSummaryIndex::getValueInfo
ValueInfo getValueInfo(GlobalValue::GUID GUID) const
Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
Definition:ModuleSummaryIndex.h:1633
llvm::ModuleSummaryIndex::getFlags
uint64_t getFlags() const
Definition:ModuleSummaryIndex.cpp:93
llvm::ModuleSummaryIndex::addOrGetStackIdIndex
unsigned addOrGetStackIdIndex(uint64_t StackId)
Definition:ModuleSummaryIndex.h:1494
llvm::ModuleSummaryIndex::getGUIDFromOriginalID
GlobalValue::GUID getGUIDFromOriginalID(GlobalValue::GUID OriginalID) const
Return the GUID for OriginalId in the OidGuidMap.
Definition:ModuleSummaryIndex.h:1665
llvm::ModuleSummaryIndex::getGlobalValueSummary
GlobalValueSummary * getGlobalValueSummary(const GlobalValue &GV, bool PerModuleIndex=true) const
Returns the first GlobalValueSummary for GV, asserting that there is only one if PerModuleIndex.
Definition:ModuleSummaryIndex.h:1745
llvm::ModuleSummaryIndex::setWithGlobalValueDeadStripping
void setWithGlobalValueDeadStripping()
Definition:ModuleSummaryIndex.h:1578
llvm::ModuleSummaryIndex::getModule
ModuleInfo * getModule(StringRef ModPath)
Return module entry for module with the given ModPath.
Definition:ModuleSummaryIndex.h:1805
llvm::ModuleSummaryIndex::getOrInsertValueInfo
ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID, StringRef Name)
Return a ValueInfo for GUID setting value Name.
Definition:ModuleSummaryIndex.h:1649
llvm::ModuleSummaryIndex::setWithWholeProgramVisibility
void setWithWholeProgramVisibility()
Definition:ModuleSummaryIndex.h:1591
llvm::ModuleSummaryIndex::canImportGlobalVar
bool canImportGlobalVar(const GlobalValueSummary *S, bool AnalyzeRefs) const
Checks if we can import global variable from another module.
Definition:ModuleSummaryIndex.cpp:329
llvm::ModuleSummaryIndex::getGlobalNameForLocal
static std::string getGlobalNameForLocal(StringRef Name, StringRef Suffix)
Definition:ModuleSummaryIndex.h:1780
llvm::ModuleSummaryIndex::addOriginalName
void addOriginalName(GlobalValue::GUID ValueGUID, GlobalValue::GUID OrigGUID)
Add an original name for the value of the given GUID.
Definition:ModuleSummaryIndex.h:1710
llvm::ModuleSummaryIndex::calculateCallGraphRoot
FunctionSummary calculateCallGraphRoot()
Definition:ModuleSummaryIndex.h:1551
llvm::ModuleSummaryIndex::getTypeIdSummary
TypeIdSummary * getTypeIdSummary(StringRef TypeId)
Definition:ModuleSummaryIndex.h:1850
llvm::ModuleSummaryIndex::getOrInsertTypeIdCompatibleVtableSummary
TypeIdCompatibleVtableInfo & getOrInsertTypeIdCompatibleVtableSummary(StringRef TypeId)
Return an existing or new TypeIdCompatibleVtableMap entry for TypeId.
Definition:ModuleSummaryIndex.h:1864
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
llvm::PointerIntPair
PointerIntPair - This class implements a pair of a pointer and small integer.
Definition:PointerIntPair.h:80
llvm::PointerIntPair::setPointer
void setPointer(PointerTy PtrVal) &
Definition:PointerIntPair.h:98
llvm::PointerIntPair::getInt
IntType getInt() const
Definition:PointerIntPair.h:96
llvm::PointerIntPair::setInt
void setInt(IntType IntVal) &
Definition:PointerIntPair.h:102
llvm::PointerIntPair::getPointer
PointerTy getPointer() const
Definition:PointerIntPair.h:94
llvm::ScaledNumber
Simple representation of a scaled number.
Definition:ScaledNumber.h:493
llvm::SmallString
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition:SmallString.h:26
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition:SmallVector.h:573
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVectorTemplateCommon::end
iterator end()
Definition:SmallVector.h:269
llvm::SmallVectorTemplateCommon::begin
iterator begin()
Definition:SmallVector.h:267
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StringMapEntry
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition:StringMapEntry.h:102
llvm::StringMap< ModuleHash >
llvm::StringMap::end
iterator end()
Definition:StringMap.h:220
llvm::StringMap::find
iterator find(StringRef Key)
Definition:StringMap.h:233
llvm::StringMap::count
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition:StringMap.h:276
llvm::StringMap::insert
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition:StringMap.h:308
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StringSaver
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition:StringSaver.h:21
llvm::StringSaver::save
StringRef save(const char *S)
Definition:StringSaver.h:30
llvm::UniqueStringSaver
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition:StringSaver.h:44
llvm::UniqueStringSaver::save
StringRef save(const char *S)
Definition:StringSaver.h:52
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition:Use.h:43
llvm::Value::hasName
bool hasName() const
Definition:Value.h:261
llvm::mapped_iterator
Definition:STLExtras.h:353
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition:raw_ostream.h:661
uint32_t
uint64_t
uint8_t
unsigned
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:ErrorHandling.h:143
false
Definition:StackSlotColoring.cpp:193
llvm::CallingConv::Cold
@ Cold
Attempts to make code in the caller as efficient as possible under the assumption that the call is no...
Definition:CallingConv.h:47
llvm::CallingConv::C
@ C
The default llvm calling convention, compatible with C.
Definition:CallingConv.h:34
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::gvsummary_iterator
GlobalValueSummaryMapTy::iterator gvsummary_iterator
Definition:ModuleSummaryIndex.h:1297
llvm::Offset
@ Offset
Definition:DWP.cpp:480
llvm::operator<
bool operator<(int64_t V1, const APSInt &V2)
Definition:APSInt.h:361
llvm::getHotnessName
const char * getHotnessName(CalleeInfo::HotnessType HT)
Definition:ModuleSummaryIndex.h:118
llvm::AllocationType
AllocationType
Definition:ModuleSummaryIndex.h:368
llvm::AllocationType::All
@ All
llvm::AllocationType::NotCold
@ NotCold
llvm::operator!=
bool operator!=(uint64_t V1, const APInt &V2)
Definition:APInt.h:2082
llvm::make_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
Definition:iterator_range.h:77
llvm::operator==
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
Definition:AddressRanges.h:153
llvm::VTableFuncList
std::vector< VirtFuncOffset > VTableFuncList
List of functions referenced by a particular vtable definition.
Definition:ModuleSummaryIndex.h:1133
llvm::MachineFunctionDataHotness::Hot
@ Hot
llvm::None
@ None
Definition:CodeGenData.h:106
llvm::GlobalValueSummaryList
std::vector< std::unique_ptr< GlobalValueSummary > > GlobalValueSummaryList
Definition:ModuleSummaryIndex.h:136
llvm::IRMemLocation::First
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
llvm::GVSummaryPtrSet
std::unordered_set< GlobalValueSummary * > GVSummaryPtrSet
A set of global value summary pointers.
Definition:ModuleSummaryIndex.h:1313
llvm::const_gvsummary_iterator
GlobalValueSummaryMapTy::const_iterator const_gvsummary_iterator
Type used for iterating through the global value summary map.
Definition:ModuleSummaryIndex.h:1296
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition:APFixedPoint.h:303
llvm::ModuleToSummariesForIndexTy
std::map< std::string, GVSummaryMapTy, std::less<> > ModuleToSummariesForIndexTy
Map of a module name to the GUIDs and summaries we will import from that module.
Definition:ModuleSummaryIndex.h:1310
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1873
llvm::HighlightColor::String
@ String
llvm::TypeIdSummaryMapTy
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).
Definition:ModuleSummaryIndex.h:1318
llvm::find_if
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
Definition:STLExtras.h:1766
llvm::ModuleHash
std::array< uint32_t, 5 > ModuleHash
160 bits SHA1
Definition:ModuleSummaryIndex.h:1293
llvm::GlobalValueSummaryMapTy
std::map< GlobalValue::GUID, GlobalValueSummaryInfo > GlobalValueSummaryMapTy
Map from global value GUID to corresponding summary structures.
Definition:ModuleSummaryIndex.h:176
llvm::TypeIdCompatibleVtableInfo
std::vector< TypeIdOffsetVtableInfo > TypeIdCompatibleVtableInfo
List of vtable definitions decorated by a particular type identifier, and their corresponding offsets...
Definition:ModuleSummaryIndex.h:1341
llvm::Guid
@ Guid
Definition:PGOCtxProfWriter.h:22
std
Implement std::hash so that hash_code can be used in STL containers.
Definition:BitVector.h:858
raw_ostream.h
N
#define N
llvm::AllocInfo
Summary of memprof metadata on allocations.
Definition:ModuleSummaryIndex.h:405
llvm::AllocInfo::AllocInfo
AllocInfo(std::vector< MIBInfo > MIBs)
Definition:ModuleSummaryIndex.h:427
llvm::AllocInfo::AllocInfo
AllocInfo(SmallVector< uint8_t > Versions, std::vector< MIBInfo > MIBs)
Definition:ModuleSummaryIndex.h:430
llvm::AllocInfo::ContextSizeInfos
std::vector< std::vector< ContextTotalSize > > ContextSizeInfos
Definition:ModuleSummaryIndex.h:425
llvm::AllocInfo::Versions
SmallVector< uint8_t > Versions
Definition:ModuleSummaryIndex.h:414
llvm::AllocInfo::MIBs
std::vector< MIBInfo > MIBs
Definition:ModuleSummaryIndex.h:417
llvm::CalleeInfo
Class to accumulate and hold information about a callee.
Definition:ModuleSummaryIndex.h:59
llvm::CalleeInfo::HotnessType
HotnessType
Definition:ModuleSummaryIndex.h:60
llvm::CalleeInfo::HotnessType::Cold
@ Cold
llvm::CalleeInfo::HotnessType::Critical
@ Critical
llvm::CalleeInfo::HotnessType::Hot
@ Hot
llvm::CalleeInfo::HotnessType::None
@ None
llvm::CalleeInfo::HotnessType::Unknown
@ Unknown
llvm::CalleeInfo::MaxRelBlockFreq
static constexpr uint64_t MaxRelBlockFreq
Definition:ModuleSummaryIndex.h:80
llvm::CalleeInfo::hasTailCall
bool hasTailCall() const
Definition:ModuleSummaryIndex.h:93
llvm::CalleeInfo::RelBlockFreq
uint32_t RelBlockFreq
Definition:ModuleSummaryIndex.h:78
llvm::CalleeInfo::updateHotness
void updateHotness(const HotnessType OtherHotness)
Definition:ModuleSummaryIndex.h:89
llvm::CalleeInfo::Hotness
uint32_t Hotness
Definition:ModuleSummaryIndex.h:70
llvm::CalleeInfo::HasTailCall
bool HasTailCall
Definition:ModuleSummaryIndex.h:73
llvm::CalleeInfo::CalleeInfo
CalleeInfo(HotnessType Hotness, bool HasTC, uint64_t RelBF)
Definition:ModuleSummaryIndex.h:85
llvm::CalleeInfo::getHotness
HotnessType getHotness() const
Definition:ModuleSummaryIndex.h:97
llvm::CalleeInfo::ScaleShift
static constexpr int32_t ScaleShift
Definition:ModuleSummaryIndex.h:79
llvm::CalleeInfo::setHasTailCall
void setHasTailCall(const bool HasTC)
Definition:ModuleSummaryIndex.h:95
llvm::CalleeInfo::updateRelBlockFreq
void updateRelBlockFreq(uint64_t BlockFreq, uint64_t EntryFreq)
Update RelBlockFreq from BlockFreq and EntryFreq.
Definition:ModuleSummaryIndex.h:104
llvm::CalleeInfo::CalleeInfo
CalleeInfo()
Definition:ModuleSummaryIndex.h:82
llvm::CalleeInfo::RelBlockFreqBits
static constexpr unsigned RelBlockFreqBits
The value stored in RelBlockFreq has to be interpreted as the digits of a scaled number with a scale ...
Definition:ModuleSummaryIndex.h:77
llvm::CallsiteInfo
Summary of memprof callsite metadata.
Definition:ModuleSummaryIndex.h:314
llvm::CallsiteInfo::StackIdIndices
SmallVector< unsigned > StackIdIndices
Definition:ModuleSummaryIndex.h:332
llvm::CallsiteInfo::Clones
SmallVector< unsigned > Clones
Definition:ModuleSummaryIndex.h:326
llvm::CallsiteInfo::Callee
ValueInfo Callee
Definition:ModuleSummaryIndex.h:316
llvm::CallsiteInfo::CallsiteInfo
CallsiteInfo(ValueInfo Callee, SmallVector< unsigned > StackIdIndices)
Definition:ModuleSummaryIndex.h:334
llvm::CallsiteInfo::CallsiteInfo
CallsiteInfo(ValueInfo Callee, SmallVector< unsigned > Clones, SmallVector< unsigned > StackIdIndices)
Definition:ModuleSummaryIndex.h:336
llvm::ContextTotalSize
Definition:ModuleSummaryIndex.h:308
llvm::ContextTotalSize::FullStackId
uint64_t FullStackId
Definition:ModuleSummaryIndex.h:309
llvm::ContextTotalSize::TotalSize
uint64_t TotalSize
Definition:ModuleSummaryIndex.h:310
llvm::DenseMapInfo< FunctionSummary::ConstVCall >::getEmptyKey
static FunctionSummary::ConstVCall getEmptyKey()
Definition:ModuleSummaryIndex.h:1104
llvm::DenseMapInfo< FunctionSummary::ConstVCall >::getTombstoneKey
static FunctionSummary::ConstVCall getTombstoneKey()
Definition:ModuleSummaryIndex.h:1108
llvm::DenseMapInfo< FunctionSummary::ConstVCall >::getHashValue
static unsigned getHashValue(FunctionSummary::ConstVCall I)
Definition:ModuleSummaryIndex.h:1118
llvm::DenseMapInfo< FunctionSummary::ConstVCall >::isEqual
static bool isEqual(FunctionSummary::ConstVCall L, FunctionSummary::ConstVCall R)
Definition:ModuleSummaryIndex.h:1112
llvm::DenseMapInfo< FunctionSummary::VFuncId >::getEmptyKey
static FunctionSummary::VFuncId getEmptyKey()
Definition:ModuleSummaryIndex.h:1090
llvm::DenseMapInfo< FunctionSummary::VFuncId >::isEqual
static bool isEqual(FunctionSummary::VFuncId L, FunctionSummary::VFuncId R)
Definition:ModuleSummaryIndex.h:1096
llvm::DenseMapInfo< FunctionSummary::VFuncId >::getTombstoneKey
static FunctionSummary::VFuncId getTombstoneKey()
Definition:ModuleSummaryIndex.h:1092
llvm::DenseMapInfo< FunctionSummary::VFuncId >::getHashValue
static unsigned getHashValue(FunctionSummary::VFuncId I)
Definition:ModuleSummaryIndex.h:1100
llvm::DenseMapInfo< ValueInfo >::isEqual
static bool isEqual(ValueInfo L, ValueInfo R)
Definition:ModuleSummaryIndex.h:296
llvm::DenseMapInfo< ValueInfo >::getEmptyKey
static ValueInfo getEmptyKey()
Definition:ModuleSummaryIndex.h:284
llvm::DenseMapInfo< ValueInfo >::getTombstoneKey
static ValueInfo getTombstoneKey()
Definition:ModuleSummaryIndex.h:288
llvm::DenseMapInfo< ValueInfo >::isSpecialKey
static bool isSpecialKey(ValueInfo V)
Definition:ModuleSummaryIndex.h:292
llvm::DenseMapInfo< ValueInfo >::getHashValue
static unsigned getHashValue(ValueInfo I)
Definition:ModuleSummaryIndex.h:302
llvm::DenseMapInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition:DenseMapInfo.h:52
llvm::FunctionSummary::ConstVCall
A specification for a virtual function call with all constant integer arguments.
Definition:ModuleSummaryIndex.h:744
llvm::FunctionSummary::ConstVCall::Args
std::vector< uint64_t > Args
Definition:ModuleSummaryIndex.h:746
llvm::FunctionSummary::ConstVCall::VFunc
VFuncId VFunc
Definition:ModuleSummaryIndex.h:745
llvm::FunctionSummary::FFlags
Flags specific to function summaries.
Definition:ModuleSummaryIndex.h:770
llvm::FunctionSummary::FFlags::anyFlagSet
bool anyFlagSet()
Definition:ModuleSummaryIndex.h:812
llvm::FunctionSummary::FFlags::NoRecurse
unsigned NoRecurse
Definition:ModuleSummaryIndex.h:775
llvm::FunctionSummary::FFlags::NoInline
unsigned NoInline
Definition:ModuleSummaryIndex.h:779
llvm::FunctionSummary::FFlags::MayThrow
unsigned MayThrow
Definition:ModuleSummaryIndex.h:786
llvm::FunctionSummary::FFlags::operator&=
FFlags & operator&=(const FFlags &RHS)
Definition:ModuleSummaryIndex.h:798
llvm::FunctionSummary::FFlags::AlwaysInline
unsigned AlwaysInline
Definition:ModuleSummaryIndex.h:781
llvm::FunctionSummary::FFlags::ReadNone
unsigned ReadNone
Definition:ModuleSummaryIndex.h:773
llvm::FunctionSummary::FFlags::NoUnwind
unsigned NoUnwind
Definition:ModuleSummaryIndex.h:784
llvm::FunctionSummary::FFlags::ReturnDoesNotAlias
unsigned ReturnDoesNotAlias
Definition:ModuleSummaryIndex.h:776
llvm::FunctionSummary::FFlags::HasUnknownCall
unsigned HasUnknownCall
Definition:ModuleSummaryIndex.h:789
llvm::FunctionSummary::FFlags::ReadOnly
unsigned ReadOnly
Definition:ModuleSummaryIndex.h:774
llvm::FunctionSummary::FFlags::MustBeUnreachable
unsigned MustBeUnreachable
Definition:ModuleSummaryIndex.h:796
llvm::FunctionSummary::ParamAccess::Call
Describes the use of a value in a call instruction, specifying the call's target, the value's paramet...
Definition:ModuleSummaryIndex.h:845
llvm::FunctionSummary::ParamAccess::Call::Offsets
ConstantRange Offsets
Definition:ModuleSummaryIndex.h:848
llvm::FunctionSummary::ParamAccess::Call::Callee
ValueInfo Callee
Definition:ModuleSummaryIndex.h:847
llvm::FunctionSummary::ParamAccess::Call::Call
Call()=default
llvm::FunctionSummary::ParamAccess::Call::ParamNo
uint64_t ParamNo
Definition:ModuleSummaryIndex.h:846
llvm::FunctionSummary::ParamAccess::Call::Call
Call(uint64_t ParamNo, ValueInfo Callee, const ConstantRange &Offsets)
Definition:ModuleSummaryIndex.h:851
llvm::FunctionSummary::ParamAccess
Describes the uses of a parameter by the function.
Definition:ModuleSummaryIndex.h:839
llvm::FunctionSummary::ParamAccess::ParamAccess
ParamAccess(uint64_t ParamNo, const ConstantRange &Use)
Definition:ModuleSummaryIndex.h:868
llvm::FunctionSummary::ParamAccess::ParamNo
uint64_t ParamNo
Definition:ModuleSummaryIndex.h:855
llvm::FunctionSummary::ParamAccess::Calls
std::vector< Call > Calls
In the per-module summary, it summarizes the byte offset applied to each pointer parameter before pas...
Definition:ModuleSummaryIndex.h:865
llvm::FunctionSummary::ParamAccess::ParamAccess
ParamAccess()=default
llvm::FunctionSummary::ParamAccess::RangeWidth
static constexpr uint32_t RangeWidth
Definition:ModuleSummaryIndex.h:840
llvm::FunctionSummary::TypeIdInfo
All type identifier related information.
Definition:ModuleSummaryIndex.h:751
llvm::FunctionSummary::TypeIdInfo::TypeCheckedLoadConstVCalls
std::vector< ConstVCall > TypeCheckedLoadConstVCalls
Definition:ModuleSummaryIndex.h:766
llvm::FunctionSummary::TypeIdInfo::TypeCheckedLoadVCalls
std::vector< VFuncId > TypeCheckedLoadVCalls
Definition:ModuleSummaryIndex.h:760
llvm::FunctionSummary::TypeIdInfo::TypeTestAssumeConstVCalls
std::vector< ConstVCall > TypeTestAssumeConstVCalls
List of virtual calls made by this function using (respectively) llvm.assume(llvm....
Definition:ModuleSummaryIndex.h:765
llvm::FunctionSummary::TypeIdInfo::TypeTests
std::vector< GlobalValue::GUID > TypeTests
List of type identifiers used by this function in llvm.type.test intrinsics referenced by something o...
Definition:ModuleSummaryIndex.h:755
llvm::FunctionSummary::TypeIdInfo::TypeTestAssumeVCalls
std::vector< VFuncId > TypeTestAssumeVCalls
List of virtual calls made by this function using (respectively) llvm.assume(llvm....
Definition:ModuleSummaryIndex.h:760
llvm::FunctionSummary::VFuncId
An "identifier" for a virtual function.
Definition:ModuleSummaryIndex.h:736
llvm::FunctionSummary::VFuncId::GUID
GlobalValue::GUID GUID
Definition:ModuleSummaryIndex.h:737
llvm::FunctionSummary::VFuncId::Offset
uint64_t Offset
Definition:ModuleSummaryIndex.h:738
llvm::GlobalValueSummaryInfo
Definition:ModuleSummaryIndex.h:138
llvm::GlobalValueSummaryInfo::SummaryList
GlobalValueSummaryList SummaryList
List of global value summary structures for a particular value held in the GlobalValueMap.
Definition:ModuleSummaryIndex.h:166
llvm::GlobalValueSummaryInfo::GlobalValueSummaryInfo
GlobalValueSummaryInfo(bool HaveGVs)
Definition:ModuleSummaryIndex.h:654
llvm::GlobalValueSummaryInfo::U
union llvm::GlobalValueSummaryInfo::NameOrGV U
llvm::GlobalValueSummary::GVFlags
Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
Definition:ModuleSummaryIndex.h:484
llvm::GlobalValueSummary::GVFlags::GVFlags
GVFlags(GlobalValue::LinkageTypes Linkage, GlobalValue::VisibilityTypes Visibility, bool NotEligibleToImport, bool Live, bool IsLocal, bool CanAutoHide, ImportKind ImportType)
Convenience Constructors.
Definition:ModuleSummaryIndex.h:528
llvm::GlobalValueSummary::GVFlags::DSOLocal
unsigned DSOLocal
Indicates that the linker resolved the symbol to a definition from within the same linkage unit.
Definition:ModuleSummaryIndex.h:510
llvm::GlobalValueSummary::GVFlags::CanAutoHide
unsigned CanAutoHide
In the per-module summary, indicates that the global value is linkonce_odr and global unnamed addr (s...
Definition:ModuleSummaryIndex.h:521
llvm::GlobalValueSummary::GVFlags::ImportType
unsigned ImportType
This field is written by the ThinLTO indexing step to postlink combined summary.
Definition:ModuleSummaryIndex.h:525
llvm::GlobalValueSummary::GVFlags::NotEligibleToImport
unsigned NotEligibleToImport
Indicate if the global value cannot be imported (e.g.
Definition:ModuleSummaryIndex.h:499
llvm::GlobalValueSummary::GVFlags::Linkage
unsigned Linkage
The linkage type of the associated global value.
Definition:ModuleSummaryIndex.h:492
llvm::GlobalValueSummary::GVFlags::Visibility
unsigned Visibility
Indicates the visibility.
Definition:ModuleSummaryIndex.h:495
llvm::GlobalValueSummary::GVFlags::Live
unsigned Live
In per-module summary, indicate that the global value must be considered a live root for index-based ...
Definition:ModuleSummaryIndex.h:506
llvm::GlobalVarSummary::GVarFlags
Definition:ModuleSummaryIndex.h:1151
llvm::GlobalVarSummary::GVarFlags::VCallVisibility
unsigned VCallVisibility
Definition:ModuleSummaryIndex.h:1178
llvm::GlobalVarSummary::GVarFlags::GVarFlags
GVarFlags(bool ReadOnly, bool WriteOnly, bool Constant, GlobalObject::VCallVisibility Vis)
Definition:ModuleSummaryIndex.h:1152
llvm::GlobalVarSummary::GVarFlags::MaybeReadOnly
unsigned MaybeReadOnly
Definition:ModuleSummaryIndex.h:1162
llvm::GlobalVarSummary::GVarFlags::MaybeWriteOnly
unsigned MaybeWriteOnly
Definition:ModuleSummaryIndex.h:1166
llvm::GlobalVarSummary::GVarFlags::Constant
unsigned Constant
Definition:ModuleSummaryIndex.h:1175
llvm::GraphTraits< ModuleSummaryIndex * >::getEntryNode
static NodeRef getEntryNode(ModuleSummaryIndex *I)
Definition:ModuleSummaryIndex.h:1982
llvm::GraphTraits< ValueInfo >::valueInfoFromEdge
static NodeRef valueInfoFromEdge(FunctionSummary::EdgeTy &P)
Definition:ModuleSummaryIndex.h:1927
llvm::GraphTraits< ValueInfo >::NodeRef
ValueInfo NodeRef
Definition:ModuleSummaryIndex.h:1924
llvm::GraphTraits< ValueInfo >::child_begin
static ChildIteratorType child_begin(NodeRef N)
Definition:ModuleSummaryIndex.h:1939
llvm::GraphTraits< ValueInfo >::child_edge_begin
static ChildEdgeIteratorType child_edge_begin(NodeRef N)
Definition:ModuleSummaryIndex.h:1959
llvm::GraphTraits< ValueInfo >::edge_dest
static NodeRef edge_dest(EdgeRef E)
Definition:ModuleSummaryIndex.h:1977
llvm::GraphTraits< ValueInfo >::getEntryNode
static NodeRef getEntryNode(ValueInfo V)
Definition:ModuleSummaryIndex.h:1937
llvm::GraphTraits< ValueInfo >::child_end
static ChildIteratorType child_end(NodeRef N)
Definition:ModuleSummaryIndex.h:1949
llvm::GraphTraits< ValueInfo >::child_edge_end
static ChildEdgeIteratorType child_edge_end(NodeRef N)
Definition:ModuleSummaryIndex.h:1968
llvm::GraphTraits< ValueInfo >::EdgeRef
FunctionSummary::EdgeTy & EdgeRef
Definition:ModuleSummaryIndex.h:1925
llvm::GraphTraits
Definition:GraphTraits.h:38
llvm::MIBInfo
Summary of a single MIB in a memprof metadata on allocations.
Definition:ModuleSummaryIndex.h:377
llvm::MIBInfo::MIBInfo
MIBInfo(AllocationType AllocType, SmallVector< unsigned > StackIdIndices)
Definition:ModuleSummaryIndex.h:387
llvm::MIBInfo::AllocType
AllocationType AllocType
Definition:ModuleSummaryIndex.h:379
llvm::MIBInfo::StackIdIndices
SmallVector< unsigned > StackIdIndices
Definition:ModuleSummaryIndex.h:385
llvm::TypeIdOffsetVtableInfo
The following data structures summarize type metadata information.
Definition:ModuleSummaryIndex.h:1330
llvm::TypeIdOffsetVtableInfo::VTableVI
ValueInfo VTableVI
Definition:ModuleSummaryIndex.h:1335
llvm::TypeIdOffsetVtableInfo::TypeIdOffsetVtableInfo
TypeIdOffsetVtableInfo(uint64_t Offset, ValueInfo VI)
Definition:ModuleSummaryIndex.h:1331
llvm::TypeIdOffsetVtableInfo::AddressPointOffset
uint64_t AddressPointOffset
Definition:ModuleSummaryIndex.h:1334
llvm::TypeIdSummary
Definition:ModuleSummaryIndex.h:1284
llvm::TypeIdSummary::WPDRes
std::map< uint64_t, WholeProgramDevirtResolution > WPDRes
Mapping from byte offset to whole-program devirt resolution for that (typeid, byte offset) pair.
Definition:ModuleSummaryIndex.h:1289
llvm::TypeIdSummary::TTRes
TypeTestResolution TTRes
Definition:ModuleSummaryIndex.h:1285
llvm::TypeTestResolution
Definition:ModuleSummaryIndex.h:1216
llvm::TypeTestResolution::Kind
Kind
Specifies which kind of type check we should emit for this byte array.
Definition:ModuleSummaryIndex.h:1221
llvm::TypeTestResolution::Unknown
@ Unknown
Unknown (analysis not performed, don't lower)
Definition:ModuleSummaryIndex.h:1228
llvm::TypeTestResolution::Single
@ Single
Single element (last example in "Short Inline Bit Vectors")
Definition:ModuleSummaryIndex.h:1225
llvm::TypeTestResolution::Inline
@ Inline
Inlined bit vector ("Short Inline Bit Vectors")
Definition:ModuleSummaryIndex.h:1224
llvm::TypeTestResolution::Unsat
@ Unsat
Unsatisfiable type (i.e. no global has this type metadata)
Definition:ModuleSummaryIndex.h:1222
llvm::TypeTestResolution::AllOnes
@ AllOnes
All-ones bit vector ("Eliminating Bit Vector Checks for All-Ones Bit Vectors")
Definition:ModuleSummaryIndex.h:1226
llvm::TypeTestResolution::ByteArray
@ ByteArray
Test a byte array (first example)
Definition:ModuleSummaryIndex.h:1223
llvm::TypeTestResolution::SizeM1BitWidth
unsigned SizeM1BitWidth
Range of size-1 expressed as a bit width.
Definition:ModuleSummaryIndex.h:1234
llvm::TypeTestResolution::SizeM1
uint64_t SizeM1
Definition:ModuleSummaryIndex.h:1242
llvm::TypeTestResolution::TheKind
enum llvm::TypeTestResolution::Kind TheKind
llvm::TypeTestResolution::BitMask
uint8_t BitMask
Definition:ModuleSummaryIndex.h:1243
llvm::TypeTestResolution::AlignLog2
uint64_t AlignLog2
Definition:ModuleSummaryIndex.h:1241
llvm::TypeTestResolution::InlineBits
uint64_t InlineBits
Definition:ModuleSummaryIndex.h:1244
llvm::ValueInfo
Struct that holds a reference to a particular GUID in a global value summary.
Definition:ModuleSummaryIndex.h:180
llvm::ValueInfo::setReadOnly
void setReadOnly()
Definition:ModuleSummaryIndex.h:230
llvm::ValueInfo::setWriteOnly
void setWriteOnly()
Definition:ModuleSummaryIndex.h:236
llvm::ValueInfo::RefAndFlags
PointerIntPair< const GlobalValueSummaryMapTy::value_type *, 3, int > RefAndFlags
Definition:ModuleSummaryIndex.h:183
llvm::ValueInfo::getELFVisibility
GlobalValue::VisibilityTypes getELFVisibility() const
Returns the most constraining visibility among summaries.
Definition:ModuleSummaryIndex.cpp:43
llvm::ValueInfo::isValidAccessSpecifier
bool isValidAccessSpecifier() const
Definition:ModuleSummaryIndex.h:226
llvm::ValueInfo::getRef
const GlobalValueSummaryMapTy::value_type * getRef() const
Definition:ModuleSummaryIndex.h:241
llvm::ValueInfo::getSummaryList
ArrayRef< std::unique_ptr< GlobalValueSummary > > getSummaryList() const
Definition:ModuleSummaryIndex.h:199
llvm::ValueInfo::name
StringRef name() const
Definition:ModuleSummaryIndex.h:207
llvm::ValueInfo::isWriteOnly
bool isWriteOnly() const
Definition:ModuleSummaryIndex.h:218
llvm::ValueInfo::getValue
const GlobalValue * getValue() const
Definition:ModuleSummaryIndex.h:194
llvm::ValueInfo::hasName
bool hasName() const
Definition:ModuleSummaryIndex.h:205
llvm::ValueInfo::Flags
Flags
Definition:ModuleSummaryIndex.h:181
llvm::ValueInfo::WriteOnly
@ WriteOnly
Definition:ModuleSummaryIndex.h:181
llvm::ValueInfo::ReadOnly
@ ReadOnly
Definition:ModuleSummaryIndex.h:181
llvm::ValueInfo::HaveGV
@ HaveGV
Definition:ModuleSummaryIndex.h:181
llvm::ValueInfo::ValueInfo
ValueInfo(bool HaveGVs, const GlobalValueSummaryMapTy::value_type *R)
Definition:ModuleSummaryIndex.h:186
llvm::ValueInfo::isReadOnly
bool isReadOnly() const
Definition:ModuleSummaryIndex.h:214
llvm::ValueInfo::canAutoHide
bool canAutoHide() const
Checks if all copies are eligible for auto-hiding (have flag set).
Definition:ModuleSummaryIndex.cpp:68
llvm::ValueInfo::getAccessSpecifier
unsigned getAccessSpecifier() const
Definition:ModuleSummaryIndex.h:222
llvm::ValueInfo::ValueInfo
ValueInfo()=default
llvm::ValueInfo::isDSOLocal
bool isDSOLocal(bool WithDSOLocalPropagation=false) const
Checks if all summaries are DSO local (have the flag set).
Definition:ModuleSummaryIndex.cpp:55
llvm::ValueInfo::getGUID
GlobalValue::GUID getGUID() const
Definition:ModuleSummaryIndex.h:193
llvm::ValueInfo::haveGVs
bool haveGVs() const
Definition:ModuleSummaryIndex.h:213
llvm::VirtFuncOffset
The ValueInfo and offset for a function within a vtable definition initializer array.
Definition:ModuleSummaryIndex.h:1125
llvm::VirtFuncOffset::VTableOffset
uint64_t VTableOffset
Definition:ModuleSummaryIndex.h:1130
llvm::VirtFuncOffset::VirtFuncOffset
VirtFuncOffset(ValueInfo VI, uint64_t Offset)
Definition:ModuleSummaryIndex.h:1126
llvm::VirtFuncOffset::FuncVI
ValueInfo FuncVI
Definition:ModuleSummaryIndex.h:1129
llvm::WholeProgramDevirtResolution::ByArg
Definition:ModuleSummaryIndex.h:1258
llvm::WholeProgramDevirtResolution::ByArg::Kind
Kind
Definition:ModuleSummaryIndex.h:1259
llvm::WholeProgramDevirtResolution::ByArg::UniformRetVal
@ UniformRetVal
Uniform return value optimization.
Definition:ModuleSummaryIndex.h:1261
llvm::WholeProgramDevirtResolution::ByArg::VirtualConstProp
@ VirtualConstProp
Virtual constant propagation.
Definition:ModuleSummaryIndex.h:1263
llvm::WholeProgramDevirtResolution::ByArg::UniqueRetVal
@ UniqueRetVal
Unique return value optimization.
Definition:ModuleSummaryIndex.h:1262
llvm::WholeProgramDevirtResolution::ByArg::Indir
@ Indir
Just do a regular virtual call.
Definition:ModuleSummaryIndex.h:1260
llvm::WholeProgramDevirtResolution::ByArg::Bit
uint32_t Bit
Definition:ModuleSummaryIndex.h:1276
llvm::WholeProgramDevirtResolution::ByArg::Info
uint64_t Info
Additional information for the resolution:
Definition:ModuleSummaryIndex.h:1270
llvm::WholeProgramDevirtResolution::ByArg::TheKind
enum llvm::WholeProgramDevirtResolution::ByArg::Kind TheKind
llvm::WholeProgramDevirtResolution::ByArg::Byte
uint32_t Byte
Definition:ModuleSummaryIndex.h:1275
llvm::WholeProgramDevirtResolution
Definition:ModuleSummaryIndex.h:1247
llvm::WholeProgramDevirtResolution::TheKind
enum llvm::WholeProgramDevirtResolution::Kind TheKind
llvm::WholeProgramDevirtResolution::ResByArg
std::map< std::vector< uint64_t >, ByArg > ResByArg
Resolutions for calls with all constant integer arguments (excluding the first argument,...
Definition:ModuleSummaryIndex.h:1281
llvm::WholeProgramDevirtResolution::SingleImplName
std::string SingleImplName
Definition:ModuleSummaryIndex.h:1256
llvm::WholeProgramDevirtResolution::Kind
Kind
Definition:ModuleSummaryIndex.h:1248
llvm::WholeProgramDevirtResolution::SingleImpl
@ SingleImpl
Single implementation devirtualization.
Definition:ModuleSummaryIndex.h:1250
llvm::WholeProgramDevirtResolution::Indir
@ Indir
Just do a regular virtual call.
Definition:ModuleSummaryIndex.h:1249
llvm::WholeProgramDevirtResolution::BranchFunnel
@ BranchFunnel
When retpoline mitigation is enabled, use a branch funnel that is defined in the merged module.
Definition:ModuleSummaryIndex.h:1251
llvm::yaml::MappingTraits
Definition:ModuleSummaryIndex.h:54
llvm::GlobalValueSummaryInfo::NameOrGV
Definition:ModuleSummaryIndex.h:139
llvm::GlobalValueSummaryInfo::NameOrGV::GV
const GlobalValue * GV
The GlobalValue corresponding to this summary.
Definition:ModuleSummaryIndex.h:151
llvm::GlobalValueSummaryInfo::NameOrGV::Name
StringRef Name
Summary string representation.
Definition:ModuleSummaryIndex.h:158
llvm::GlobalValueSummaryInfo::NameOrGV::NameOrGV
NameOrGV(bool HaveGVs)
Definition:ModuleSummaryIndex.h:140

Generated on Sun Jul 20 2025 07:24:11 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp