LLVM  16.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"
34 #include <algorithm>
35 #include <array>
36 #include <cassert>
37 #include <cstddef>
38 #include <cstdint>
39 #include <map>
40 #include <memory>
41 #include <set>
42 #include <string>
43 #include <utility>
44 #include <vector>
45 
46 namespace llvm {
47 
48 template <class GraphType> struct GraphTraits;
49 
50 namespace yaml {
51 
52 template <typename T> struct MappingTraits;
53 
54 } // end namespace yaml
55 
56 /// Class to accumulate and hold information about a callee.
57 struct CalleeInfo {
58  enum class HotnessType : uint8_t {
59  Unknown = 0,
60  Cold = 1,
61  None = 2,
62  Hot = 3,
63  Critical = 4
64  };
65 
66  // The size of the bit-field might need to be adjusted if more values are
67  // added to HotnessType enum.
69 
70  /// The value stored in RelBlockFreq has to be interpreted as the digits of
71  /// a scaled number with a scale of \p -ScaleShift.
73  static constexpr int32_t ScaleShift = 8;
74  static constexpr uint64_t MaxRelBlockFreq = (1 << 29) - 1;
75 
77  : Hotness(static_cast<uint32_t>(HotnessType::Unknown)), RelBlockFreq(0) {}
79  : Hotness(static_cast<uint32_t>(Hotness)), RelBlockFreq(RelBF) {}
80 
81  void updateHotness(const HotnessType OtherHotness) {
82  Hotness = std::max(Hotness, static_cast<uint32_t>(OtherHotness));
83  }
84 
86 
87  /// Update \p RelBlockFreq from \p BlockFreq and \p EntryFreq
88  ///
89  /// BlockFreq is divided by EntryFreq and added to RelBlockFreq. To represent
90  /// fractional values, the result is represented as a fixed point number with
91  /// scale of -ScaleShift.
92  void updateRelBlockFreq(uint64_t BlockFreq, uint64_t EntryFreq) {
93  if (EntryFreq == 0)
94  return;
96  Scaled64 Temp(BlockFreq, ScaleShift);
97  Temp /= Scaled64::get(EntryFreq);
98 
99  uint64_t Sum =
100  SaturatingAdd<uint64_t>(Temp.toInt<uint64_t>(), RelBlockFreq);
101  Sum = std::min(Sum, uint64_t(MaxRelBlockFreq));
102  RelBlockFreq = static_cast<uint32_t>(Sum);
103  }
104 };
105 
106 inline const char *getHotnessName(CalleeInfo::HotnessType HT) {
107  switch (HT) {
109  return "unknown";
111  return "cold";
113  return "none";
115  return "hot";
117  return "critical";
118  }
119  llvm_unreachable("invalid hotness");
120 }
121 
122 class GlobalValueSummary;
123 
124 using GlobalValueSummaryList = std::vector<std::unique_ptr<GlobalValueSummary>>;
125 
126 struct alignas(8) GlobalValueSummaryInfo {
127  union NameOrGV {
128  NameOrGV(bool HaveGVs) {
129  if (HaveGVs)
130  GV = nullptr;
131  else
132  Name = "";
133  }
134 
135  /// The GlobalValue corresponding to this summary. This is only used in
136  /// per-module summaries and when the IR is available. E.g. when module
137  /// analysis is being run, or when parsing both the IR and the summary
138  /// from assembly.
139  const GlobalValue *GV;
140 
141  /// Summary string representation. This StringRef points to BC module
142  /// string table and is valid until module data is stored in memory.
143  /// This is guaranteed to happen until runThinLTOBackend function is
144  /// called, so it is safe to use this field during thin link. This field
145  /// is only valid if summary index was loaded from BC file.
147  } U;
148 
149  GlobalValueSummaryInfo(bool HaveGVs) : U(HaveGVs) {}
150 
151  /// List of global value summary structures for a particular value held
152  /// in the GlobalValueMap. Requires a vector in the case of multiple
153  /// COMDAT values of the same name.
155 };
156 
157 /// Map from global value GUID to corresponding summary structures. Use a
158 /// std::map rather than a DenseMap so that pointers to the map's value_type
159 /// (which are used by ValueInfo) are not invalidated by insertion. Also it will
160 /// likely incur less overhead, as the value type is not very small and the size
161 /// of the map is unknown, resulting in inefficiencies due to repeated
162 /// insertions and resizing.
164  std::map<GlobalValue::GUID, GlobalValueSummaryInfo>;
165 
166 /// Struct that holds a reference to a particular GUID in a global value
167 /// summary.
168 struct ValueInfo {
169  enum Flags { HaveGV = 1, ReadOnly = 2, WriteOnly = 4 };
172 
173  ValueInfo() = default;
174  ValueInfo(bool HaveGVs, const GlobalValueSummaryMapTy::value_type *R) {
176  RefAndFlags.setInt(HaveGVs);
177  }
178 
179  explicit operator bool() const { return getRef(); }
180 
181  GlobalValue::GUID getGUID() const { return getRef()->first; }
182  const GlobalValue *getValue() const {
183  assert(haveGVs());
184  return getRef()->second.U.GV;
185  }
186 
188  return getRef()->second.SummaryList;
189  }
190 
191  StringRef name() const {
192  return haveGVs() ? getRef()->second.U.GV->getName()
193  : getRef()->second.U.Name;
194  }
195 
196  bool haveGVs() const { return RefAndFlags.getInt() & HaveGV; }
197  bool isReadOnly() const {
199  return RefAndFlags.getInt() & ReadOnly;
200  }
201  bool isWriteOnly() const {
203  return RefAndFlags.getInt() & WriteOnly;
204  }
205  unsigned getAccessSpecifier() const {
207  return RefAndFlags.getInt() & (ReadOnly | WriteOnly);
208  }
209  bool isValidAccessSpecifier() const {
210  unsigned BadAccessMask = ReadOnly | WriteOnly;
211  return (RefAndFlags.getInt() & BadAccessMask) != BadAccessMask;
212  }
213  void setReadOnly() {
214  // We expect ro/wo attribute to set only once during
215  // ValueInfo lifetime.
216  assert(getAccessSpecifier() == 0);
218  }
219  void setWriteOnly() {
220  assert(getAccessSpecifier() == 0);
222  }
223 
224  const GlobalValueSummaryMapTy::value_type *getRef() const {
225  return RefAndFlags.getPointer();
226  }
227 
228  /// Returns the most constraining visibility among summaries. The
229  /// visibilities, ordered from least to most constraining, are: default,
230  /// protected and hidden.
232 
233  /// Checks if all summaries are DSO local (have the flag set). When DSOLocal
234  /// propagation has been done, set the parameter to enable fast check.
235  bool isDSOLocal(bool WithDSOLocalPropagation = false) const;
236 
237  /// Checks if all copies are eligible for auto-hiding (have flag set).
238  bool canAutoHide() const;
239 };
240 
242  OS << VI.getGUID();
243  if (!VI.name().empty())
244  OS << " (" << VI.name() << ")";
245  return OS;
246 }
247 
248 inline bool operator==(const ValueInfo &A, const ValueInfo &B) {
249  assert(A.getRef() && B.getRef() &&
250  "Need ValueInfo with non-null Ref for comparison");
251  return A.getRef() == B.getRef();
252 }
253 
254 inline bool operator!=(const ValueInfo &A, const ValueInfo &B) {
255  assert(A.getRef() && B.getRef() &&
256  "Need ValueInfo with non-null Ref for comparison");
257  return A.getRef() != B.getRef();
258 }
259 
260 inline bool operator<(const ValueInfo &A, const ValueInfo &B) {
261  assert(A.getRef() && B.getRef() &&
262  "Need ValueInfo with non-null Ref to compare GUIDs");
263  return A.getGUID() < B.getGUID();
264 }
265 
266 template <> struct DenseMapInfo<ValueInfo> {
267  static inline ValueInfo getEmptyKey() {
268  return ValueInfo(false, (GlobalValueSummaryMapTy::value_type *)-8);
269  }
270 
271  static inline ValueInfo getTombstoneKey() {
272  return ValueInfo(false, (GlobalValueSummaryMapTy::value_type *)-16);
273  }
274 
275  static inline bool isSpecialKey(ValueInfo V) {
276  return V == getTombstoneKey() || V == getEmptyKey();
277  }
278 
279  static bool isEqual(ValueInfo L, ValueInfo R) {
280  // We are not supposed to mix ValueInfo(s) with different HaveGVs flag
281  // in a same container.
282  assert(isSpecialKey(L) || isSpecialKey(R) || (L.haveGVs() == R.haveGVs()));
283  return L.getRef() == R.getRef();
284  }
285  static unsigned getHashValue(ValueInfo I) { return (uintptr_t)I.getRef(); }
286 };
287 
288 /// Summary of memprof callsite metadata.
289 struct CallsiteInfo {
290  // Actual callee function.
292 
293  // Used to record whole program analysis cloning decisions.
294  // The ThinLTO backend will need to create as many clones as there are entries
295  // in the vector (it is expected and should be confirmed that all such
296  // summaries in the same FunctionSummary have the same number of entries).
297  // Each index records version info for the corresponding clone of this
298  // function. The value is the callee clone it calls (becomes the appended
299  // suffix id). Index 0 is the original version, and a value of 0 calls the
300  // original callee.
302 
303  // Represents stack ids in this context, recorded as indices into the
304  // StackIds vector in the summary index, which in turn holds the full 64-bit
305  // stack ids. This reduces memory as there are in practice far fewer unique
306  // stack ids than stack id references.
308 
315 };
316 
317 // Allocation type assigned to an allocation reached by a given context.
318 // More can be added but initially this is just noncold and cold.
319 // Values should be powers of two so that they can be ORed, in particular to
320 // track allocations that have different behavior with different calling
321 // contexts.
322 enum class AllocationType : uint8_t { None = 0, NotCold = 1, Cold = 2 };
323 
324 /// Summary of a single MIB in a memprof metadata on allocations.
325 struct MIBInfo {
326  // The allocation type for this profiled context.
328 
329  // Represents stack ids in this context, recorded as indices into the
330  // StackIds vector in the summary index, which in turn holds the full 64-bit
331  // stack ids. This reduces memory as there are in practice far fewer unique
332  // stack ids than stack id references.
334 
337 };
338 
339 /// Summary of memprof metadata on allocations.
340 struct AllocInfo {
341  // Used to record whole program analysis cloning decisions.
342  // The ThinLTO backend will need to create as many clones as there are entries
343  // in the vector (it is expected and should be confirmed that all such
344  // summaries in the same FunctionSummary have the same number of entries).
345  // Each index records version info for the corresponding clone of this
346  // function. The value is the allocation type of the corresponding allocation.
347  // Index 0 is the original version. Before cloning, index 0 may have more than
348  // one allocation type.
350 
351  // Vector of MIBs in this memprof metadata.
352  std::vector<MIBInfo> MIBs;
353 
354  AllocInfo(std::vector<MIBInfo> MIBs) : MIBs(std::move(MIBs)) {
355  Versions.push_back(0);
356  }
358  : Versions(std::move(Versions)), MIBs(std::move(MIBs)) {}
359 };
360 
361 /// Function and variable summary information to aid decisions and
362 /// implementation of importing.
364 public:
365  /// Sububclass discriminator (for dyn_cast<> et al.)
367 
368  /// Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
369  struct GVFlags {
370  /// The linkage type of the associated global value.
371  ///
372  /// One use is to flag values that have local linkage types and need to
373  /// have module identifier appended before placing into the combined
374  /// index, to disambiguate from other values with the same name.
375  /// In the future this will be used to update and optimize linkage
376  /// types based on global summary-based analysis.
377  unsigned Linkage : 4;
378 
379  /// Indicates the visibility.
380  unsigned Visibility : 2;
381 
382  /// Indicate if the global value cannot be imported (e.g. it cannot
383  /// be renamed or references something that can't be renamed).
384  unsigned NotEligibleToImport : 1;
385 
386  /// In per-module summary, indicate that the global value must be considered
387  /// a live root for index-based liveness analysis. Used for special LLVM
388  /// values such as llvm.global_ctors that the linker does not know about.
389  ///
390  /// In combined summary, indicate that the global value is live.
391  unsigned Live : 1;
392 
393  /// Indicates that the linker resolved the symbol to a definition from
394  /// within the same linkage unit.
395  unsigned DSOLocal : 1;
396 
397  /// In the per-module summary, indicates that the global value is
398  /// linkonce_odr and global unnamed addr (so eligible for auto-hiding
399  /// via hidden visibility). In the combined summary, indicates that the
400  /// prevailing linkonce_odr copy can be auto-hidden via hidden visibility
401  /// when it is upgraded to weak_odr in the backend. This is legal when
402  /// all copies are eligible for auto-hiding (i.e. all copies were
403  /// linkonce_odr global unnamed addr. If any copy is not (e.g. it was
404  /// originally weak_odr, we cannot auto-hide the prevailing copy as it
405  /// means the symbol was externally visible.
406  unsigned CanAutoHide : 1;
407 
408  /// Convenience Constructors
411  bool NotEligibleToImport, bool Live, bool IsLocal,
412  bool CanAutoHide)
415  DSOLocal(IsLocal), CanAutoHide(CanAutoHide) {}
416  };
417 
418 private:
419  /// Kind of summary for use in dyn_cast<> et al.
420  SummaryKind Kind;
421 
422  GVFlags Flags;
423 
424  /// This is the hash of the name of the symbol in the original file. It is
425  /// identical to the GUID for global symbols, but differs for local since the
426  /// GUID includes the module level id in the hash.
427  GlobalValue::GUID OriginalName = 0;
428 
429  /// Path of module IR containing value's definition, used to locate
430  /// module during importing.
431  ///
432  /// This is only used during parsing of the combined index, or when
433  /// parsing the per-module index for creation of the combined summary index,
434  /// not during writing of the per-module index which doesn't contain a
435  /// module path string table.
436  StringRef ModulePath;
437 
438  /// List of values referenced by this global value's definition
439  /// (either by the initializer of a global variable, or referenced
440  /// from within a function). This does not include functions called, which
441  /// are listed in the derived FunctionSummary object.
442  std::vector<ValueInfo> RefEdgeList;
443 
444 protected:
445  GlobalValueSummary(SummaryKind K, GVFlags Flags, std::vector<ValueInfo> Refs)
446  : Kind(K), Flags(Flags), RefEdgeList(std::move(Refs)) {
447  assert((K != AliasKind || Refs.empty()) &&
448  "Expect no references for AliasSummary");
449  }
450 
451 public:
452  virtual ~GlobalValueSummary() = default;
453 
454  /// Returns the hash of the original name, it is identical to the GUID for
455  /// externally visible symbols, but not for local ones.
456  GlobalValue::GUID getOriginalName() const { return OriginalName; }
457 
458  /// Initialize the original name hash in this summary.
459  void setOriginalName(GlobalValue::GUID Name) { OriginalName = Name; }
460 
461  /// Which kind of summary subclass this is.
462  SummaryKind getSummaryKind() const { return Kind; }
463 
464  /// Set the path to the module containing this function, for use in
465  /// the combined index.
466  void setModulePath(StringRef ModPath) { ModulePath = ModPath; }
467 
468  /// Get the path to the module containing this function.
469  StringRef modulePath() const { return ModulePath; }
470 
471  /// Get the flags for this GlobalValue (see \p struct GVFlags).
472  GVFlags flags() const { return Flags; }
473 
474  /// Return linkage type recorded for this global value.
476  return static_cast<GlobalValue::LinkageTypes>(Flags.Linkage);
477  }
478 
479  /// Sets the linkage to the value determined by global summary-based
480  /// optimization. Will be applied in the ThinLTO backends.
482  Flags.Linkage = Linkage;
483  }
484 
485  /// Return true if this global value can't be imported.
486  bool notEligibleToImport() const { return Flags.NotEligibleToImport; }
487 
488  bool isLive() const { return Flags.Live; }
489 
490  void setLive(bool Live) { Flags.Live = Live; }
491 
492  void setDSOLocal(bool Local) { Flags.DSOLocal = Local; }
493 
494  bool isDSOLocal() const { return Flags.DSOLocal; }
495 
496  void setCanAutoHide(bool CanAutoHide) { Flags.CanAutoHide = CanAutoHide; }
497 
498  bool canAutoHide() const { return Flags.CanAutoHide; }
499 
501  return (GlobalValue::VisibilityTypes)Flags.Visibility;
502  }
504  Flags.Visibility = (unsigned)Vis;
505  }
506 
507  /// Flag that this global value cannot be imported.
508  void setNotEligibleToImport() { Flags.NotEligibleToImport = true; }
509 
510  /// Return the list of values referenced by this global value definition.
511  ArrayRef<ValueInfo> refs() const { return RefEdgeList; }
512 
513  /// If this is an alias summary, returns the summary of the aliased object (a
514  /// global variable or function), otherwise returns itself.
516  const GlobalValueSummary *getBaseObject() const;
517 
518  friend class ModuleSummaryIndex;
519 };
520 
521 /// Alias summary information.
523  ValueInfo AliaseeValueInfo;
524 
525  /// This is the Aliasee in the same module as alias (could get from VI, trades
526  /// memory for time). Note that this pointer may be null (and the value info
527  /// empty) when we have a distributed index where the alias is being imported
528  /// (as a copy of the aliasee), but the aliasee is not.
529  GlobalValueSummary *AliaseeSummary;
530 
531 public:
534  AliaseeSummary(nullptr) {}
535 
536  /// Check if this is an alias summary.
537  static bool classof(const GlobalValueSummary *GVS) {
538  return GVS->getSummaryKind() == AliasKind;
539  }
540 
541  void setAliasee(ValueInfo &AliaseeVI, GlobalValueSummary *Aliasee) {
542  AliaseeValueInfo = AliaseeVI;
543  AliaseeSummary = Aliasee;
544  }
545 
546  bool hasAliasee() const {
547  assert(!!AliaseeSummary == (AliaseeValueInfo &&
548  !AliaseeValueInfo.getSummaryList().empty()) &&
549  "Expect to have both aliasee summary and summary list or neither");
550  return !!AliaseeSummary;
551  }
552 
554  assert(AliaseeSummary && "Unexpected missing aliasee summary");
555  return *AliaseeSummary;
556  }
557 
559  return const_cast<GlobalValueSummary &>(
560  static_cast<const AliasSummary *>(this)->getAliasee());
561  }
563  assert(AliaseeValueInfo && "Unexpected missing aliasee");
564  return AliaseeValueInfo;
565  }
567  assert(AliaseeValueInfo && "Unexpected missing aliasee");
568  return AliaseeValueInfo.getGUID();
569  }
570 };
571 
573  if (auto *AS = dyn_cast<AliasSummary>(this))
574  return &AS->getAliasee();
575  return this;
576 }
577 
579  if (auto *AS = dyn_cast<AliasSummary>(this))
580  return &AS->getAliasee();
581  return this;
582 }
583 
584 /// Function summary information to aid decisions and implementation of
585 /// importing.
587 public:
588  /// <CalleeValueInfo, CalleeInfo> call edge pair.
589  using EdgeTy = std::pair<ValueInfo, CalleeInfo>;
590 
591  /// Types for -force-summary-edges-cold debugging option.
592  enum ForceSummaryHotnessType : unsigned {
596  };
597 
598  /// An "identifier" for a virtual function. This contains the type identifier
599  /// represented as a GUID and the offset from the address point to the virtual
600  /// function pointer, where "address point" is as defined in the Itanium ABI:
601  /// https://itanium-cxx-abi.github.io/cxx-abi/abi.html#vtable-general
602  struct VFuncId {
605  };
606 
607  /// A specification for a virtual function call with all constant integer
608  /// arguments. This is used to perform virtual constant propagation on the
609  /// summary.
610  struct ConstVCall {
612  std::vector<uint64_t> Args;
613  };
614 
615  /// All type identifier related information. Because these fields are
616  /// relatively uncommon we only allocate space for them if necessary.
617  struct TypeIdInfo {
618  /// List of type identifiers used by this function in llvm.type.test
619  /// intrinsics referenced by something other than an llvm.assume intrinsic,
620  /// represented as GUIDs.
621  std::vector<GlobalValue::GUID> TypeTests;
622 
623  /// List of virtual calls made by this function using (respectively)
624  /// llvm.assume(llvm.type.test) or llvm.type.checked.load intrinsics that do
625  /// not have all constant integer arguments.
627 
628  /// List of virtual calls made by this function using (respectively)
629  /// llvm.assume(llvm.type.test) or llvm.type.checked.load intrinsics with
630  /// all constant integer arguments.
631  std::vector<ConstVCall> TypeTestAssumeConstVCalls,
633  };
634 
635  /// Flags specific to function summaries.
636  struct FFlags {
637  // Function attribute flags. Used to track if a function accesses memory,
638  // recurses or aliases.
639  unsigned ReadNone : 1;
640  unsigned ReadOnly : 1;
641  unsigned NoRecurse : 1;
642  unsigned ReturnDoesNotAlias : 1;
643 
644  // Indicate if the global value cannot be inlined.
645  unsigned NoInline : 1;
646  // Indicate if function should be always inlined.
647  unsigned AlwaysInline : 1;
648  // Indicate if function never raises an exception. Can be modified during
649  // thinlink function attribute propagation
650  unsigned NoUnwind : 1;
651  // Indicate if function contains instructions that mayThrow
652  unsigned MayThrow : 1;
653 
654  // If there are calls to unknown targets (e.g. indirect)
655  unsigned HasUnknownCall : 1;
656 
657  // Indicate if a function must be an unreachable function.
658  //
659  // This bit is sufficient but not necessary;
660  // if this bit is on, the function must be regarded as unreachable;
661  // if this bit is off, the function might be reachable or unreachable.
662  unsigned MustBeUnreachable : 1;
663 
665  this->ReadNone &= RHS.ReadNone;
666  this->ReadOnly &= RHS.ReadOnly;
667  this->NoRecurse &= RHS.NoRecurse;
669  this->NoInline &= RHS.NoInline;
670  this->AlwaysInline &= RHS.AlwaysInline;
671  this->NoUnwind &= RHS.NoUnwind;
672  this->MayThrow &= RHS.MayThrow;
673  this->HasUnknownCall &= RHS.HasUnknownCall;
675  return *this;
676  }
677 
678  bool anyFlagSet() {
679  return this->ReadNone | this->ReadOnly | this->NoRecurse |
680  this->ReturnDoesNotAlias | this->NoInline | this->AlwaysInline |
681  this->NoUnwind | this->MayThrow | this->HasUnknownCall |
682  this->MustBeUnreachable;
683  }
684 
685  operator std::string() {
686  std::string Output;
687  raw_string_ostream OS(Output);
688  OS << "funcFlags: (";
689  OS << "readNone: " << this->ReadNone;
690  OS << ", readOnly: " << this->ReadOnly;
691  OS << ", noRecurse: " << this->NoRecurse;
692  OS << ", returnDoesNotAlias: " << this->ReturnDoesNotAlias;
693  OS << ", noInline: " << this->NoInline;
694  OS << ", alwaysInline: " << this->AlwaysInline;
695  OS << ", noUnwind: " << this->NoUnwind;
696  OS << ", mayThrow: " << this->MayThrow;
697  OS << ", hasUnknownCall: " << this->HasUnknownCall;
698  OS << ", mustBeUnreachable: " << this->MustBeUnreachable;
699  OS << ")";
700  return OS.str();
701  }
702  };
703 
704  /// Describes the uses of a parameter by the function.
705  struct ParamAccess {
706  static constexpr uint32_t RangeWidth = 64;
707 
708  /// Describes the use of a value in a call instruction, specifying the
709  /// call's target, the value's parameter number, and the possible range of
710  /// offsets from the beginning of the value that are passed.
711  struct Call {
714  ConstantRange Offsets{/*BitWidth=*/RangeWidth, /*isFullSet=*/true};
715 
716  Call() = default;
719  };
720 
722  /// The range contains byte offsets from the parameter pointer which
723  /// accessed by the function. In the per-module summary, it only includes
724  /// accesses made by the function instructions. In the combined summary, it
725  /// also includes accesses by nested function calls.
726  ConstantRange Use{/*BitWidth=*/RangeWidth, /*isFullSet=*/true};
727  /// In the per-module summary, it summarizes the byte offset applied to each
728  /// pointer parameter before passing to each corresponding callee.
729  /// In the combined summary, it's empty and information is propagated by
730  /// inter-procedural analysis and applied to the Use field.
731  std::vector<Call> Calls;
732 
733  ParamAccess() = default;
735  : ParamNo(ParamNo), Use(Use) {}
736  };
737 
738  /// Create an empty FunctionSummary (with specified call edges).
739  /// Used to represent external nodes and the dummy root node.
740  static FunctionSummary
741  makeDummyFunctionSummary(std::vector<FunctionSummary::EdgeTy> Edges) {
742  return FunctionSummary(
744  GlobalValue::LinkageTypes::AvailableExternallyLinkage,
746  /*NotEligibleToImport=*/true, /*Live=*/true, /*IsLocal=*/false,
747  /*CanAutoHide=*/false),
748  /*NumInsts=*/0, FunctionSummary::FFlags{}, /*EntryCount=*/0,
749  std::vector<ValueInfo>(), std::move(Edges),
750  std::vector<GlobalValue::GUID>(),
751  std::vector<FunctionSummary::VFuncId>(),
752  std::vector<FunctionSummary::VFuncId>(),
753  std::vector<FunctionSummary::ConstVCall>(),
754  std::vector<FunctionSummary::ConstVCall>(),
755  std::vector<FunctionSummary::ParamAccess>(),
756  std::vector<CallsiteInfo>(), std::vector<AllocInfo>());
757  }
758 
759  /// A dummy node to reference external functions that aren't in the index
761 
762 private:
763  /// Number of instructions (ignoring debug instructions, e.g.) computed
764  /// during the initial compile step when the summary index is first built.
765  unsigned InstCount;
766 
767  /// Function summary specific flags.
768  FFlags FunFlags;
769 
770  /// The synthesized entry count of the function.
771  /// This is only populated during ThinLink phase and remains unused while
772  /// generating per-module summaries.
773  uint64_t EntryCount = 0;
774 
775  /// List of <CalleeValueInfo, CalleeInfo> call edge pairs from this function.
776  std::vector<EdgeTy> CallGraphEdgeList;
777 
778  std::unique_ptr<TypeIdInfo> TIdInfo;
779 
780  /// Uses for every parameter to this function.
781  using ParamAccessesTy = std::vector<ParamAccess>;
782  std::unique_ptr<ParamAccessesTy> ParamAccesses;
783 
784  /// Optional list of memprof callsite metadata summaries. The correspondence
785  /// between the callsite summary and the callsites in the function is implied
786  /// by the order in the vector (and can be validated by comparing the stack
787  /// ids in the CallsiteInfo to those in the instruction callsite metadata).
788  /// As a memory savings optimization, we only create these for the prevailing
789  /// copy of a symbol when creating the combined index during LTO.
790  using CallsitesTy = std::vector<CallsiteInfo>;
791  std::unique_ptr<CallsitesTy> Callsites;
792 
793  /// Optional list of allocation memprof metadata summaries. The correspondence
794  /// between the alloc memprof summary and the allocation callsites in the
795  /// function is implied by the order in the vector (and can be validated by
796  /// comparing the stack ids in the AllocInfo to those in the instruction
797  /// memprof metadata).
798  /// As a memory savings optimization, we only create these for the prevailing
799  /// copy of a symbol when creating the combined index during LTO.
800  using AllocsTy = std::vector<AllocInfo>;
801  std::unique_ptr<AllocsTy> Allocs;
802 
803 public:
804  FunctionSummary(GVFlags Flags, unsigned NumInsts, FFlags FunFlags,
805  uint64_t EntryCount, std::vector<ValueInfo> Refs,
806  std::vector<EdgeTy> CGEdges,
807  std::vector<GlobalValue::GUID> TypeTests,
808  std::vector<VFuncId> TypeTestAssumeVCalls,
809  std::vector<VFuncId> TypeCheckedLoadVCalls,
810  std::vector<ConstVCall> TypeTestAssumeConstVCalls,
811  std::vector<ConstVCall> TypeCheckedLoadConstVCalls,
812  std::vector<ParamAccess> Params, CallsitesTy CallsiteList,
813  AllocsTy AllocList)
814  : GlobalValueSummary(FunctionKind, Flags, std::move(Refs)),
815  InstCount(NumInsts), FunFlags(FunFlags), EntryCount(EntryCount),
816  CallGraphEdgeList(std::move(CGEdges)) {
817  if (!TypeTests.empty() || !TypeTestAssumeVCalls.empty() ||
818  !TypeCheckedLoadVCalls.empty() || !TypeTestAssumeConstVCalls.empty() ||
819  !TypeCheckedLoadConstVCalls.empty())
820  TIdInfo = std::make_unique<TypeIdInfo>(
821  TypeIdInfo{std::move(TypeTests), std::move(TypeTestAssumeVCalls),
822  std::move(TypeCheckedLoadVCalls),
823  std::move(TypeTestAssumeConstVCalls),
824  std::move(TypeCheckedLoadConstVCalls)});
825  if (!Params.empty())
826  ParamAccesses = std::make_unique<ParamAccessesTy>(std::move(Params));
827  if (!CallsiteList.empty())
828  Callsites = std::make_unique<CallsitesTy>(std::move(CallsiteList));
829  if (!AllocList.empty())
830  Allocs = std::make_unique<AllocsTy>(std::move(AllocList));
831  }
832  // Gets the number of readonly and writeonly refs in RefEdgeList
833  std::pair<unsigned, unsigned> specialRefCounts() const;
834 
835  /// Check if this is a function summary.
836  static bool classof(const GlobalValueSummary *GVS) {
837  return GVS->getSummaryKind() == FunctionKind;
838  }
839 
840  /// Get function summary flags.
841  FFlags fflags() const { return FunFlags; }
842 
843  void setNoRecurse() { FunFlags.NoRecurse = true; }
844 
845  void setNoUnwind() { FunFlags.NoUnwind = true; }
846 
847  /// Get the instruction count recorded for this function.
848  unsigned instCount() const { return InstCount; }
849 
850  /// Get the synthetic entry count for this function.
851  uint64_t entryCount() const { return EntryCount; }
852 
853  /// Set the synthetic entry count for this function.
854  void setEntryCount(uint64_t EC) { EntryCount = EC; }
855 
856  /// Return the list of <CalleeValueInfo, CalleeInfo> pairs.
857  ArrayRef<EdgeTy> calls() const { return CallGraphEdgeList; }
858 
859  std::vector<EdgeTy> &mutableCalls() { return CallGraphEdgeList; }
860 
861  void addCall(EdgeTy E) { CallGraphEdgeList.push_back(E); }
862 
863  /// Returns the list of type identifiers used by this function in
864  /// llvm.type.test intrinsics other than by an llvm.assume intrinsic,
865  /// represented as GUIDs.
867  if (TIdInfo)
868  return TIdInfo->TypeTests;
869  return {};
870  }
871 
872  /// Returns the list of virtual calls made by this function using
873  /// llvm.assume(llvm.type.test) intrinsics that do not have all constant
874  /// integer arguments.
876  if (TIdInfo)
877  return TIdInfo->TypeTestAssumeVCalls;
878  return {};
879  }
880 
881  /// Returns the list of virtual calls made by this function using
882  /// llvm.type.checked.load intrinsics that do not have all constant integer
883  /// arguments.
885  if (TIdInfo)
886  return TIdInfo->TypeCheckedLoadVCalls;
887  return {};
888  }
889 
890  /// Returns the list of virtual calls made by this function using
891  /// llvm.assume(llvm.type.test) intrinsics with all constant integer
892  /// arguments.
894  if (TIdInfo)
895  return TIdInfo->TypeTestAssumeConstVCalls;
896  return {};
897  }
898 
899  /// Returns the list of virtual calls made by this function using
900  /// llvm.type.checked.load intrinsics with all constant integer arguments.
902  if (TIdInfo)
903  return TIdInfo->TypeCheckedLoadConstVCalls;
904  return {};
905  }
906 
907  /// Returns the list of known uses of pointer parameters.
909  if (ParamAccesses)
910  return *ParamAccesses;
911  return {};
912  }
913 
914  /// Sets the list of known uses of pointer parameters.
915  void setParamAccesses(std::vector<ParamAccess> NewParams) {
916  if (NewParams.empty())
917  ParamAccesses.reset();
918  else if (ParamAccesses)
919  *ParamAccesses = std::move(NewParams);
920  else
921  ParamAccesses = std::make_unique<ParamAccessesTy>(std::move(NewParams));
922  }
923 
924  /// Add a type test to the summary. This is used by WholeProgramDevirt if we
925  /// were unable to devirtualize a checked call.
927  if (!TIdInfo)
928  TIdInfo = std::make_unique<TypeIdInfo>();
929  TIdInfo->TypeTests.push_back(Guid);
930  }
931 
932  const TypeIdInfo *getTypeIdInfo() const { return TIdInfo.get(); };
933 
935  if (Callsites)
936  return *Callsites;
937  return {};
938  }
939 
941  if (Allocs)
942  return *Allocs;
943  return {};
944  }
945 
946  friend struct GraphTraits<ValueInfo>;
947 };
948 
949 template <> struct DenseMapInfo<FunctionSummary::VFuncId> {
950  static FunctionSummary::VFuncId getEmptyKey() { return {0, uint64_t(-1)}; }
951 
953  return {0, uint64_t(-2)};
954  }
955 
957  return L.GUID == R.GUID && L.Offset == R.Offset;
958  }
959 
960  static unsigned getHashValue(FunctionSummary::VFuncId I) { return I.GUID; }
961 };
962 
963 template <> struct DenseMapInfo<FunctionSummary::ConstVCall> {
965  return {{0, uint64_t(-1)}, {}};
966  }
967 
969  return {{0, uint64_t(-2)}, {}};
970  }
971 
975  L.Args == R.Args;
976  }
977 
979  return I.VFunc.GUID;
980  }
981 };
982 
983 /// The ValueInfo and offset for a function within a vtable definition
984 /// initializer array.
987  : FuncVI(VI), VTableOffset(Offset) {}
988 
991 };
992 /// List of functions referenced by a particular vtable definition.
993 using VTableFuncList = std::vector<VirtFuncOffset>;
994 
995 /// Global variable summary information to aid decisions and
996 /// implementation of importing.
997 ///
998 /// Global variable summary has two extra flag, telling if it is
999 /// readonly or writeonly. Both readonly and writeonly variables
1000 /// can be optimized in the backed: readonly variables can be
1001 /// const-folded, while writeonly vars can be completely eliminated
1002 /// together with corresponding stores. We let both things happen
1003 /// by means of internalizing such variables after ThinLTO import.
1005 private:
1006  /// For vtable definitions this holds the list of functions and
1007  /// their corresponding offsets within the initializer array.
1008  std::unique_ptr<VTableFuncList> VTableFuncs;
1009 
1010 public:
1011  struct GVarFlags {
1012  GVarFlags(bool ReadOnly, bool WriteOnly, bool Constant,
1014  : MaybeReadOnly(ReadOnly), MaybeWriteOnly(WriteOnly),
1016 
1017  // If true indicates that this global variable might be accessed
1018  // purely by non-volatile load instructions. This in turn means
1019  // it can be internalized in source and destination modules during
1020  // thin LTO import because it neither modified nor its address
1021  // is taken.
1022  unsigned MaybeReadOnly : 1;
1023  // If true indicates that variable is possibly only written to, so
1024  // its value isn't loaded and its address isn't taken anywhere.
1025  // False, when 'Constant' attribute is set.
1026  unsigned MaybeWriteOnly : 1;
1027  // Indicates that value is a compile-time constant. Global variable
1028  // can be 'Constant' while not being 'ReadOnly' on several occasions:
1029  // - it is volatile, (e.g mapped device address)
1030  // - its address is taken, meaning that unlike 'ReadOnly' vars we can't
1031  // internalize it.
1032  // Constant variables are always imported thus giving compiler an
1033  // opportunity to make some extra optimizations. Readonly constants
1034  // are also internalized.
1035  unsigned Constant : 1;
1036  // Set from metadata on vtable definitions during the module summary
1037  // analysis.
1038  unsigned VCallVisibility : 2;
1039  } VarFlags;
1040 
1042  std::vector<ValueInfo> Refs)
1043  : GlobalValueSummary(GlobalVarKind, Flags, std::move(Refs)),
1044  VarFlags(VarFlags) {}
1045 
1046  /// Check if this is a global variable summary.
1047  static bool classof(const GlobalValueSummary *GVS) {
1048  return GVS->getSummaryKind() == GlobalVarKind;
1049  }
1050 
1051  GVarFlags varflags() const { return VarFlags; }
1052  void setReadOnly(bool RO) { VarFlags.MaybeReadOnly = RO; }
1053  void setWriteOnly(bool WO) { VarFlags.MaybeWriteOnly = WO; }
1054  bool maybeReadOnly() const { return VarFlags.MaybeReadOnly; }
1055  bool maybeWriteOnly() const { return VarFlags.MaybeWriteOnly; }
1056  bool isConstant() const { return VarFlags.Constant; }
1058  VarFlags.VCallVisibility = Vis;
1059  }
1062  }
1063 
1065  assert(!VTableFuncs);
1066  VTableFuncs = std::make_unique<VTableFuncList>(std::move(Funcs));
1067  }
1068 
1070  if (VTableFuncs)
1071  return *VTableFuncs;
1072  return {};
1073  }
1074 };
1075 
1077  /// Specifies which kind of type check we should emit for this byte array.
1078  /// See http://clang.llvm.org/docs/ControlFlowIntegrityDesign.html for full
1079  /// details on each kind of check; the enumerators are described with
1080  /// reference to that document.
1081  enum Kind {
1082  Unsat, ///< Unsatisfiable type (i.e. no global has this type metadata)
1083  ByteArray, ///< Test a byte array (first example)
1084  Inline, ///< Inlined bit vector ("Short Inline Bit Vectors")
1085  Single, ///< Single element (last example in "Short Inline Bit Vectors")
1086  AllOnes, ///< All-ones bit vector ("Eliminating Bit Vector Checks for
1087  /// All-Ones Bit Vectors")
1088  Unknown, ///< Unknown (analysis not performed, don't lower)
1089  } TheKind = Unknown;
1090 
1091  /// Range of size-1 expressed as a bit width. For example, if the size is in
1092  /// range [1,256], this number will be 8. This helps generate the most compact
1093  /// instruction sequences.
1094  unsigned SizeM1BitWidth = 0;
1095 
1096  // The following fields are only used if the target does not support the use
1097  // of absolute symbols to store constants. Their meanings are the same as the
1098  // corresponding fields in LowerTypeTestsModule::TypeIdLowering in
1099  // LowerTypeTests.cpp.
1100 
1103  uint8_t BitMask = 0;
1105 };
1106 
1108  enum Kind {
1109  Indir, ///< Just do a regular virtual call
1110  SingleImpl, ///< Single implementation devirtualization
1111  BranchFunnel, ///< When retpoline mitigation is enabled, use a branch funnel
1112  ///< that is defined in the merged module. Otherwise same as
1113  ///< Indir.
1114  } TheKind = Indir;
1115 
1116  std::string SingleImplName;
1117 
1118  struct ByArg {
1119  enum Kind {
1120  Indir, ///< Just do a regular virtual call
1121  UniformRetVal, ///< Uniform return value optimization
1122  UniqueRetVal, ///< Unique return value optimization
1123  VirtualConstProp, ///< Virtual constant propagation
1124  } TheKind = Indir;
1125 
1126  /// Additional information for the resolution:
1127  /// - UniformRetVal: the uniform return value.
1128  /// - UniqueRetVal: the return value associated with the unique vtable (0 or
1129  /// 1).
1131 
1132  // The following fields are only used if the target does not support the use
1133  // of absolute symbols to store constants.
1134 
1137  };
1138 
1139  /// Resolutions for calls with all constant integer arguments (excluding the
1140  /// first argument, "this"), where the key is the argument vector.
1141  std::map<std::vector<uint64_t>, ByArg> ResByArg;
1142 };
1143 
1146 
1147  /// Mapping from byte offset to whole-program devirt resolution for that
1148  /// (typeid, byte offset) pair.
1149  std::map<uint64_t, WholeProgramDevirtResolution> WPDRes;
1150 };
1151 
1152 /// 160 bits SHA1
1153 using ModuleHash = std::array<uint32_t, 5>;
1154 
1155 /// Type used for iterating through the global value summary map.
1156 using const_gvsummary_iterator = GlobalValueSummaryMapTy::const_iterator;
1157 using gvsummary_iterator = GlobalValueSummaryMapTy::iterator;
1158 
1159 /// String table to hold/own module path strings, which additionally holds the
1160 /// module ID assigned to each module during the plugin step, as well as a hash
1161 /// of the module. The StringMap makes a copy of and owns inserted strings.
1163 
1164 /// Map of global value GUID to its summary, used to identify values defined in
1165 /// a particular module, and provide efficient access to their summary.
1167 
1168 /// Map of a type GUID to type id string and summary (multimap used
1169 /// in case of GUID conflicts).
1170 using TypeIdSummaryMapTy =
1171  std::multimap<GlobalValue::GUID, std::pair<std::string, TypeIdSummary>>;
1172 
1173 /// The following data structures summarize type metadata information.
1174 /// For type metadata overview see https://llvm.org/docs/TypeMetadata.html.
1175 /// Each type metadata includes both the type identifier and the offset of
1176 /// the address point of the type (the address held by objects of that type
1177 /// which may not be the beginning of the virtual table). Vtable definitions
1178 /// are decorated with type metadata for the types they are compatible with.
1179 ///
1180 /// Holds information about vtable definitions decorated with type metadata:
1181 /// the vtable definition value and its address point offset in a type
1182 /// identifier metadata it is decorated (compatible) with.
1185  : AddressPointOffset(Offset), VTableVI(VI) {}
1186 
1189 };
1190 /// List of vtable definitions decorated by a particular type identifier,
1191 /// and their corresponding offsets in that type identifier's metadata.
1192 /// Note that each type identifier may be compatible with multiple vtables, due
1193 /// to inheritance, which is why this is a vector.
1194 using TypeIdCompatibleVtableInfo = std::vector<TypeIdOffsetVtableInfo>;
1195 
1196 /// Class to hold module path string table and global value map,
1197 /// and encapsulate methods for operating on them.
1199 private:
1200  /// Map from value name to list of summary instances for values of that
1201  /// name (may be duplicates in the COMDAT case, e.g.).
1202  GlobalValueSummaryMapTy GlobalValueMap;
1203 
1204  /// Holds strings for combined index, mapping to the corresponding module ID.
1205  ModulePathStringTableTy ModulePathStringTable;
1206 
1207  /// Mapping from type identifier GUIDs to type identifier and its summary
1208  /// information. Produced by thin link.
1209  TypeIdSummaryMapTy TypeIdMap;
1210 
1211  /// Mapping from type identifier to information about vtables decorated
1212  /// with that type identifier's metadata. Produced by per module summary
1213  /// analysis and consumed by thin link. For more information, see description
1214  /// above where TypeIdCompatibleVtableInfo is defined.
1215  std::map<std::string, TypeIdCompatibleVtableInfo, std::less<>>
1216  TypeIdCompatibleVtableMap;
1217 
1218  /// Mapping from original ID to GUID. If original ID can map to multiple
1219  /// GUIDs, it will be mapped to 0.
1220  std::map<GlobalValue::GUID, GlobalValue::GUID> OidGuidMap;
1221 
1222  /// Indicates that summary-based GlobalValue GC has run, and values with
1223  /// GVFlags::Live==false are really dead. Otherwise, all values must be
1224  /// considered live.
1225  bool WithGlobalValueDeadStripping = false;
1226 
1227  /// Indicates that summary-based attribute propagation has run and
1228  /// GVarFlags::MaybeReadonly / GVarFlags::MaybeWriteonly are really
1229  /// read/write only.
1230  bool WithAttributePropagation = false;
1231 
1232  /// Indicates that summary-based DSOLocal propagation has run and the flag in
1233  /// every summary of a GV is synchronized.
1234  bool WithDSOLocalPropagation = false;
1235 
1236  /// Indicates that we have whole program visibility.
1237  bool WithWholeProgramVisibility = false;
1238 
1239  /// Indicates that summary-based synthetic entry count propagation has run
1240  bool HasSyntheticEntryCounts = false;
1241 
1242  /// Indicates that distributed backend should skip compilation of the
1243  /// module. Flag is suppose to be set by distributed ThinLTO indexing
1244  /// when it detected that the module is not needed during the final
1245  /// linking. As result distributed backend should just output a minimal
1246  /// valid object file.
1247  bool SkipModuleByDistributedBackend = false;
1248 
1249  /// If true then we're performing analysis of IR module, or parsing along with
1250  /// the IR from assembly. The value of 'false' means we're reading summary
1251  /// from BC or YAML source. Affects the type of value stored in NameOrGV
1252  /// union.
1253  bool HaveGVs;
1254 
1255  // True if the index was created for a module compiled with -fsplit-lto-unit.
1256  bool EnableSplitLTOUnit;
1257 
1258  // True if some of the modules were compiled with -fsplit-lto-unit and
1259  // some were not. Set when the combined index is created during the thin link.
1260  bool PartiallySplitLTOUnits = false;
1261 
1262  /// True if some of the FunctionSummary contains a ParamAccess.
1263  bool HasParamAccess = false;
1264 
1265  std::set<std::string> CfiFunctionDefs;
1266  std::set<std::string> CfiFunctionDecls;
1267 
1268  // Used in cases where we want to record the name of a global, but
1269  // don't have the string owned elsewhere (e.g. the Strtab on a module).
1270  BumpPtrAllocator Alloc;
1271  StringSaver Saver;
1272 
1273  // The total number of basic blocks in the module in the per-module summary or
1274  // the total number of basic blocks in the LTO unit in the combined index.
1275  uint64_t BlockCount;
1276 
1277  // List of unique stack ids (hashes). We use a 4B index of the id in the
1278  // stack id lists on the alloc and callsite summaries for memory savings,
1279  // since the number of unique ids is in practice much smaller than the
1280  // number of stack id references in the summaries.
1281  std::vector<uint64_t> StackIds;
1282 
1283  // Temporary map while building StackIds list. Clear when index is completely
1284  // built via releaseTemporaryMemory.
1285  std::map<uint64_t, unsigned> StackIdToIndex;
1286 
1287  // YAML I/O support.
1289 
1290  GlobalValueSummaryMapTy::value_type *
1291  getOrInsertValuePtr(GlobalValue::GUID GUID) {
1292  return &*GlobalValueMap.emplace(GUID, GlobalValueSummaryInfo(HaveGVs))
1293  .first;
1294  }
1295 
1296 public:
1297  // See HaveGVs variable comment.
1298  ModuleSummaryIndex(bool HaveGVs, bool EnableSplitLTOUnit = false)
1299  : HaveGVs(HaveGVs), EnableSplitLTOUnit(EnableSplitLTOUnit), Saver(Alloc),
1300  BlockCount(0) {}
1301 
1302  // Current version for the module summary in bitcode files.
1303  // The BitcodeSummaryVersion should be bumped whenever we introduce changes
1304  // in the way some record are interpreted, like flags for instance.
1305  // Note that incrementing this may require changes in both BitcodeReader.cpp
1306  // and BitcodeWriter.cpp.
1307  static constexpr uint64_t BitcodeSummaryVersion = 9;
1308 
1309  // Regular LTO module name for ASM writer
1310  static constexpr const char *getRegularLTOModuleName() {
1311  return "[Regular LTO]";
1312  }
1313 
1314  bool haveGVs() const { return HaveGVs; }
1315 
1316  uint64_t getFlags() const;
1317  void setFlags(uint64_t Flags);
1318 
1319  uint64_t getBlockCount() const { return BlockCount; }
1320  void addBlockCount(uint64_t C) { BlockCount += C; }
1321  void setBlockCount(uint64_t C) { BlockCount = C; }
1322 
1323  gvsummary_iterator begin() { return GlobalValueMap.begin(); }
1324  const_gvsummary_iterator begin() const { return GlobalValueMap.begin(); }
1325  gvsummary_iterator end() { return GlobalValueMap.end(); }
1326  const_gvsummary_iterator end() const { return GlobalValueMap.end(); }
1327  size_t size() const { return GlobalValueMap.size(); }
1328 
1329  const std::vector<uint64_t> &stackIds() const { return StackIds; }
1330 
1331  unsigned addOrGetStackIdIndex(uint64_t StackId) {
1332  auto Inserted = StackIdToIndex.insert({StackId, StackIds.size()});
1333  if (Inserted.second)
1334  StackIds.push_back(StackId);
1335  return Inserted.first->second;
1336  }
1337 
1339  assert(StackIds.size() > Index);
1340  return StackIds[Index];
1341  }
1342 
1343  // Facility to release memory from data structures only needed during index
1344  // construction (including while building combined index). Currently this only
1345  // releases the temporary map used while constructing a correspondence between
1346  // stack ids and their index in the StackIds vector. Mostly impactful when
1347  // building a large combined index.
1349  assert(StackIdToIndex.size() == StackIds.size());
1350  StackIdToIndex.clear();
1351  StackIds.shrink_to_fit();
1352  }
1353 
1354  /// Convenience function for doing a DFS on a ValueInfo. Marks the function in
1355  /// the FunctionHasParent map.
1356  static void discoverNodes(ValueInfo V,
1357  std::map<ValueInfo, bool> &FunctionHasParent) {
1358  if (!V.getSummaryList().size())
1359  return; // skip external functions that don't have summaries
1360 
1361  // Mark discovered if we haven't yet
1362  auto S = FunctionHasParent.emplace(V, false);
1363 
1364  // Stop if we've already discovered this node
1365  if (!S.second)
1366  return;
1367 
1368  FunctionSummary *F =
1369  dyn_cast<FunctionSummary>(V.getSummaryList().front().get());
1370  assert(F != nullptr && "Expected FunctionSummary node");
1371 
1372  for (const auto &C : F->calls()) {
1373  // Insert node if necessary
1374  auto S = FunctionHasParent.emplace(C.first, true);
1375 
1376  // Skip nodes that we're sure have parents
1377  if (!S.second && S.first->second)
1378  continue;
1379 
1380  if (S.second)
1381  discoverNodes(C.first, FunctionHasParent);
1382  else
1383  S.first->second = true;
1384  }
1385  }
1386 
1387  // Calculate the callgraph root
1389  // Functions that have a parent will be marked in FunctionHasParent pair.
1390  // Once we've marked all functions, the functions in the map that are false
1391  // have no parent (so they're the roots)
1392  std::map<ValueInfo, bool> FunctionHasParent;
1393 
1394  for (auto &S : *this) {
1395  // Skip external functions
1396  if (!S.second.SummaryList.size() ||
1397  !isa<FunctionSummary>(S.second.SummaryList.front().get()))
1398  continue;
1399  discoverNodes(ValueInfo(HaveGVs, &S), FunctionHasParent);
1400  }
1401 
1402  std::vector<FunctionSummary::EdgeTy> Edges;
1403  // create edges to all roots in the Index
1404  for (auto &P : FunctionHasParent) {
1405  if (P.second)
1406  continue; // skip over non-root nodes
1407  Edges.push_back(std::make_pair(P.first, CalleeInfo{}));
1408  }
1409  if (Edges.empty()) {
1410  // Failed to find root - return an empty node
1412  }
1413  auto CallGraphRoot = FunctionSummary::makeDummyFunctionSummary(Edges);
1414  return CallGraphRoot;
1415  }
1416 
1418  return WithGlobalValueDeadStripping;
1419  }
1421  WithGlobalValueDeadStripping = true;
1422  }
1423 
1424  bool withAttributePropagation() const { return WithAttributePropagation; }
1426  WithAttributePropagation = true;
1427  }
1428 
1429  bool withDSOLocalPropagation() const { return WithDSOLocalPropagation; }
1430  void setWithDSOLocalPropagation() { WithDSOLocalPropagation = true; }
1431 
1432  bool withWholeProgramVisibility() const { return WithWholeProgramVisibility; }
1433  void setWithWholeProgramVisibility() { WithWholeProgramVisibility = true; }
1434 
1435  bool isReadOnly(const GlobalVarSummary *GVS) const {
1436  return WithAttributePropagation && GVS->maybeReadOnly();
1437  }
1438  bool isWriteOnly(const GlobalVarSummary *GVS) const {
1439  return WithAttributePropagation && GVS->maybeWriteOnly();
1440  }
1441 
1442  bool hasSyntheticEntryCounts() const { return HasSyntheticEntryCounts; }
1443  void setHasSyntheticEntryCounts() { HasSyntheticEntryCounts = true; }
1444 
1446  return SkipModuleByDistributedBackend;
1447  }
1449  SkipModuleByDistributedBackend = true;
1450  }
1451 
1452  bool enableSplitLTOUnit() const { return EnableSplitLTOUnit; }
1453  void setEnableSplitLTOUnit() { EnableSplitLTOUnit = true; }
1454 
1455  bool partiallySplitLTOUnits() const { return PartiallySplitLTOUnits; }
1456  void setPartiallySplitLTOUnits() { PartiallySplitLTOUnits = true; }
1457 
1458  bool hasParamAccess() const { return HasParamAccess; }
1459 
1460  bool isGlobalValueLive(const GlobalValueSummary *GVS) const {
1461  return !WithGlobalValueDeadStripping || GVS->isLive();
1462  }
1463  bool isGUIDLive(GlobalValue::GUID GUID) const;
1464 
1465  /// Return a ValueInfo for the index value_type (convenient when iterating
1466  /// index).
1467  ValueInfo getValueInfo(const GlobalValueSummaryMapTy::value_type &R) const {
1468  return ValueInfo(HaveGVs, &R);
1469  }
1470 
1471  /// Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
1473  auto I = GlobalValueMap.find(GUID);
1474  return ValueInfo(HaveGVs, I == GlobalValueMap.end() ? nullptr : &*I);
1475  }
1476 
1477  /// Return a ValueInfo for \p GUID.
1479  return ValueInfo(HaveGVs, getOrInsertValuePtr(GUID));
1480  }
1481 
1482  // Save a string in the Index. Use before passing Name to
1483  // getOrInsertValueInfo when the string isn't owned elsewhere (e.g. on the
1484  // module's Strtab).
1485  StringRef saveString(StringRef String) { return Saver.save(String); }
1486 
1487  /// Return a ValueInfo for \p GUID setting value \p Name.
1489  assert(!HaveGVs);
1490  auto VP = getOrInsertValuePtr(GUID);
1491  VP->second.U.Name = Name;
1492  return ValueInfo(HaveGVs, VP);
1493  }
1494 
1495  /// Return a ValueInfo for \p GV and mark it as belonging to GV.
1497  assert(HaveGVs);
1498  auto VP = getOrInsertValuePtr(GV->getGUID());
1499  VP->second.U.GV = GV;
1500  return ValueInfo(HaveGVs, VP);
1501  }
1502 
1503  /// Return the GUID for \p OriginalId in the OidGuidMap.
1505  const auto I = OidGuidMap.find(OriginalID);
1506  return I == OidGuidMap.end() ? 0 : I->second;
1507  }
1508 
1509  std::set<std::string> &cfiFunctionDefs() { return CfiFunctionDefs; }
1510  const std::set<std::string> &cfiFunctionDefs() const { return CfiFunctionDefs; }
1511 
1512  std::set<std::string> &cfiFunctionDecls() { return CfiFunctionDecls; }
1513  const std::set<std::string> &cfiFunctionDecls() const { return CfiFunctionDecls; }
1514 
1515  /// Add a global value summary for a value.
1517  std::unique_ptr<GlobalValueSummary> Summary) {
1519  }
1520 
1521  /// Add a global value summary for a value of the given name.
1523  std::unique_ptr<GlobalValueSummary> Summary) {
1525  std::move(Summary));
1526  }
1527 
1528  /// Add a global value summary for the given ValueInfo.
1530  std::unique_ptr<GlobalValueSummary> Summary) {
1531  if (const FunctionSummary *FS = dyn_cast<FunctionSummary>(Summary.get()))
1532  HasParamAccess |= !FS->paramAccesses().empty();
1533  addOriginalName(VI.getGUID(), Summary->getOriginalName());
1534  // Here we have a notionally const VI, but the value it points to is owned
1535  // by the non-const *this.
1536  const_cast<GlobalValueSummaryMapTy::value_type *>(VI.getRef())
1537  ->second.SummaryList.push_back(std::move(Summary));
1538  }
1539 
1540  /// Add an original name for the value of the given GUID.
1542  GlobalValue::GUID OrigGUID) {
1543  if (OrigGUID == 0 || ValueGUID == OrigGUID)
1544  return;
1545  if (OidGuidMap.count(OrigGUID) && OidGuidMap[OrigGUID] != ValueGUID)
1546  OidGuidMap[OrigGUID] = 0;
1547  else
1548  OidGuidMap[OrigGUID] = ValueGUID;
1549  }
1550 
1551  /// Find the summary for ValueInfo \p VI in module \p ModuleId, or nullptr if
1552  /// not found.
1554  auto SummaryList = VI.getSummaryList();
1555  auto Summary =
1556  llvm::find_if(SummaryList,
1557  [&](const std::unique_ptr<GlobalValueSummary> &Summary) {
1558  return Summary->modulePath() == ModuleId;
1559  });
1560  if (Summary == SummaryList.end())
1561  return nullptr;
1562  return Summary->get();
1563  }
1564 
1565  /// Find the summary for global \p GUID in module \p ModuleId, or nullptr if
1566  /// not found.
1568  StringRef ModuleId) const {
1569  auto CalleeInfo = getValueInfo(ValueGUID);
1570  if (!CalleeInfo)
1571  return nullptr; // This function does not have a summary
1572  return findSummaryInModule(CalleeInfo, ModuleId);
1573  }
1574 
1575  /// Returns the first GlobalValueSummary for \p GV, asserting that there
1576  /// is only one if \p PerModuleIndex.
1578  bool PerModuleIndex = true) const {
1579  assert(GV.hasName() && "Can't get GlobalValueSummary for GV with no name");
1580  return getGlobalValueSummary(GV.getGUID(), PerModuleIndex);
1581  }
1582 
1583  /// Returns the first GlobalValueSummary for \p ValueGUID, asserting that
1584  /// there
1585  /// is only one if \p PerModuleIndex.
1587  bool PerModuleIndex = true) const;
1588 
1589  /// Table of modules, containing module hash and id.
1591  return ModulePathStringTable;
1592  }
1593 
1594  /// Table of modules, containing hash and id.
1596  return ModulePathStringTable;
1597  }
1598 
1599  /// Get the module ID recorded for the given module path.
1600  uint64_t getModuleId(const StringRef ModPath) const {
1601  return ModulePathStringTable.lookup(ModPath).first;
1602  }
1603 
1604  /// Get the module SHA1 hash recorded for the given module path.
1605  const ModuleHash &getModuleHash(const StringRef ModPath) const {
1606  auto It = ModulePathStringTable.find(ModPath);
1607  assert(It != ModulePathStringTable.end() && "Module not registered");
1608  return It->second.second;
1609  }
1610 
1611  /// Convenience method for creating a promoted global name
1612  /// for the given value name of a local, and its original module's ID.
1613  static std::string getGlobalNameForLocal(StringRef Name, ModuleHash ModHash) {
1614  std::string Suffix = utostr((uint64_t(ModHash[0]) << 32) |
1615  ModHash[1]); // Take the first 64 bits
1616  return getGlobalNameForLocal(Name, Suffix);
1617  }
1618 
1619  static std::string getGlobalNameForLocal(StringRef Name, StringRef Suffix) {
1620  SmallString<256> NewName(Name);
1621  NewName += ".llvm.";
1622  NewName += Suffix;
1623  return std::string(NewName.str());
1624  }
1625 
1626  /// Helper to obtain the unpromoted name for a global value (or the original
1627  /// name if not promoted). Split off the rightmost ".llvm.${hash}" suffix,
1628  /// because it is possible in certain clients (not clang at the moment) for
1629  /// two rounds of ThinLTO optimization and therefore promotion to occur.
1631  std::pair<StringRef, StringRef> Pair = Name.rsplit(".llvm.");
1632  return Pair.first;
1633  }
1634 
1636 
1637  /// Add a new module with the given \p Hash, mapped to the given \p
1638  /// ModID, and return a reference to the module.
1640  ModuleHash Hash = ModuleHash{{0}}) {
1641  return &*ModulePathStringTable.insert({ModPath, {ModId, Hash}}).first;
1642  }
1643 
1644  /// Return module entry for module with the given \p ModPath.
1646  auto It = ModulePathStringTable.find(ModPath);
1647  assert(It != ModulePathStringTable.end() && "Module not registered");
1648  return &*It;
1649  }
1650 
1651  /// Check if the given Module has any functions available for exporting
1652  /// in the index. We consider any module present in the ModulePathStringTable
1653  /// to have exported functions.
1654  bool hasExportedFunctions(const Module &M) const {
1655  return ModulePathStringTable.count(M.getModuleIdentifier());
1656  }
1657 
1658  const TypeIdSummaryMapTy &typeIds() const { return TypeIdMap; }
1659 
1660  /// Return an existing or new TypeIdSummary entry for \p TypeId.
1661  /// This accessor can mutate the map and therefore should not be used in
1662  /// the ThinLTO backends.
1664  auto TidIter = TypeIdMap.equal_range(GlobalValue::getGUID(TypeId));
1665  for (auto It = TidIter.first; It != TidIter.second; ++It)
1666  if (It->second.first == TypeId)
1667  return It->second.second;
1668  auto It = TypeIdMap.insert(
1669  {GlobalValue::getGUID(TypeId), {std::string(TypeId), TypeIdSummary()}});
1670  return It->second.second;
1671  }
1672 
1673  /// This returns either a pointer to the type id summary (if present in the
1674  /// summary map) or null (if not present). This may be used when importing.
1676  auto TidIter = TypeIdMap.equal_range(GlobalValue::getGUID(TypeId));
1677  for (auto It = TidIter.first; It != TidIter.second; ++It)
1678  if (It->second.first == TypeId)
1679  return &It->second.second;
1680  return nullptr;
1681  }
1682 
1684  return const_cast<TypeIdSummary *>(
1685  static_cast<const ModuleSummaryIndex *>(this)->getTypeIdSummary(
1686  TypeId));
1687  }
1688 
1689  const auto &typeIdCompatibleVtableMap() const {
1690  return TypeIdCompatibleVtableMap;
1691  }
1692 
1693  /// Return an existing or new TypeIdCompatibleVtableMap entry for \p TypeId.
1694  /// This accessor can mutate the map and therefore should not be used in
1695  /// the ThinLTO backends.
1698  return TypeIdCompatibleVtableMap[std::string(TypeId)];
1699  }
1700 
1701  /// For the given \p TypeId, this returns the TypeIdCompatibleVtableMap
1702  /// entry if present in the summary map. This may be used when importing.
1705  auto I = TypeIdCompatibleVtableMap.find(TypeId);
1706  if (I == TypeIdCompatibleVtableMap.end())
1707  return None;
1708  return I->second;
1709  }
1710 
1711  /// Collect for the given module the list of functions it defines
1712  /// (GUID -> Summary).
1714  GVSummaryMapTy &GVSummaryMap) const;
1715 
1716  /// Collect for each module the list of Summaries it defines (GUID ->
1717  /// Summary).
1718  template <class Map>
1719  void
1720  collectDefinedGVSummariesPerModule(Map &ModuleToDefinedGVSummaries) const {
1721  for (const auto &GlobalList : *this) {
1722  auto GUID = GlobalList.first;
1723  for (const auto &Summary : GlobalList.second.SummaryList) {
1724  ModuleToDefinedGVSummaries[Summary->modulePath()][GUID] = Summary.get();
1725  }
1726  }
1727  }
1728 
1729  /// Print to an output stream.
1730  void print(raw_ostream &OS, bool IsForDebug = false) const;
1731 
1732  /// Dump to stderr (for debugging).
1733  void dump() const;
1734 
1735  /// Export summary to dot file for GraphViz.
1736  void
1738  const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols) const;
1739 
1740  /// Print out strongly connected components for debugging.
1741  void dumpSCCs(raw_ostream &OS);
1742 
1743  /// Do the access attribute and DSOLocal propagation in combined index.
1745 
1746  /// Checks if we can import global variable from another module.
1747  bool canImportGlobalVar(GlobalValueSummary *S, bool AnalyzeRefs) const;
1748 };
1749 
1750 /// GraphTraits definition to build SCC for the index
1751 template <> struct GraphTraits<ValueInfo> {
1754 
1756  return P.first;
1757  }
1758  using ChildIteratorType =
1760  decltype(&valueInfoFromEdge)>;
1761 
1762  using ChildEdgeIteratorType = std::vector<FunctionSummary::EdgeTy>::iterator;
1763 
1764  static NodeRef getEntryNode(ValueInfo V) { return V; }
1765 
1767  if (!N.getSummaryList().size()) // handle external function
1768  return ChildIteratorType(
1769  FunctionSummary::ExternalNode.CallGraphEdgeList.begin(),
1770  &valueInfoFromEdge);
1771  FunctionSummary *F =
1772  cast<FunctionSummary>(N.getSummaryList().front()->getBaseObject());
1773  return ChildIteratorType(F->CallGraphEdgeList.begin(), &valueInfoFromEdge);
1774  }
1775 
1777  if (!N.getSummaryList().size()) // handle external function
1778  return ChildIteratorType(
1779  FunctionSummary::ExternalNode.CallGraphEdgeList.end(),
1780  &valueInfoFromEdge);
1781  FunctionSummary *F =
1782  cast<FunctionSummary>(N.getSummaryList().front()->getBaseObject());
1783  return ChildIteratorType(F->CallGraphEdgeList.end(), &valueInfoFromEdge);
1784  }
1785 
1787  if (!N.getSummaryList().size()) // handle external function
1788  return FunctionSummary::ExternalNode.CallGraphEdgeList.begin();
1789 
1790  FunctionSummary *F =
1791  cast<FunctionSummary>(N.getSummaryList().front()->getBaseObject());
1792  return F->CallGraphEdgeList.begin();
1793  }
1794 
1796  if (!N.getSummaryList().size()) // handle external function
1797  return FunctionSummary::ExternalNode.CallGraphEdgeList.end();
1798 
1799  FunctionSummary *F =
1800  cast<FunctionSummary>(N.getSummaryList().front()->getBaseObject());
1801  return F->CallGraphEdgeList.end();
1802  }
1803 
1804  static NodeRef edge_dest(EdgeRef E) { return E.first; }
1805 };
1806 
1807 template <>
1810  std::unique_ptr<GlobalValueSummary> Root =
1811  std::make_unique<FunctionSummary>(I->calculateCallGraphRoot());
1812  GlobalValueSummaryInfo G(I->haveGVs());
1813  G.SummaryList.push_back(std::move(Root));
1814  static auto P =
1815  GlobalValueSummaryMapTy::value_type(GlobalValue::GUID(0), std::move(G));
1816  return ValueInfo(I->haveGVs(), &P);
1817  }
1818 };
1819 } // end namespace llvm
1820 
1821 #endif // LLVM_IR_MODULESUMMARYINDEX_H
llvm::FunctionSummary::TypeIdInfo
All type identifier related information.
Definition: ModuleSummaryIndex.h:617
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:1141
llvm::GlobalValue::GUID
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Definition: GlobalValue.h:581
llvm::ValueInfo::ValueInfo
ValueInfo(bool HaveGVs, const GlobalValueSummaryMapTy::value_type *R)
Definition: ModuleSummaryIndex.h:174
llvm::FunctionSummary::ParamAccess::ParamNo
uint64_t ParamNo
Definition: ModuleSummaryIndex.h:721
llvm::const_gvsummary_iterator
GlobalValueSummaryMapTy::const_iterator const_gvsummary_iterator
Type used for iterating through the global value summary map.
Definition: ModuleSummaryIndex.h:1156
llvm::FunctionSummary::FFlags::ReadOnly
unsigned ReadOnly
Definition: ModuleSummaryIndex.h:640
llvm::ValueInfo::getSummaryList
ArrayRef< std::unique_ptr< GlobalValueSummary > > getSummaryList() const
Definition: ModuleSummaryIndex.h:187
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:1522
llvm::ModuleSummaryIndex::hasSyntheticEntryCounts
bool hasSyntheticEntryCounts() const
Definition: ModuleSummaryIndex.h:1442
llvm::ModuleSummaryIndex::haveGVs
bool haveGVs() const
Definition: ModuleSummaryIndex.h:1314
llvm::DenseMapInfo< FunctionSummary::VFuncId >::isEqual
static bool isEqual(FunctionSummary::VFuncId L, FunctionSummary::VFuncId R)
Definition: ModuleSummaryIndex.h:956
MathExtras.h
llvm::GlobalValueSummaryInfo::NameOrGV::GV
const GlobalValue * GV
The GlobalValue corresponding to this summary.
Definition: ModuleSummaryIndex.h:139
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::FunctionSummary::ConstVCall::Args
std::vector< uint64_t > Args
Definition: ModuleSummaryIndex.h:612
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::ModuleSummaryIndex::getOrInsertValueInfo
ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID, StringRef Name)
Return a ValueInfo for GUID setting value Name.
Definition: ModuleSummaryIndex.h:1488
llvm::DenseMapInfo< ValueInfo >::getEmptyKey
static ValueInfo getEmptyKey()
Definition: ModuleSummaryIndex.h:267
llvm::StringMapEntry
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMapEntry.h:102
llvm::ModuleSummaryIndex::getTypeIdSummary
TypeIdSummary * getTypeIdSummary(StringRef TypeId)
Definition: ModuleSummaryIndex.h:1683
llvm::WholeProgramDevirtResolution::ByArg::TheKind
enum llvm::WholeProgramDevirtResolution::ByArg::Kind TheKind
llvm::GraphTraits< ValueInfo >::edge_dest
static NodeRef edge_dest(EdgeRef E)
Definition: ModuleSummaryIndex.h:1804
llvm::GlobalValueSummary::setNotEligibleToImport
void setNotEligibleToImport()
Flag that this global value cannot be imported.
Definition: ModuleSummaryIndex.h:508
llvm::GraphTraits< ValueInfo >::getEntryNode
static NodeRef getEntryNode(ValueInfo V)
Definition: ModuleSummaryIndex.h:1764
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:466
llvm::GraphTraits< ValueInfo >::child_begin
static ChildIteratorType child_begin(NodeRef N)
Definition: ModuleSummaryIndex.h:1766
llvm::ModuleSummaryIndex::begin
const_gvsummary_iterator begin() const
Definition: ModuleSummaryIndex.h:1324
llvm::ModuleSummaryIndex::getModule
ModuleInfo * getModule(StringRef ModPath)
Return module entry for module with the given ModPath.
Definition: ModuleSummaryIndex.h:1645
llvm::ModuleSummaryIndex::ModuleInfo
ModulePathStringTableTy::value_type ModuleInfo
Definition: ModuleSummaryIndex.h:1635
llvm::PointerIntPair::setInt
void setInt(IntType IntVal) &
Definition: PointerIntPair.h:68
llvm::GlobalValueSummaryMapTy
std::map< GlobalValue::GUID, GlobalValueSummaryInfo > GlobalValueSummaryMapTy
Map from global value GUID to corresponding summary structures.
Definition: ModuleSummaryIndex.h:164
llvm::DenseMapInfo< ValueInfo >::isEqual
static bool isEqual(ValueInfo L, ValueInfo R)
Definition: ModuleSummaryIndex.h:279
llvm::ModuleSummaryIndex::setPartiallySplitLTOUnits
void setPartiallySplitLTOUnits()
Definition: ModuleSummaryIndex.h:1456
llvm::ModuleSummaryIndex::isReadOnly
bool isReadOnly(const GlobalVarSummary *GVS) const
Definition: ModuleSummaryIndex.h:1435
llvm::FunctionSummary::classof
static bool classof(const GlobalValueSummary *GVS)
Check if this is a function summary.
Definition: ModuleSummaryIndex.h:836
llvm::ModuleSummaryIndex::getModuleHash
const ModuleHash & getModuleHash(const StringRef ModPath) const
Get the module SHA1 hash recorded for the given module path.
Definition: ModuleSummaryIndex.h:1605
llvm::FunctionSummary::calls
ArrayRef< EdgeTy > calls() const
Return the list of <CalleeValueInfo, CalleeInfo> pairs.
Definition: ModuleSummaryIndex.h:857
llvm::ModuleSummaryIndex::setEnableSplitLTOUnit
void setEnableSplitLTOUnit()
Definition: ModuleSummaryIndex.h:1453
llvm::CalleeInfo::MaxRelBlockFreq
static constexpr uint64_t MaxRelBlockFreq
Definition: ModuleSummaryIndex.h:74
llvm::ModuleSummaryIndex::saveString
StringRef saveString(StringRef String)
Definition: ModuleSummaryIndex.h:1485
llvm::TypeTestResolution::Kind
Kind
Specifies which kind of type check we should emit for this byte array.
Definition: ModuleSummaryIndex.h:1081
llvm::FunctionSummary::fflags
FFlags fflags() const
Get function summary flags.
Definition: ModuleSummaryIndex.h:841
llvm::ModuleSummaryIndex::stackIds
const std::vector< uint64_t > & stackIds() const
Definition: ModuleSummaryIndex.h:1329
llvm::FunctionSummary::paramAccesses
ArrayRef< ParamAccess > paramAccesses() const
Returns the list of known uses of pointer parameters.
Definition: ModuleSummaryIndex.h:908
StringRef.h
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::GlobalVarSummary
Global variable summary information to aid decisions and implementation of importing.
Definition: ModuleSummaryIndex.h:1004
llvm::FunctionSummary::FFlags::AlwaysInline
unsigned AlwaysInline
Definition: ModuleSummaryIndex.h:647
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:629
llvm::GlobalVarSummary::setWriteOnly
void setWriteOnly(bool WO)
Definition: ModuleSummaryIndex.h:1053
llvm::FunctionSummary::ParamAccess::Call::Offsets
ConstantRange Offsets
Definition: ModuleSummaryIndex.h:714
llvm::GraphTraits< ValueInfo >::child_edge_end
static ChildEdgeIteratorType child_edge_end(NodeRef N)
Definition: ModuleSummaryIndex.h:1795
llvm::GlobalValueSummary::setLive
void setLive(bool Live)
Definition: ModuleSummaryIndex.h:490
llvm::CallsiteInfo::StackIdIndices
SmallVector< unsigned > StackIdIndices
Definition: ModuleSummaryIndex.h:307
llvm::SmallVector< unsigned >
llvm::GraphTraits< ValueInfo >::ChildEdgeIteratorType
std::vector< FunctionSummary::EdgeTy >::iterator ChildEdgeIteratorType
Definition: ModuleSummaryIndex.h:1762
llvm::ValueInfo::getGUID
GlobalValue::GUID getGUID() const
Definition: ModuleSummaryIndex.h:181
llvm::FunctionSummary::ParamAccess::ParamAccess
ParamAccess()=default
llvm::GlobalValueSummary::isDSOLocal
bool isDSOLocal() const
Definition: ModuleSummaryIndex.h:494
llvm::ValueInfo::HaveGV
@ HaveGV
Definition: ModuleSummaryIndex.h:169
llvm::GlobalValueSummary::notEligibleToImport
bool notEligibleToImport() const
Return true if this global value can't be imported.
Definition: ModuleSummaryIndex.h:486
llvm::AllocInfo::Versions
SmallVector< uint8_t > Versions
Definition: ModuleSummaryIndex.h:349
llvm::TypeTestResolution::InlineBits
uint64_t InlineBits
Definition: ModuleSummaryIndex.h:1104
llvm::Value::hasName
bool hasName() const
Definition: Value.h:261
llvm::TypeTestResolution::Unsat
@ Unsat
Unsatisfiable type (i.e. no global has this type metadata)
Definition: ModuleSummaryIndex.h:1082
llvm::CalleeInfo::HotnessType::Cold
@ Cold
Allocator.h
llvm::ModuleSummaryIndex::end
const_gvsummary_iterator end() const
Definition: ModuleSummaryIndex.h:1326
llvm::FunctionSummary::setNoUnwind
void setNoUnwind()
Definition: ModuleSummaryIndex.h:845
llvm::GlobalVarSummary::GlobalVarSummary
GlobalVarSummary(GVFlags Flags, GVarFlags VarFlags, std::vector< ValueInfo > Refs)
Definition: ModuleSummaryIndex.h:1041
llvm::ModuleSummaryIndex::getOrInsertTypeIdSummary
TypeIdSummary & getOrInsertTypeIdSummary(StringRef TypeId)
Return an existing or new TypeIdSummary entry for TypeId.
Definition: ModuleSummaryIndex.h:1663
llvm::FunctionSummary::addCall
void addCall(EdgeTy E)
Definition: ModuleSummaryIndex.h:861
llvm::AliasSummary
Alias summary information.
Definition: ModuleSummaryIndex.h:522
llvm::GlobalValueSummaryInfo::SummaryList
GlobalValueSummaryList SummaryList
List of global value summary structures for a particular value held in the GlobalValueMap.
Definition: ModuleSummaryIndex.h:154
llvm::TypeTestResolution::AllOnes
@ AllOnes
All-ones bit vector ("Eliminating Bit Vector Checks for All-Ones Bit Vectors")
Definition: ModuleSummaryIndex.h:1086
llvm::VirtFuncOffset
The ValueInfo and offset for a function within a vtable definition initializer array.
Definition: ModuleSummaryIndex.h:985
llvm::ValueInfo::getValue
const GlobalValue * getValue() const
Definition: ModuleSummaryIndex.h:182
llvm::StringMap::end
iterator end()
Definition: StringMap.h:204
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:893
llvm::VirtFuncOffset::VTableOffset
uint64_t VTableOffset
Definition: ModuleSummaryIndex.h:990
DenseMap.h
llvm::FunctionSummary::FFlags::operator&=
FFlags & operator&=(const FFlags &RHS)
Definition: ModuleSummaryIndex.h:664
Module.h
llvm::GlobalValueSummary::setVisibility
void setVisibility(GlobalValue::VisibilityTypes Vis)
Definition: ModuleSummaryIndex.h:503
llvm::X86AS::FS
@ FS
Definition: X86.h:200
llvm::TypeIdOffsetVtableInfo
The following data structures summarize type metadata information.
Definition: ModuleSummaryIndex.h:1183
llvm::GlobalValueSummary::GVFlags::Linkage
unsigned Linkage
The linkage type of the associated global value.
Definition: ModuleSummaryIndex.h:377
llvm::operator!=
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:2012
llvm::AllocInfo::AllocInfo
AllocInfo(SmallVector< uint8_t > Versions, std::vector< MIBInfo > MIBs)
Definition: ModuleSummaryIndex.h:357
llvm::Optional
Definition: APInt.h:33
llvm::VirtFuncOffset::VirtFuncOffset
VirtFuncOffset(ValueInfo VI, uint64_t Offset)
Definition: ModuleSummaryIndex.h:986
llvm::GlobalVarSummary::getVCallVisibility
GlobalObject::VCallVisibility getVCallVisibility() const
Definition: ModuleSummaryIndex.h:1060
llvm::GlobalValueSummary::isLive
bool isLive() const
Definition: ModuleSummaryIndex.h:488
llvm::GlobalValue::DefaultVisibility
@ DefaultVisibility
The GV is visible.
Definition: GlobalValue.h:63
llvm::mapped_iterator
Definition: STLExtras.h:405
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:1675
llvm::FunctionSummary::FSHT_AllNonCritical
@ FSHT_AllNonCritical
Definition: ModuleSummaryIndex.h:594
llvm::ModuleSummaryIndex::isGlobalValueLive
bool isGlobalValueLive(const GlobalValueSummary *GVS) const
Definition: ModuleSummaryIndex.h:1460
llvm::FunctionSummary::TypeIdInfo::TypeTestAssumeConstVCalls
std::vector< ConstVCall > TypeTestAssumeConstVCalls
List of virtual calls made by this function using (respectively) llvm.assume(llvm....
Definition: ModuleSummaryIndex.h:631
llvm::max
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:337
llvm::FunctionSummary::FFlags::ReturnDoesNotAlias
unsigned ReturnDoesNotAlias
Definition: ModuleSummaryIndex.h:642
llvm::AliasSummary::setAliasee
void setAliasee(ValueInfo &AliaseeVI, GlobalValueSummary *Aliasee)
Definition: ModuleSummaryIndex.h:541
llvm::FunctionSummary::FFlags::NoInline
unsigned NoInline
Definition: ModuleSummaryIndex.h:645
STLExtras.h
llvm::ValueInfo::Flags
Flags
Definition: ModuleSummaryIndex.h:169
llvm::GlobalValueSummary::GVFlags::NotEligibleToImport
unsigned NotEligibleToImport
Indicate if the global value cannot be imported (e.g.
Definition: ModuleSummaryIndex.h:384
llvm::FunctionSummary::FFlags::NoRecurse
unsigned NoRecurse
Definition: ModuleSummaryIndex.h:641
RHS
Value * RHS
Definition: X86PartialReduction.cpp:76
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:1630
llvm::GlobalValue::LinkageTypes
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:47
llvm::StringMap::find
iterator find(StringRef Key)
Definition: StringMap.h:217
llvm::FunctionSummary::ParamAccess::Call::Call
Call()=default
llvm::ModuleSummaryIndex::hasParamAccess
bool hasParamAccess() const
Definition: ModuleSummaryIndex.h:1458
llvm::yaml::MappingTraits
Definition: ModuleSummaryIndex.h:52
llvm::ModuleSummaryIndex::propagateAttributes
void propagateAttributes(const DenseSet< GlobalValue::GUID > &PreservedSymbols)
Do the access attribute and DSOLocal propagation in combined index.
Definition: ModuleSummaryIndex.cpp:250
llvm::ModuleSummaryIndex::end
gvsummary_iterator end()
Definition: ModuleSummaryIndex.h:1325
llvm::FunctionSummary::VFuncId::Offset
uint64_t Offset
Definition: ModuleSummaryIndex.h:604
llvm::AliasSummary::getAliasee
const GlobalValueSummary & getAliasee() const
Definition: ModuleSummaryIndex.h:553
llvm::ModuleSummaryIndex::getModuleId
uint64_t getModuleId(const StringRef ModPath) const
Get the module ID recorded for the given module path.
Definition: ModuleSummaryIndex.h:1600
llvm::GlobalValueSummary::getVisibility
GlobalValue::VisibilityTypes getVisibility() const
Definition: ModuleSummaryIndex.h:500
llvm::ValueInfo::isDSOLocal
bool isDSOLocal(bool WithDSOLocalPropagation=false) const
Checks if all summaries are DSO local (have the flag set).
Definition: ModuleSummaryIndex.cpp:54
llvm::GraphTraits< ValueInfo >::NodeRef
ValueInfo NodeRef
Definition: ModuleSummaryIndex.h:1752
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::FunctionSummary::allocs
ArrayRef< AllocInfo > allocs() const
Definition: ModuleSummaryIndex.h:940
llvm::GlobalValueSummary::refs
ArrayRef< ValueInfo > refs() const
Return the list of values referenced by this global value definition.
Definition: ModuleSummaryIndex.h:511
llvm::ModuleSummaryIndex::withDSOLocalPropagation
bool withDSOLocalPropagation() const
Definition: ModuleSummaryIndex.h:1429
llvm::GlobalValueSummary::GVFlags
Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
Definition: ModuleSummaryIndex.h:369
llvm::FunctionSummary::TypeIdInfo::TypeCheckedLoadVCalls
std::vector< VFuncId > TypeCheckedLoadVCalls
Definition: ModuleSummaryIndex.h:626
llvm::ValueInfo::WriteOnly
@ WriteOnly
Definition: ModuleSummaryIndex.h:169
llvm::VirtFuncOffset::FuncVI
ValueInfo FuncVI
Definition: ModuleSummaryIndex.h:989
llvm::FunctionSummary::ConstVCall
A specification for a virtual function call with all constant integer arguments.
Definition: ModuleSummaryIndex.h:610
llvm::ModuleSummaryIndex::size
size_t size() const
Definition: ModuleSummaryIndex.h:1327
llvm::ValueInfo::ValueInfo
ValueInfo()=default
llvm::CallsiteInfo::CallsiteInfo
CallsiteInfo(ValueInfo Callee, SmallVector< unsigned > Clones, SmallVector< unsigned > StackIdIndices)
Definition: ModuleSummaryIndex.h:311
llvm::ModuleSummaryIndex::setWithAttributePropagation
void setWithAttributePropagation()
Definition: ModuleSummaryIndex.h:1425
llvm::GlobalValueSummary
Function and variable summary information to aid decisions and implementation of importing.
Definition: ModuleSummaryIndex.h:363
llvm::DenseMapInfo
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: APInt.h:34
llvm::GlobalVarSummary::GVarFlags::MaybeWriteOnly
unsigned MaybeWriteOnly
Definition: ModuleSummaryIndex.h:1026
llvm::ValueInfo::name
StringRef name() const
Definition: ModuleSummaryIndex.h:191
llvm::GlobalValueSummaryInfo
Definition: ModuleSummaryIndex.h:126
GlobalValue.h
llvm::TypeIdOffsetVtableInfo::VTableVI
ValueInfo VTableVI
Definition: ModuleSummaryIndex.h:1188
llvm::GlobalValue::VisibilityTypes
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Definition: GlobalValue.h:62
llvm::GlobalVarSummary::GVarFlags
Definition: ModuleSummaryIndex.h:1011
llvm::FunctionSummary::EdgeTy
std::pair< ValueInfo, CalleeInfo > EdgeTy
<CalleeValueInfo, CalleeInfo> call edge pair.
Definition: ModuleSummaryIndex.h:589
llvm::FunctionSummary::ParamAccess::Call::Callee
ValueInfo Callee
Definition: ModuleSummaryIndex.h:713
llvm::GlobalVarSummary::GVarFlags::VCallVisibility
unsigned VCallVisibility
Definition: ModuleSummaryIndex.h:1038
SmallString.h
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::ModuleSummaryIndex::enableSplitLTOUnit
bool enableSplitLTOUnit() const
Definition: ModuleSummaryIndex.h:1452
llvm::ValueInfo::isWriteOnly
bool isWriteOnly() const
Definition: ModuleSummaryIndex.h:201
llvm::GlobalValueSummary::setCanAutoHide
void setCanAutoHide(bool CanAutoHide)
Definition: ModuleSummaryIndex.h:496
llvm::yaml::MappingTraits< ModuleSummaryIndex >
Definition: ModuleSummaryIndexYAML.h:279
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::GlobalValueSummaryInfo::NameOrGV
Definition: ModuleSummaryIndex.h:127
llvm::FunctionSummary::ParamAccess::Call::ParamNo
uint64_t ParamNo
Definition: ModuleSummaryIndex.h:712
llvm::StringMap::insert
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:275
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:866
llvm::CallsiteInfo::Callee
ValueInfo Callee
Definition: ModuleSummaryIndex.h:291
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:875
llvm::WholeProgramDevirtResolution::ByArg::Kind
Kind
Definition: ModuleSummaryIndex.h:1119
llvm::FunctionSummary::ForceSummaryHotnessType
ForceSummaryHotnessType
Types for -force-summary-edges-cold debugging option.
Definition: ModuleSummaryIndex.h:592
llvm::GlobalValueSummaryInfo::U
union llvm::GlobalValueSummaryInfo::NameOrGV U
llvm::GlobalValueSummary::GlobalVarKind
@ GlobalVarKind
Definition: ModuleSummaryIndex.h:366
llvm::GlobalValueSummary::flags
GVFlags flags() const
Get the flags for this GlobalValue (see struct GVFlags).
Definition: ModuleSummaryIndex.h:472
llvm::dwarf::Index
Index
Definition: Dwarf.h:472
llvm::CalleeInfo::HotnessType
HotnessType
Definition: ModuleSummaryIndex.h:58
llvm::CallsiteInfo
Summary of memprof callsite metadata.
Definition: ModuleSummaryIndex.h:289
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::ModuleSummaryIndex::modulePaths
StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths()
Table of modules, containing hash and id.
Definition: ModuleSummaryIndex.h:1595
llvm::WholeProgramDevirtResolution::ByArg::Byte
uint32_t Byte
Definition: ModuleSummaryIndex.h:1135
llvm::GlobalVarSummary::isConstant
bool isConstant() const
Definition: ModuleSummaryIndex.h:1056
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::FunctionSummary::mutableCalls
std::vector< EdgeTy > & mutableCalls()
Definition: ModuleSummaryIndex.h:859
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:291
llvm::GlobalValueSummary::getSummaryKind
SummaryKind getSummaryKind() const
Which kind of summary subclass this is.
Definition: ModuleSummaryIndex.h:462
llvm::FunctionSummary::ParamAccess::ParamAccess
ParamAccess(uint64_t ParamNo, const ConstantRange &Use)
Definition: ModuleSummaryIndex.h:734
llvm::getHotnessName
const char * getHotnessName(CalleeInfo::HotnessType HT)
Definition: ModuleSummaryIndex.h:106
llvm::GlobalVarSummary::maybeReadOnly
bool maybeReadOnly() const
Definition: ModuleSummaryIndex.h:1054
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:1541
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:1654
llvm::AllocInfo::AllocInfo
AllocInfo(std::vector< MIBInfo > MIBs)
Definition: ModuleSummaryIndex.h:354
llvm::ModuleSummaryIndex::getFlags
uint64_t getFlags() const
Definition: ModuleSummaryIndex.cpp:92
llvm::CalleeInfo::updateRelBlockFreq
void updateRelBlockFreq(uint64_t BlockFreq, uint64_t EntryFreq)
Update RelBlockFreq from BlockFreq and EntryFreq.
Definition: ModuleSummaryIndex.h:92
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:1553
llvm::ModuleSummaryIndex::withGlobalValueDeadStripping
bool withGlobalValueDeadStripping() const
Definition: ModuleSummaryIndex.h:1417
llvm::WholeProgramDevirtResolution::Kind
Kind
Definition: ModuleSummaryIndex.h:1108
llvm::WholeProgramDevirtResolution::BranchFunnel
@ BranchFunnel
When retpoline mitigation is enabled, use a branch funnel that is defined in the merged module.
Definition: ModuleSummaryIndex.h:1111
llvm::ValueInfo::ReadOnly
@ ReadOnly
Definition: ModuleSummaryIndex.h:169
llvm::FunctionSummary::FFlags::anyFlagSet
bool anyFlagSet()
Definition: ModuleSummaryIndex.h:678
llvm::TypeTestResolution::BitMask
uint8_t BitMask
Definition: ModuleSummaryIndex.h:1103
llvm::TypeTestResolution::Inline
@ Inline
Inlined bit vector ("Short Inline Bit Vectors")
Definition: ModuleSummaryIndex.h:1084
llvm::ValueInfo::getELFVisibility
GlobalValue::VisibilityTypes getELFVisibility() const
Returns the most constraining visibility among summaries.
Definition: ModuleSummaryIndex.cpp:42
llvm::GlobalValueSummary::GVFlags::Visibility
unsigned Visibility
Indicates the visibility.
Definition: ModuleSummaryIndex.h:380
llvm::GlobalValue::getGUID
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:585
llvm::FunctionSummary::addTypeTest
void addTypeTest(GlobalValue::GUID Guid)
Add a type test to the summary.
Definition: ModuleSummaryIndex.h:926
llvm::ModuleSummaryIndex::setHasSyntheticEntryCounts
void setHasSyntheticEntryCounts()
Definition: ModuleSummaryIndex.h:1443
llvm::CalleeInfo
Class to accumulate and hold information about a callee.
Definition: ModuleSummaryIndex.h:57
llvm::WholeProgramDevirtResolution::SingleImpl
@ SingleImpl
Single implementation devirtualization.
Definition: ModuleSummaryIndex.h:1110
llvm::StringMap< std::pair< uint64_t, ModuleHash > >
llvm::ValueInfo
Struct that holds a reference to a particular GUID in a global value summary.
Definition: ModuleSummaryIndex.h:168
llvm::SmallString< 256 >
llvm::CalleeInfo::HotnessType::None
@ None
llvm::ValueInfo::setReadOnly
void setReadOnly()
Definition: ModuleSummaryIndex.h:213
llvm::FunctionSummary::FFlags::HasUnknownCall
unsigned HasUnknownCall
Definition: ModuleSummaryIndex.h:655
llvm::ValueInfo::canAutoHide
bool canAutoHide() const
Checks if all copies are eligible for auto-hiding (have flag set).
Definition: ModuleSummaryIndex.cpp:67
llvm::TypeTestResolution::AlignLog2
uint64_t AlignLog2
Definition: ModuleSummaryIndex.h:1101
llvm::GlobalVarSummary::setVCallVisibility
void setVCallVisibility(GlobalObject::VCallVisibility Vis)
Definition: ModuleSummaryIndex.h:1057
llvm::WholeProgramDevirtResolution::SingleImplName
std::string SingleImplName
Definition: ModuleSummaryIndex.h:1116
llvm::AliasSummary::hasAliasee
bool hasAliasee() const
Definition: ModuleSummaryIndex.h:546
StringSaver.h
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:1567
llvm::GlobalVarSummary::maybeWriteOnly
bool maybeWriteOnly() const
Definition: ModuleSummaryIndex.h:1055
llvm::TypeTestResolution::Single
@ Single
Single element (last example in "Short Inline Bit Vectors")
Definition: ModuleSummaryIndex.h:1085
llvm::WholeProgramDevirtResolution::ByArg::UniformRetVal
@ UniformRetVal
Uniform return value optimization.
Definition: ModuleSummaryIndex.h:1121
llvm::PointerIntPair::getPointer
PointerTy getPointer() const
Definition: PointerIntPair.h:60
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:200
llvm::DenseSet
Implements a dense probed hash-table based set.
Definition: DenseSet.h:268
llvm::MIBInfo::StackIdIndices
SmallVector< unsigned > StackIdIndices
Definition: ModuleSummaryIndex.h:333
llvm::ModuleSummaryIndex::isGUIDLive
bool isGUIDLive(GlobalValue::GUID GUID) const
Definition: ModuleSummaryIndex.cpp:180
llvm::ModuleSummaryIndex::addOrGetStackIdIndex
unsigned addOrGetStackIdIndex(uint64_t StackId)
Definition: ModuleSummaryIndex.h:1331
llvm::FunctionSummary::VFuncId
An "identifier" for a virtual function.
Definition: ModuleSummaryIndex.h:602
llvm::AllocationType::NotCold
@ NotCold
llvm::CalleeInfo::HotnessType::Hot
@ Hot
llvm::GlobalValue
Definition: GlobalValue.h:44
VI
@ VI
Definition: SIInstrInfo.cpp:7883
llvm::WholeProgramDevirtResolution::ByArg::Indir
@ Indir
Just do a regular virtual call.
Definition: ModuleSummaryIndex.h:1120
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::GlobalValueSummary::linkage
GlobalValue::LinkageTypes linkage() const
Return linkage type recorded for this global value.
Definition: ModuleSummaryIndex.h:475
llvm::GlobalVarSummary::vTableFuncs
ArrayRef< VirtFuncOffset > vTableFuncs() const
Definition: ModuleSummaryIndex.h:1069
llvm::GlobalValueSummary::GVFlags::GVFlags
GVFlags(GlobalValue::LinkageTypes Linkage, GlobalValue::VisibilityTypes Visibility, bool NotEligibleToImport, bool Live, bool IsLocal, bool CanAutoHide)
Convenience Constructors.
Definition: ModuleSummaryIndex.h:409
llvm::WholeProgramDevirtResolution::Indir
@ Indir
Just do a regular virtual call.
Definition: ModuleSummaryIndex.h:1109
Index
uint32_t Index
Definition: ELFObjHandler.cpp:83
llvm::ValueInfo::getAccessSpecifier
unsigned getAccessSpecifier() const
Definition: ModuleSummaryIndex.h:205
uint64_t
llvm::ModuleSummaryIndex::dumpSCCs
void dumpSCCs(raw_ostream &OS)
Print out strongly connected components for debugging.
Definition: ModuleSummaryIndex.cpp:355
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:63
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:1467
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::ModuleSummaryIndex::getGUIDFromOriginalID
GlobalValue::GUID getGUIDFromOriginalID(GlobalValue::GUID OriginalID) const
Return the GUID for OriginalId in the OidGuidMap.
Definition: ModuleSummaryIndex.h:1504
llvm::DenseMap
Definition: DenseMap.h:714
llvm::ModuleSummaryIndex::getBlockCount
uint64_t getBlockCount() const
Definition: ModuleSummaryIndex.h:1319
llvm::AliasSummary::AliasSummary
AliasSummary(GVFlags Flags)
Definition: ModuleSummaryIndex.h:532
llvm::operator<
bool operator<(int64_t V1, const APSInt &V2)
Definition: APSInt.h:347
llvm::VTableFuncList
std::vector< VirtFuncOffset > VTableFuncList
List of functions referenced by a particular vtable definition.
Definition: ModuleSummaryIndex.h:993
llvm::ModuleSummaryIndex::releaseTemporaryMemory
void releaseTemporaryMemory()
Definition: ModuleSummaryIndex.h:1348
llvm::DenseMapInfo< FunctionSummary::ConstVCall >::getTombstoneKey
static FunctionSummary::ConstVCall getTombstoneKey()
Definition: ModuleSummaryIndex.h:968
llvm::FunctionSummary::FFlags::MustBeUnreachable
unsigned MustBeUnreachable
Definition: ModuleSummaryIndex.h:662
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::StringMap::lookup
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: StringMap.h:233
llvm::PointerIntPair::getInt
IntType getInt() const
Definition: PointerIntPair.h:62
StringExtras.h
llvm::GraphTraits< ValueInfo >::child_end
static ChildIteratorType child_end(NodeRef N)
Definition: ModuleSummaryIndex.h:1776
llvm::ModuleSummaryIndex::setBlockCount
void setBlockCount(uint64_t C)
Definition: ModuleSummaryIndex.h:1321
llvm::GraphTraits< ModuleSummaryIndex * >::getEntryNode
static NodeRef getEntryNode(ModuleSummaryIndex *I)
Definition: ModuleSummaryIndex.h:1809
llvm::ModuleSummaryIndex::print
void print(raw_ostream &OS, bool IsForDebug=false) const
Print to an output stream.
Definition: AsmWriter.cpp:4898
llvm::ModuleSummaryIndex::getTypeIdCompatibleVtableSummary
Optional< TypeIdCompatibleVtableInfo > getTypeIdCompatibleVtableSummary(StringRef TypeId) const
For the given TypeId, this returns the TypeIdCompatibleVtableMap entry if present in the summary map.
Definition: ModuleSummaryIndex.h:1704
llvm::ModuleSummaryIndex::skipModuleByDistributedBackend
bool skipModuleByDistributedBackend() const
Definition: ModuleSummaryIndex.h:1445
llvm::FunctionSummary::makeDummyFunctionSummary
static FunctionSummary makeDummyFunctionSummary(std::vector< FunctionSummary::EdgeTy > Edges)
Create an empty FunctionSummary (with specified call edges).
Definition: ModuleSummaryIndex.h:741
llvm::WholeProgramDevirtResolution::ByArg::UniqueRetVal
@ UniqueRetVal
Unique return value optimization.
Definition: ModuleSummaryIndex.h:1122
ArrayRef.h
llvm::gvsummary_iterator
GlobalValueSummaryMapTy::iterator gvsummary_iterator
Definition: ModuleSummaryIndex.h:1157
llvm::TypeIdSummary
Definition: ModuleSummaryIndex.h:1144
llvm::ModuleSummaryIndex::getGlobalNameForLocal
static std::string getGlobalNameForLocal(StringRef Name, StringRef Suffix)
Definition: ModuleSummaryIndex.h:1619
llvm::TypeIdOffsetVtableInfo::TypeIdOffsetVtableInfo
TypeIdOffsetVtableInfo(uint64_t Offset, ValueInfo VI)
Definition: ModuleSummaryIndex.h:1184
llvm::ModuleSummaryIndex::modulePaths
const StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths() const
Table of modules, containing module hash and id.
Definition: ModuleSummaryIndex.h:1590
llvm::ModuleSummaryIndex::addBlockCount
void addBlockCount(uint64_t C)
Definition: ModuleSummaryIndex.h:1320
llvm::CalleeInfo::Hotness
uint32_t Hotness
Definition: ModuleSummaryIndex.h:68
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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:1836
llvm::GlobalValueSummary::FunctionKind
@ FunctionKind
Definition: ModuleSummaryIndex.h:366
PreservedSymbols
static const char * PreservedSymbols[]
Definition: IRSymtab.cpp:48
llvm::ModuleSummaryIndex::getOrInsertValueInfo
ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID)
Return a ValueInfo for GUID.
Definition: ModuleSummaryIndex.h:1478
llvm::operator==
bool operator==(uint64_t V1, const APInt &V2)
Definition: APInt.h:2010
llvm::ModuleSummaryIndex::typeIds
const TypeIdSummaryMapTy & typeIds() const
Definition: ModuleSummaryIndex.h:1658
llvm::ModuleSummaryIndex::setWithDSOLocalPropagation
void setWithDSOLocalPropagation()
Definition: ModuleSummaryIndex.h:1430
llvm::ModuleSummaryIndex::begin
gvsummary_iterator begin()
Definition: ModuleSummaryIndex.h:1323
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::ModuleSummaryIndex::cfiFunctionDefs
std::set< std::string > & cfiFunctionDefs()
Definition: ModuleSummaryIndex.h:1509
llvm::ModuleSummaryIndex::ModuleSummaryIndex
ModuleSummaryIndex(bool HaveGVs, bool EnableSplitLTOUnit=false)
Definition: ModuleSummaryIndex.h:1298
llvm::FunctionSummary::FFlags
Flags specific to function summaries.
Definition: ModuleSummaryIndex.h:636
llvm::StringSaver
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
Definition: StringSaver.h:21
llvm::ModuleSummaryIndex::partiallySplitLTOUnits
bool partiallySplitLTOUnits() const
Definition: ModuleSummaryIndex.h:1455
llvm::DenseMapInfo< FunctionSummary::VFuncId >::getEmptyKey
static FunctionSummary::VFuncId getEmptyKey()
Definition: ModuleSummaryIndex.h:950
llvm::ModuleSummaryIndex::getStackIdAtIndex
uint64_t getStackIdAtIndex(unsigned Index) const
Definition: ModuleSummaryIndex.h:1338
llvm::FunctionSummary::setParamAccesses
void setParamAccesses(std::vector< ParamAccess > NewParams)
Sets the list of known uses of pointer parameters.
Definition: ModuleSummaryIndex.h:915
llvm::FunctionSummary::instCount
unsigned instCount() const
Get the instruction count recorded for this function.
Definition: ModuleSummaryIndex.h:848
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::GlobalValueSummary::SummaryKind
SummaryKind
Sububclass discriminator (for dyn_cast<> et al.)
Definition: ModuleSummaryIndex.h:366
llvm::CalleeInfo::HotnessType::Unknown
@ Unknown
llvm::min
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Definition: FileCheck.cpp:357
llvm::ModuleSummaryIndex::exportToDot
void exportToDot(raw_ostream &OS, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols) const
Export summary to dot file for GraphViz.
Definition: ModuleSummaryIndex.cpp:536
llvm::ModuleSummaryIndex::setFlags
void setFlags(uint64_t Flags)
Definition: ModuleSummaryIndex.cpp:113
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::ModuleSummaryIndex::setWithWholeProgramVisibility
void setWithWholeProgramVisibility()
Definition: ModuleSummaryIndex.h:1433
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::GlobalValueSummary::AliasKind
@ AliasKind
Definition: ModuleSummaryIndex.h:366
llvm::ModuleSummaryIndex::getValueInfo
ValueInfo getValueInfo(GlobalValue::GUID GUID) const
Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
Definition: ModuleSummaryIndex.h:1472
llvm::GlobalValueSummaryInfo::NameOrGV::NameOrGV
NameOrGV(bool HaveGVs)
Definition: ModuleSummaryIndex.h:128
uint32_t
llvm::ModuleSummaryIndex::collectDefinedGVSummariesPerModule
void collectDefinedGVSummariesPerModule(Map &ModuleToDefinedGVSummaries) const
Collect for each module the list of Summaries it defines (GUID -> Summary).
Definition: ModuleSummaryIndex.h:1720
llvm::ValueInfo::haveGVs
bool haveGVs() const
Definition: ModuleSummaryIndex.h:196
llvm::PointerIntPair::setPointer
void setPointer(PointerTy PtrVal) &
Definition: PointerIntPair.h:64
llvm::GlobalValueSummary::GlobalValueSummary
GlobalValueSummary(SummaryKind K, GVFlags Flags, std::vector< ValueInfo > Refs)
Definition: ModuleSummaryIndex.h:445
llvm::FunctionSummary::ParamAccess::Call::Call
Call(uint64_t ParamNo, ValueInfo Callee, const ConstantRange &Offsets)
Definition: ModuleSummaryIndex.h:717
ConstantRange.h
llvm::AllocationType
AllocationType
Definition: ModuleSummaryIndex.h:322
llvm::CalleeInfo::updateHotness
void updateHotness(const HotnessType OtherHotness)
Definition: ModuleSummaryIndex.h:81
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::AliasSummary::getAliasee
GlobalValueSummary & getAliasee()
Definition: ModuleSummaryIndex.h:558
llvm::TypeTestResolution
Definition: ModuleSummaryIndex.h:1076
llvm::TypeIdCompatibleVtableInfo
std::vector< TypeIdOffsetVtableInfo > TypeIdCompatibleVtableInfo
List of vtable definitions decorated by a particular type identifier, and their corresponding offsets...
Definition: ModuleSummaryIndex.h:1194
llvm::ModuleSummaryIndex::cfiFunctionDecls
std::set< std::string > & cfiFunctionDecls()
Definition: ModuleSummaryIndex.h:1512
llvm::GlobalValueSummaryInfo::NameOrGV::Name
StringRef Name
Summary string representation.
Definition: ModuleSummaryIndex.h:146
llvm::ValueInfo::RefAndFlags
PointerIntPair< const GlobalValueSummaryMapTy::value_type *, 3, int > RefAndFlags
Definition: ModuleSummaryIndex.h:171
llvm::FunctionSummary::FSHT_None
@ FSHT_None
Definition: ModuleSummaryIndex.h:593
llvm::FunctionSummary::entryCount
uint64_t entryCount() const
Get the synthetic entry count for this function.
Definition: ModuleSummaryIndex.h:851
llvm::TypeTestResolution::TheKind
enum llvm::TypeTestResolution::Kind TheKind
llvm::TypeTestResolution::Unknown
@ Unknown
Unknown (analysis not performed, don't lower)
Definition: ModuleSummaryIndex.h:1088
ScaledNumber.h
llvm::CallsiteInfo::CallsiteInfo
CallsiteInfo(ValueInfo Callee, SmallVector< unsigned > StackIdIndices)
Definition: ModuleSummaryIndex.h:309
llvm::GlobalVarSummary::setVTableFuncs
void setVTableFuncs(VTableFuncList Funcs)
Definition: ModuleSummaryIndex.h:1064
llvm::ValueInfo::getRef
const GlobalValueSummaryMapTy::value_type * getRef() const
Definition: ModuleSummaryIndex.h:224
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:1736
llvm::ModuleSummaryIndex::canImportGlobalVar
bool canImportGlobalVar(GlobalValueSummary *S, bool AnalyzeRefs) const
Checks if we can import global variable from another module.
Definition: ModuleSummaryIndex.cpp:320
llvm::CalleeInfo::CalleeInfo
CalleeInfo()
Definition: ModuleSummaryIndex.h:76
llvm::GlobalVarSummary::GVarFlags::Constant
unsigned Constant
Definition: ModuleSummaryIndex.h:1035
llvm::DenseMapInfo< FunctionSummary::VFuncId >::getHashValue
static unsigned getHashValue(FunctionSummary::VFuncId I)
Definition: ModuleSummaryIndex.h:960
llvm::GlobalValueSummaryList
std::vector< std::unique_ptr< GlobalValueSummary > > GlobalValueSummaryList
Definition: ModuleSummaryIndex.h:124
llvm::CalleeInfo::HotnessType::Critical
@ Critical
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:884
llvm::DenseMapInfo< ValueInfo >::getHashValue
static unsigned getHashValue(ValueInfo I)
Definition: ModuleSummaryIndex.h:285
llvm::ModuleSummaryIndex::cfiFunctionDecls
const std::set< std::string > & cfiFunctionDecls() const
Definition: ModuleSummaryIndex.h:1513
llvm::ScaledNumber< uint64_t >
llvm::DenseMapInfo< FunctionSummary::ConstVCall >::getEmptyKey
static FunctionSummary::ConstVCall getEmptyKey()
Definition: ModuleSummaryIndex.h:964
llvm::FunctionSummary::ExternalNode
static FunctionSummary ExternalNode
A dummy node to reference external functions that aren't in the index.
Definition: ModuleSummaryIndex.h:760
llvm::GlobalVarSummary::varflags
GVarFlags varflags() const
Definition: ModuleSummaryIndex.h:1051
llvm::WholeProgramDevirtResolution::ByArg
Definition: ModuleSummaryIndex.h:1118
llvm::MIBInfo::AllocType
AllocationType AllocType
Definition: ModuleSummaryIndex.h:327
llvm::FunctionSummary
Function summary information to aid decisions and implementation of importing.
Definition: ModuleSummaryIndex.h:586
llvm::TypeTestResolution::SizeM1
uint64_t SizeM1
Definition: ModuleSummaryIndex.h:1102
llvm::ModuleSummaryIndex::setWithGlobalValueDeadStripping
void setWithGlobalValueDeadStripping()
Definition: ModuleSummaryIndex.h:1420
llvm::GlobalObject::VCallVisibility
VCallVisibility
Definition: GlobalObject.h:32
std
Definition: BitVector.h:851
llvm::None
constexpr std::nullopt_t None
Definition: None.h:27
llvm::AliasSummary::classof
static bool classof(const GlobalValueSummary *GVS)
Check if this is an alias summary.
Definition: ModuleSummaryIndex.h:537
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:731
llvm::FunctionSummary::ParamAccess::RangeWidth
static constexpr uint32_t RangeWidth
Definition: ModuleSummaryIndex.h:706
get
Should compile to something r4 addze r3 instead we get
Definition: README.txt:24
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:456
llvm::FunctionSummary::FFlags::ReadNone
unsigned ReadNone
Definition: ModuleSummaryIndex.h:639
llvm::ModuleSummaryIndex::calculateCallGraphRoot
FunctionSummary calculateCallGraphRoot()
Definition: ModuleSummaryIndex.h:1388
llvm::ModuleSummaryIndex::cfiFunctionDefs
const std::set< std::string > & cfiFunctionDefs() const
Definition: ModuleSummaryIndex.h:1510
llvm::GlobalValue::getGUID
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:589
llvm::ModuleSummaryIndex::typeIdCompatibleVtableMap
const auto & typeIdCompatibleVtableMap() const
Definition: ModuleSummaryIndex.h:1689
llvm::CalleeInfo::RelBlockFreq
uint32_t RelBlockFreq
The value stored in RelBlockFreq has to be interpreted as the digits of a scaled number with a scale ...
Definition: ModuleSummaryIndex.h:72
llvm::CalleeInfo::getHotness
HotnessType getHotness() const
Definition: ModuleSummaryIndex.h:85
llvm::DenseMapInfo< FunctionSummary::VFuncId >::getTombstoneKey
static FunctionSummary::VFuncId getTombstoneKey()
Definition: ModuleSummaryIndex.h:952
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:406
llvm::WholeProgramDevirtResolution::ByArg::Info
uint64_t Info
Additional information for the resolution:
Definition: ModuleSummaryIndex.h:1130
llvm::WholeProgramDevirtResolution::ByArg::VirtualConstProp
@ VirtualConstProp
Virtual constant propagation.
Definition: ModuleSummaryIndex.h:1123
llvm::AllocationType::Cold
@ Cold
llvm::MIBInfo
Summary of a single MIB in a memprof metadata on allocations.
Definition: ModuleSummaryIndex.h:325
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:1577
llvm::FunctionSummary::FFlags::MayThrow
unsigned MayThrow
Definition: ModuleSummaryIndex.h:652
llvm::FunctionSummary::setNoRecurse
void setNoRecurse()
Definition: ModuleSummaryIndex.h:843
llvm::GlobalVarSummary::setReadOnly
void setReadOnly(bool RO)
Definition: ModuleSummaryIndex.h:1052
Scaled64
ScaledNumber< uint64_t > Scaled64
Definition: SyntheticCountsPropagation.cpp:37
llvm::FunctionSummary::specialRefCounts
std::pair< unsigned, unsigned > specialRefCounts() const
Definition: ModuleSummaryIndex.cpp:77
isEqual
static bool isEqual(const Function &Caller, const Function &Callee)
Definition: Attributes.cpp:1952
llvm::StringMap::count
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Definition: StringMap.h:245
llvm::SmallString::str
StringRef str() const
Explicit conversion to StringRef.
Definition: SmallString.h:260
llvm::ModuleSummaryIndex::BitcodeSummaryVersion
static constexpr uint64_t BitcodeSummaryVersion
Definition: ModuleSummaryIndex.h:1307
llvm::ModuleSummaryIndex::dump
void dump() const
Dump to stderr (for debugging).
Definition: AsmWriter.cpp:4960
AllocType
AllocType
Definition: MemoryBuiltins.cpp:54
llvm::ConstantRange
This class represents a range of values.
Definition: ConstantRange.h:47
llvm::FunctionSummary::FunctionSummary
FunctionSummary(GVFlags Flags, unsigned NumInsts, FFlags FunFlags, uint64_t EntryCount, std::vector< ValueInfo > Refs, std::vector< 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:804
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:1149
llvm::WholeProgramDevirtResolution::TheKind
enum llvm::WholeProgramDevirtResolution::Kind TheKind
llvm::ModuleSummaryIndex::isWriteOnly
bool isWriteOnly(const GlobalVarSummary *GVS) const
Definition: ModuleSummaryIndex.h:1438
llvm::GlobalVarSummary::classof
static bool classof(const GlobalValueSummary *GVS)
Check if this is a global variable summary.
Definition: ModuleSummaryIndex.h:1047
llvm::ModuleSummaryIndex::setSkipModuleByDistributedBackend
void setSkipModuleByDistributedBackend()
Definition: ModuleSummaryIndex.h:1448
llvm::ModuleSummaryIndex::addGlobalValueSummary
void addGlobalValueSummary(const GlobalValue &GV, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for a value.
Definition: ModuleSummaryIndex.h:1516
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:901
llvm::GlobalValueSummary::setLinkage
void setLinkage(GlobalValue::LinkageTypes Linkage)
Sets the linkage to the value determined by global summary-based optimization.
Definition: ModuleSummaryIndex.h:481
llvm::ValueInfo::setWriteOnly
void setWriteOnly()
Definition: ModuleSummaryIndex.h:219
llvm::GraphTraits< ValueInfo >::child_edge_begin
static ChildEdgeIteratorType child_edge_begin(NodeRef N)
Definition: ModuleSummaryIndex.h:1786
llvm::GlobalValueSummary::canAutoHide
bool canAutoHide() const
Definition: ModuleSummaryIndex.h:498
llvm::PointerIntPair< const GlobalValueSummaryMapTy::value_type *, 3, int >
llvm::GraphTraits< ValueInfo >::valueInfoFromEdge
static NodeRef valueInfoFromEdge(FunctionSummary::EdgeTy &P)
Definition: ModuleSummaryIndex.h:1755
llvm::TypeIdSummary::TTRes
TypeTestResolution TTRes
Definition: ModuleSummaryIndex.h:1145
SmallVector.h
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:572
llvm::AllocInfo::MIBs
std::vector< MIBInfo > MIBs
Definition: ModuleSummaryIndex.h:352
llvm::ModuleSummaryIndex
Class to hold module path string table and global value map, and encapsulate methods for operating on...
Definition: ModuleSummaryIndex.h:1198
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:1613
llvm::GlobalValueSummary::modulePath
StringRef modulePath() const
Get the path to the module containing this function.
Definition: ModuleSummaryIndex.h:469
llvm::FunctionSummary::FSHT_All
@ FSHT_All
Definition: ModuleSummaryIndex.h:595
llvm::FunctionSummary::ParamAccess
Describes the uses of a parameter by the function.
Definition: ModuleSummaryIndex.h:705
llvm::CalleeInfo::CalleeInfo
CalleeInfo(HotnessType Hotness, uint64_t RelBF)
Definition: ModuleSummaryIndex.h:78
N
#define N
llvm::ModuleSummaryIndex::getOrInsertValueInfo
ValueInfo getOrInsertValueInfo(const GlobalValue *GV)
Return a ValueInfo for GV and mark it as belonging to GV.
Definition: ModuleSummaryIndex.h:1496
llvm::StringSaver::save
StringRef save(const char *S)
Definition: StringSaver.h:30
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:711
llvm::MIBInfo::MIBInfo
MIBInfo(AllocationType AllocType, SmallVector< unsigned > StackIdIndices)
Definition: ModuleSummaryIndex.h:335
llvm::GlobalValueSummaryInfo::GlobalValueSummaryInfo
GlobalValueSummaryInfo(bool HaveGVs)
Definition: ModuleSummaryIndex.h:149
llvm::AllocationType::None
@ None
llvm::GlobalVarSummary::GVarFlags::GVarFlags
GVarFlags(bool ReadOnly, bool WriteOnly, bool Constant, GlobalObject::VCallVisibility Vis)
Definition: ModuleSummaryIndex.h:1012
llvm::TypeIdOffsetVtableInfo::AddressPointOffset
uint64_t AddressPointOffset
Definition: ModuleSummaryIndex.h:1187
llvm::CallsiteInfo::Clones
SmallVector< unsigned > Clones
Definition: ModuleSummaryIndex.h:301
llvm::GlobalValueSummary::~GlobalValueSummary
virtual ~GlobalValueSummary()=default
llvm::WholeProgramDevirtResolution
Definition: ModuleSummaryIndex.h:1107
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:621
llvm::FunctionSummary::setEntryCount
void setEntryCount(uint64_t EC)
Set the synthetic entry count for this function.
Definition: ModuleSummaryIndex.h:854
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:152
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:391
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:395
llvm::FunctionSummary::FFlags::NoUnwind
unsigned NoUnwind
Definition: ModuleSummaryIndex.h:650
llvm::AllocInfo
Summary of memprof metadata on allocations.
Definition: ModuleSummaryIndex.h:340
llvm::CalleeInfo::ScaleShift
static constexpr int32_t ScaleShift
Definition: ModuleSummaryIndex.h:73
llvm::ValueInfo::isValidAccessSpecifier
bool isValidAccessSpecifier() const
Definition: ModuleSummaryIndex.h:209
llvm::GraphTraits
Definition: GraphTraits.h:37
StringMap.h
llvm::ModuleSummaryIndex::withAttributePropagation
bool withAttributePropagation() const
Definition: ModuleSummaryIndex.h:1424
llvm::ModuleSummaryIndex::addGlobalValueSummary
void addGlobalValueSummary(ValueInfo VI, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for the given ValueInfo.
Definition: ModuleSummaryIndex.h:1529
llvm::DenseMapInfo< ValueInfo >::getTombstoneKey
static ValueInfo getTombstoneKey()
Definition: ModuleSummaryIndex.h:271
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:1356
llvm::FunctionSummary::TypeIdInfo::TypeTestAssumeVCalls
std::vector< VFuncId > TypeTestAssumeVCalls
List of virtual calls made by this function using (respectively) llvm.assume(llvm....
Definition: ModuleSummaryIndex.h:626
raw_ostream.h
llvm::TypeTestResolution::ByteArray
@ ByteArray
Test a byte array (first example)
Definition: ModuleSummaryIndex.h:1083
llvm::TypeIdSummaryMapTy
std::multimap< GlobalValue::GUID, std::pair< std::string, TypeIdSummary > > TypeIdSummaryMapTy
Map of a type GUID to type id string and summary (multimap used in case of GUID conflicts).
Definition: ModuleSummaryIndex.h:1171
llvm::DenseMapInfo< FunctionSummary::ConstVCall >::getHashValue
static unsigned getHashValue(FunctionSummary::ConstVCall I)
Definition: ModuleSummaryIndex.h:978
llvm::FunctionSummary::ConstVCall::VFunc
VFuncId VFunc
Definition: ModuleSummaryIndex.h:611
llvm::ModuleSummaryIndex::withWholeProgramVisibility
bool withWholeProgramVisibility() const
Definition: ModuleSummaryIndex.h:1432
llvm::GlobalValueSummary::setOriginalName
void setOriginalName(GlobalValue::GUID Name)
Initialize the original name hash in this summary.
Definition: ModuleSummaryIndex.h:459
llvm::ModuleHash
std::array< uint32_t, 5 > ModuleHash
160 bits SHA1
Definition: ModuleSummaryIndex.h:1153
llvm::raw_string_ostream::str
std::string & str()
Returns the string's reference.
Definition: raw_ostream.h:647
llvm::FunctionSummary::VFuncId::GUID
GlobalValue::GUID GUID
Definition: ModuleSummaryIndex.h:603
llvm::GlobalVarSummary::VarFlags
struct llvm::GlobalVarSummary::GVarFlags VarFlags
llvm::GraphTraits< ValueInfo >::EdgeRef
FunctionSummary::EdgeTy & EdgeRef
Definition: ModuleSummaryIndex.h:1753
llvm::WholeProgramDevirtResolution::ByArg::Bit
uint32_t Bit
Definition: ModuleSummaryIndex.h:1136
llvm::FunctionSummary::TypeIdInfo::TypeCheckedLoadConstVCalls
std::vector< ConstVCall > TypeCheckedLoadConstVCalls
Definition: ModuleSummaryIndex.h:632
llvm::ModuleSummaryIndex::addModule
ModuleInfo * addModule(StringRef ModPath, uint64_t ModId, 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:1639
llvm::FunctionSummary::getTypeIdInfo
const TypeIdInfo * getTypeIdInfo() const
Definition: ModuleSummaryIndex.h:932
llvm::DenseMapInfo< ValueInfo >::isSpecialKey
static bool isSpecialKey(ValueInfo V)
Definition: ModuleSummaryIndex.h:275
llvm::AliasSummary::getAliaseeGUID
GlobalValue::GUID getAliaseeGUID() const
Definition: ModuleSummaryIndex.h:566
llvm::GlobalVarSummary::GVarFlags::MaybeReadOnly
unsigned MaybeReadOnly
Definition: ModuleSummaryIndex.h:1022
llvm::ValueInfo::isReadOnly
bool isReadOnly() const
Definition: ModuleSummaryIndex.h:197
llvm::TypeTestResolution::SizeM1BitWidth
unsigned SizeM1BitWidth
Range of size-1 expressed as a bit width.
Definition: ModuleSummaryIndex.h:1094
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
llvm::DenseMapInfo< FunctionSummary::ConstVCall >::isEqual
static bool isEqual(FunctionSummary::ConstVCall L, FunctionSummary::ConstVCall R)
Definition: ModuleSummaryIndex.h:972
llvm::GraphTraits< ValueInfo >
GraphTraits definition to build SCC for the index.
Definition: ModuleSummaryIndex.h:1751
llvm::AliasSummary::getAliaseeVI
ValueInfo getAliaseeVI() const
Definition: ModuleSummaryIndex.h:562
llvm::FunctionSummary::callsites
ArrayRef< CallsiteInfo > callsites() const
Definition: ModuleSummaryIndex.h:934
llvm::GlobalValueSummary::setDSOLocal
void setDSOLocal(bool Local)
Definition: ModuleSummaryIndex.h:492
llvm::ModuleSummaryIndex::getOrInsertTypeIdCompatibleVtableSummary
TypeIdCompatibleVtableInfo & getOrInsertTypeIdCompatibleVtableSummary(StringRef TypeId)
Return an existing or new TypeIdCompatibleVtableMap entry for TypeId.
Definition: ModuleSummaryIndex.h:1697
llvm::ModuleSummaryIndex::getRegularLTOModuleName
static constexpr const char * getRegularLTOModuleName()
Definition: ModuleSummaryIndex.h:1310