LLVM  4.0.0
ModuleSummaryIndex.h
Go to the documentation of this file.
1 //===-- llvm/ModuleSummaryIndex.h - Module Summary Index --------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// @file
11 /// ModuleSummaryIndex.h This file contains the declarations the classes that
12 /// hold the module index and summary for function importing.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_IR_MODULESUMMARYINDEX_H
17 #define LLVM_IR_MODULESUMMARYINDEX_H
18 
19 #include "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/DenseSet.h"
21 #include "llvm/ADT/STLExtras.h"
22 #include "llvm/ADT/SmallString.h"
23 #include "llvm/ADT/StringExtras.h"
24 #include "llvm/ADT/StringMap.h"
25 #include "llvm/IR/Module.h"
26 
27 #include <array>
28 
29 namespace llvm {
30 
31 namespace yaml {
32 template <typename T> struct MappingTraits;
33 }
34 
35 /// \brief Class to accumulate and hold information about a callee.
36 struct CalleeInfo {
37  enum class HotnessType : uint8_t { Unknown = 0, Cold = 1, None = 2, Hot = 3 };
39 
40  CalleeInfo() = default;
41  explicit CalleeInfo(HotnessType Hotness) : Hotness(Hotness) {}
42 
43  void updateHotness(const HotnessType OtherHotness) {
44  Hotness = std::max(Hotness, OtherHotness);
45  }
46 };
47 
48 /// Struct to hold value either by GUID or GlobalValue*. Values in combined
49 /// indexes as well as indirect calls are GUIDs, all others are GlobalValues.
50 struct ValueInfo {
51  /// The value representation used in this instance.
55  };
56 
57  /// Union of the two possible value types.
58  union ValueUnion {
60  const GlobalValue *GV;
62  ValueUnion(const GlobalValue *GV) : GV(GV) {}
63  };
64 
65  /// The value being represented.
67  /// The value representation.
69  /// Constructor for a GUID value
71  /// Constructor for a GlobalValue* value
73  /// Accessor for GUID value
75  assert(Kind == VI_GUID && "Not a GUID type");
76  return TheValue.Id;
77  }
78  /// Accessor for GlobalValue* value
79  const GlobalValue *getValue() const {
80  assert(Kind == VI_Value && "Not a Value type");
81  return TheValue.GV;
82  }
83  bool isGUID() const { return Kind == VI_GUID; }
84 };
85 
86 template <> struct DenseMapInfo<ValueInfo> {
87  static inline ValueInfo getEmptyKey() { return ValueInfo((GlobalValue *)-1); }
88  static inline ValueInfo getTombstoneKey() {
89  return ValueInfo((GlobalValue *)-2);
90  }
91  static bool isEqual(ValueInfo L, ValueInfo R) {
92  if (L.isGUID() != R.isGUID())
93  return false;
94  return L.isGUID() ? (L.getGUID() == R.getGUID())
95  : (L.getValue() == R.getValue());
96  }
97  static unsigned getHashValue(ValueInfo I) {
98  return I.isGUID() ? I.getGUID() : (uintptr_t)I.getValue();
99  }
100 };
101 
102 /// \brief Function and variable summary information to aid decisions and
103 /// implementation of importing.
105 public:
106  /// \brief Sububclass discriminator (for dyn_cast<> et al.)
108 
109  /// Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
110  struct GVFlags {
111  /// \brief The linkage type of the associated global value.
112  ///
113  /// One use is to flag values that have local linkage types and need to
114  /// have module identifier appended before placing into the combined
115  /// index, to disambiguate from other values with the same name.
116  /// In the future this will be used to update and optimize linkage
117  /// types based on global summary-based analysis.
118  unsigned Linkage : 4;
119 
120  /// Indicate if the global value cannot be imported (e.g. it cannot
121  /// be renamed or references something that can't be renamed).
122  unsigned NotEligibleToImport : 1;
123 
124  /// Indicate that the global value must be considered a live root for
125  /// index-based liveness analysis. Used for special LLVM values such as
126  /// llvm.global_ctors that the linker does not know about.
127  unsigned LiveRoot : 1;
128 
129  /// Convenience Constructors
131  bool NotEligibleToImport, bool LiveRoot)
132  : Linkage(Linkage), NotEligibleToImport(NotEligibleToImport),
133  LiveRoot(LiveRoot) {}
134  };
135 
136 private:
137  /// Kind of summary for use in dyn_cast<> et al.
138  SummaryKind Kind;
139 
140  GVFlags Flags;
141 
142  /// This is the hash of the name of the symbol in the original file. It is
143  /// identical to the GUID for global symbols, but differs for local since the
144  /// GUID includes the module level id in the hash.
145  GlobalValue::GUID OriginalName;
146 
147  /// \brief Path of module IR containing value's definition, used to locate
148  /// module during importing.
149  ///
150  /// This is only used during parsing of the combined index, or when
151  /// parsing the per-module index for creation of the combined summary index,
152  /// not during writing of the per-module index which doesn't contain a
153  /// module path string table.
154  StringRef ModulePath;
155 
156  /// List of values referenced by this global value's definition
157  /// (either by the initializer of a global variable, or referenced
158  /// from within a function). This does not include functions called, which
159  /// are listed in the derived FunctionSummary object.
160  std::vector<ValueInfo> RefEdgeList;
161 
162 protected:
163  /// GlobalValueSummary constructor.
164  GlobalValueSummary(SummaryKind K, GVFlags Flags, std::vector<ValueInfo> Refs)
165  : Kind(K), Flags(Flags), RefEdgeList(std::move(Refs)) {}
166 
167 public:
168  virtual ~GlobalValueSummary() = default;
169 
170  /// Returns the hash of the original name, it is identical to the GUID for
171  /// externally visible symbols, but not for local ones.
172  GlobalValue::GUID getOriginalName() { return OriginalName; }
173 
174  /// Initialize the original name hash in this summary.
175  void setOriginalName(GlobalValue::GUID Name) { OriginalName = Name; }
176 
177  /// Which kind of summary subclass this is.
178  SummaryKind getSummaryKind() const { return Kind; }
179 
180  /// Set the path to the module containing this function, for use in
181  /// the combined index.
182  void setModulePath(StringRef ModPath) { ModulePath = ModPath; }
183 
184  /// Get the path to the module containing this function.
185  StringRef modulePath() const { return ModulePath; }
186 
187  /// Get the flags for this GlobalValue (see \p struct GVFlags).
188  GVFlags flags() { return Flags; }
189 
190  /// Return linkage type recorded for this global value.
192  return static_cast<GlobalValue::LinkageTypes>(Flags.Linkage);
193  }
194 
195  /// Sets the linkage to the value determined by global summary-based
196  /// optimization. Will be applied in the ThinLTO backends.
198  Flags.Linkage = Linkage;
199  }
200 
201  /// Return true if this global value can't be imported.
202  bool notEligibleToImport() const { return Flags.NotEligibleToImport; }
203 
204  /// Return true if this global value must be considered a root for live
205  /// value analysis on the index.
206  bool liveRoot() const { return Flags.LiveRoot; }
207 
208  /// Flag that this global value must be considered a root for live
209  /// value analysis on the index.
210  void setLiveRoot() { Flags.LiveRoot = true; }
211 
212  /// Flag that this global value cannot be imported.
214 
215  /// Return the list of values referenced by this global value definition.
216  ArrayRef<ValueInfo> refs() const { return RefEdgeList; }
217 };
218 
219 /// \brief Alias summary information.
221  GlobalValueSummary *AliaseeSummary;
222 
223 public:
224  /// Summary constructors.
225  AliasSummary(GVFlags Flags, std::vector<ValueInfo> Refs)
226  : GlobalValueSummary(AliasKind, Flags, std::move(Refs)) {}
227 
228  /// Check if this is an alias summary.
229  static bool classof(const GlobalValueSummary *GVS) {
230  return GVS->getSummaryKind() == AliasKind;
231  }
232 
233  void setAliasee(GlobalValueSummary *Aliasee) { AliaseeSummary = Aliasee; }
234 
236  return const_cast<AliasSummary *>(this)->getAliasee();
237  }
238 
240  assert(AliaseeSummary && "Unexpected missing aliasee summary");
241  return *AliaseeSummary;
242  }
243 };
244 
245 /// \brief Function summary information to aid decisions and implementation of
246 /// importing.
248 public:
249  /// <CalleeValueInfo, CalleeInfo> call edge pair.
250  typedef std::pair<ValueInfo, CalleeInfo> EdgeTy;
251 
252 private:
253  /// Number of instructions (ignoring debug instructions, e.g.) computed
254  /// during the initial compile step when the summary index is first built.
255  unsigned InstCount;
256 
257  /// List of <CalleeValueInfo, CalleeInfo> call edge pairs from this function.
258  std::vector<EdgeTy> CallGraphEdgeList;
259 
260  /// List of type identifiers used by this function, represented as GUIDs.
261  std::vector<GlobalValue::GUID> TypeIdList;
262 
263 public:
264  /// Summary constructors.
265  FunctionSummary(GVFlags Flags, unsigned NumInsts, std::vector<ValueInfo> Refs,
266  std::vector<EdgeTy> CGEdges,
267  std::vector<GlobalValue::GUID> TypeIds)
268  : GlobalValueSummary(FunctionKind, Flags, std::move(Refs)),
269  InstCount(NumInsts), CallGraphEdgeList(std::move(CGEdges)),
270  TypeIdList(std::move(TypeIds)) {}
271 
272  /// Check if this is a function summary.
273  static bool classof(const GlobalValueSummary *GVS) {
274  return GVS->getSummaryKind() == FunctionKind;
275  }
276 
277  /// Get the instruction count recorded for this function.
278  unsigned instCount() const { return InstCount; }
279 
280  /// Return the list of <CalleeValueInfo, CalleeInfo> pairs.
281  ArrayRef<EdgeTy> calls() const { return CallGraphEdgeList; }
282 
283  /// Returns the list of type identifiers used by this function.
284  ArrayRef<GlobalValue::GUID> type_tests() const { return TypeIdList; }
285 };
286 
287 /// \brief Global variable summary information to aid decisions and
288 /// implementation of importing.
289 ///
290 /// Currently this doesn't add anything to the base \p GlobalValueSummary,
291 /// but is a placeholder as additional info may be added to the summary
292 /// for variables.
294 
295 public:
296  /// Summary constructors.
297  GlobalVarSummary(GVFlags Flags, std::vector<ValueInfo> Refs)
298  : GlobalValueSummary(GlobalVarKind, Flags, std::move(Refs)) {}
299 
300  /// Check if this is a global variable summary.
301  static bool classof(const GlobalValueSummary *GVS) {
302  return GVS->getSummaryKind() == GlobalVarKind;
303  }
304 };
305 
307  /// Specifies which kind of type check we should emit for this byte array.
308  /// See http://clang.llvm.org/docs/ControlFlowIntegrityDesign.html for full
309  /// details on each kind of check; the enumerators are described with
310  /// reference to that document.
311  enum Kind {
312  Unsat, ///< Unsatisfiable type (i.e. no global has this type metadata)
313  ByteArray, ///< Test a byte array (first example)
314  Inline, ///< Inlined bit vector ("Short Inline Bit Vectors")
315  Single, ///< Single element (last example in "Short Inline Bit Vectors")
316  AllOnes, ///< All-ones bit vector ("Eliminating Bit Vector Checks for
317  /// All-Ones Bit Vectors")
318  } TheKind = Unsat;
319 
320  /// Range of size-1 expressed as a bit width. For example, if the size is in
321  /// range [1,256], this number will be 8. This helps generate the most compact
322  /// instruction sequences.
323  unsigned SizeM1BitWidth = 0;
324 };
325 
328 };
329 
330 /// 160 bits SHA1
331 typedef std::array<uint32_t, 5> ModuleHash;
332 
333 /// List of global value summary structures for a particular value held
334 /// in the GlobalValueMap. Requires a vector in the case of multiple
335 /// COMDAT values of the same name.
336 typedef std::vector<std::unique_ptr<GlobalValueSummary>> GlobalValueSummaryList;
337 
338 /// Map from global value GUID to corresponding summary structures.
339 /// Use a std::map rather than a DenseMap since it will likely incur
340 /// less overhead, as the value type is not very small and the size
341 /// of the map is unknown, resulting in inefficiencies due to repeated
342 /// insertions and resizing.
343 typedef std::map<GlobalValue::GUID, GlobalValueSummaryList>
345 
346 /// Type used for iterating through the global value summary map.
347 typedef GlobalValueSummaryMapTy::const_iterator const_gvsummary_iterator;
348 typedef GlobalValueSummaryMapTy::iterator gvsummary_iterator;
349 
350 /// String table to hold/own module path strings, which additionally holds the
351 /// module ID assigned to each module during the plugin step, as well as a hash
352 /// of the module. The StringMap makes a copy of and owns inserted strings.
354 
355 /// Map of global value GUID to its summary, used to identify values defined in
356 /// a particular module, and provide efficient access to their summary.
357 typedef std::map<GlobalValue::GUID, GlobalValueSummary *> GVSummaryMapTy;
358 
359 /// Class to hold module path string table and global value map,
360 /// and encapsulate methods for operating on them.
362 private:
363  /// Map from value name to list of summary instances for values of that
364  /// name (may be duplicates in the COMDAT case, e.g.).
365  GlobalValueSummaryMapTy GlobalValueMap;
366 
367  /// Holds strings for combined index, mapping to the corresponding module ID.
368  ModulePathStringTableTy ModulePathStringTable;
369 
370  /// Mapping from type identifiers to summary information for that type
371  /// identifier.
372  // FIXME: Add bitcode read/write support for this field.
373  std::map<std::string, TypeIdSummary> TypeIdMap;
374 
375  // YAML I/O support.
377 
378 public:
379  gvsummary_iterator begin() { return GlobalValueMap.begin(); }
380  const_gvsummary_iterator begin() const { return GlobalValueMap.begin(); }
381  gvsummary_iterator end() { return GlobalValueMap.end(); }
382  const_gvsummary_iterator end() const { return GlobalValueMap.end(); }
383  size_t size() const { return GlobalValueMap.size(); }
384 
385  /// Get the list of global value summary objects for a given value name.
387  return GlobalValueMap[GlobalValue::getGUID(ValueName)];
388  }
389 
390  /// Get the list of global value summary objects for a given value name.
393  return GlobalValueMap.find(GlobalValue::getGUID(ValueName));
394  }
395 
396  /// Get the list of global value summary objects for a given value GUID.
399  return GlobalValueMap.find(ValueGUID);
400  }
401 
402  /// Add a global value summary for a value of the given name.
404  std::unique_ptr<GlobalValueSummary> Summary) {
405  GlobalValueMap[GlobalValue::getGUID(ValueName)].push_back(
406  std::move(Summary));
407  }
408 
409  /// Add a global value summary for a value of the given GUID.
411  std::unique_ptr<GlobalValueSummary> Summary) {
412  GlobalValueMap[ValueGUID].push_back(std::move(Summary));
413  }
414 
415  /// Find the summary for global \p GUID in module \p ModuleId, or nullptr if
416  /// not found.
418  StringRef ModuleId) const {
419  auto CalleeInfoList = findGlobalValueSummaryList(ValueGUID);
420  if (CalleeInfoList == end()) {
421  return nullptr; // This function does not have a summary
422  }
423  auto Summary =
424  llvm::find_if(CalleeInfoList->second,
425  [&](const std::unique_ptr<GlobalValueSummary> &Summary) {
426  return Summary->modulePath() == ModuleId;
427  });
428  if (Summary == CalleeInfoList->second.end())
429  return nullptr;
430  return Summary->get();
431  }
432 
433  /// Returns the first GlobalValueSummary for \p GV, asserting that there
434  /// is only one if \p PerModuleIndex.
436  bool PerModuleIndex = true) const {
437  assert(GV.hasName() && "Can't get GlobalValueSummary for GV with no name");
438  return getGlobalValueSummary(GlobalValue::getGUID(GV.getName()),
439  PerModuleIndex);
440  }
441 
442  /// Returns the first GlobalValueSummary for \p ValueGUID, asserting that
443  /// there
444  /// is only one if \p PerModuleIndex.
445  GlobalValueSummary *getGlobalValueSummary(GlobalValue::GUID ValueGUID,
446  bool PerModuleIndex = true) const;
447 
448  /// Table of modules, containing module hash and id.
450  return ModulePathStringTable;
451  }
452 
453  /// Table of modules, containing hash and id.
455  return ModulePathStringTable;
456  }
457 
458  /// Get the module ID recorded for the given module path.
459  uint64_t getModuleId(const StringRef ModPath) const {
460  return ModulePathStringTable.lookup(ModPath).first;
461  }
462 
463  /// Get the module SHA1 hash recorded for the given module path.
464  const ModuleHash &getModuleHash(const StringRef ModPath) const {
465  auto It = ModulePathStringTable.find(ModPath);
466  assert(It != ModulePathStringTable.end() && "Module not registered");
467  return It->second.second;
468  }
469 
470  /// Add the given per-module index into this module index/summary,
471  /// assigning it the given module ID. Each module merged in should have
472  /// a unique ID, necessary for consistent renaming of promoted
473  /// static (local) variables.
474  void mergeFrom(std::unique_ptr<ModuleSummaryIndex> Other,
475  uint64_t NextModuleId);
476 
477  /// Convenience method for creating a promoted global name
478  /// for the given value name of a local, and its original module's ID.
479  static std::string getGlobalNameForLocal(StringRef Name, ModuleHash ModHash) {
480  SmallString<256> NewName(Name);
481  NewName += ".llvm.";
482  NewName += utohexstr(ModHash[0]); // Take the first 32 bits
483  return NewName.str();
484  }
485 
486  /// Helper to obtain the unpromoted name for a global value (or the original
487  /// name if not promoted).
489  std::pair<StringRef, StringRef> Pair = Name.split(".llvm.");
490  return Pair.first;
491  }
492 
493  /// Add a new module path with the given \p Hash, mapped to the given \p
494  /// ModID, and return an iterator to the entry in the index.
496  addModulePath(StringRef ModPath, uint64_t ModId,
497  ModuleHash Hash = ModuleHash{{0}}) {
498  return ModulePathStringTable.insert(std::make_pair(
499  ModPath,
500  std::make_pair(ModId, Hash))).first;
501  }
502 
503  /// Check if the given Module has any functions available for exporting
504  /// in the index. We consider any module present in the ModulePathStringTable
505  /// to have exported functions.
506  bool hasExportedFunctions(const Module &M) const {
507  return ModulePathStringTable.count(M.getModuleIdentifier());
508  }
509 
510  /// Remove entries in the GlobalValueMap that have empty summaries due to the
511  /// eager nature of map entry creation during VST parsing. These would
512  /// also be suppressed during combined index generation in mergeFrom(),
513  /// but if there was only one module or this was the first module we might
514  /// not invoke mergeFrom.
515  void removeEmptySummaryEntries();
516 
517  /// Collect for the given module the list of function it defines
518  /// (GUID -> Summary).
519  void collectDefinedFunctionsForModule(StringRef ModulePath,
520  GVSummaryMapTy &GVSummaryMap) const;
521 
522  /// Collect for each module the list of Summaries it defines (GUID ->
523  /// Summary).
524  void collectDefinedGVSummariesPerModule(
525  StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries) const;
526 };
527 
528 } // End llvm namespace
529 
530 #endif
MachineLoop * L
StringMap< std::pair< uint64_t, ModuleHash > > ModulePathStringTableTy
String table to hold/own module path strings, which additionally holds the module ID assigned to each...
void setLiveRoot()
Flag that this global value must be considered a root for live value analysis on the index...
void setNotEligibleToImport()
Flag that this global value cannot be imported.
std::vector< std::unique_ptr< GlobalValueSummary > > GlobalValueSummaryList
List of global value summary structures for a particular value held in the GlobalValueMap.
static bool classof(const GlobalValueSummary *GVS)
Check if this is an alias summary.
ValueUnion(GlobalValue::GUID Id)
const const_gvsummary_iterator findGlobalValueSummaryList(GlobalValue::GUID ValueGUID) const
Get the list of global value summary objects for a given value GUID.
bool hasName() const
Definition: Value.h:236
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Definition: GlobalValue.h:465
const ModuleHash & getModuleHash(const StringRef ModPath) const
Get the module SHA1 hash recorded for the given module path.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMap.h:36
unsigned Linkage
The linkage type of the associated global value.
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:473
FunctionSummary(GVFlags Flags, unsigned NumInsts, std::vector< ValueInfo > Refs, std::vector< EdgeTy > CGEdges, std::vector< GlobalValue::GUID > TypeIds)
Summary constructors.
Global variable summary information to aid decisions and implementation of importing.
Unsatisfiable type (i.e. no global has this type metadata)
ModulePathStringTableTy::iterator addModulePath(StringRef ModPath, uint64_t ModId, ModuleHash Hash=ModuleHash{{0}})
Add a new module path with the given Hash, mapped to the given ModID, and return an iterator to the e...
ValueUnion TheValue
The value being represented.
Union of the two possible value types.
static StringRef getOriginalNameBeforePromote(StringRef Name)
Helper to obtain the unpromoted name for a global value (or the original name if not promoted)...
std::map< GlobalValue::GUID, GlobalValueSummaryList > GlobalValueSummaryMapTy
Map from global value GUID to corresponding summary structures.
const GlobalValue * getValue() const
Accessor for GlobalValue* value.
Kind
Specifies which kind of type check we should emit for this byte array.
static unsigned getHashValue(ValueInfo I)
GlobalValueSummaryMapTy::const_iterator const_gvsummary_iterator
Type used for iterating through the global value summary map.
StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths()
Table of modules, containing hash and id.
TypeTestResolution TTRes
GlobalValue::GUID getOriginalName()
Returns the hash of the original name, it is identical to the GUID for externally visible symbols...
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:191
ValueInfoKind
The value representation used in this instance.
static bool isEqual(ValueInfo L, ValueInfo R)
unsigned NotEligibleToImport
Indicate if the global value cannot be imported (e.g.
GVFlags flags()
Get the flags for this GlobalValue (see struct GVFlags).
static std::string getGlobalNameForLocal(StringRef Name, ModuleHash ModHash)
Convenience method for creating a promoted global name for the given value name of a local...
GlobalValueSummaryMapTy::iterator gvsummary_iterator
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
Definition: Module.h:193
const GlobalValueSummary & getAliasee() const
uint64_t getModuleId(const StringRef ModPath) const
Get the module ID recorded for the given module path.
unsigned instCount() const
Get the instruction count recorded for this function.
This class should be specialized by any type that needs to be converted to/from a YAML mapping...
bool liveRoot() const
Return true if this global value must be considered a root for live value analysis on the index...
std::pair< ValueInfo, CalleeInfo > EdgeTy
<CalleeValueInfo, CalleeInfo> call edge pair.
unsigned LiveRoot
Indicate that the global value must be considered a live root for index-based liveness analysis...
const StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths() const
Table of modules, containing module hash and id.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
Class to hold module path string table and global value map, and encapsulate methods for operating on...
StringRef modulePath() const
Get the path to the module containing this function.
bool notEligibleToImport() const
Return true if this global value can't be imported.
CalleeInfo(HotnessType Hotness)
ArrayRef< EdgeTy > calls() const
Return the list of <CalleeValueInfo, CalleeInfo> pairs.
ValueInfo(const GlobalValue *V)
Constructor for a GlobalValue* value.
AliasSummary(GVFlags Flags, std::vector< ValueInfo > Refs)
Summary constructors.
static bool classof(const GlobalValueSummary *GVS)
Check if this is a global variable summary.
const const_gvsummary_iterator findGlobalValueSummaryList(StringRef ValueName) const
Get the list of global value summary objects for a given value name.
void addGlobalValueSummary(GlobalValue::GUID ValueGUID, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for a value of the given GUID.
SummaryKind getSummaryKind() const
Which kind of summary subclass this is.
Class to accumulate and hold information about a callee.
Single element (last example in "Short Inline Bit Vectors")
bool hasExportedFunctions(const Module &M) const
Check if the given Module has any functions available for exporting in the index. ...
Function and variable summary information to aid decisions and implementation of importing.
void addGlobalValueSummary(StringRef ValueName, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for a value of the given name.
ValueUnion(const GlobalValue *GV)
Struct to hold value either by GUID or GlobalValue*.
void updateHotness(const HotnessType OtherHotness)
static bool classof(const GlobalValueSummary *GVS)
Check if this is a function summary.
Module.h This file contains the declarations for the Module class.
ArrayRef< GlobalValue::GUID > type_tests() const
Returns the list of type identifiers used by this function.
Alias summary information.
virtual ~GlobalValueSummary()=default
GlobalValueSummary * findSummaryInModule(GlobalValue::GUID ValueGUID, StringRef ModuleId) const
Find the summary for global GUID in module ModuleId, or nullptr if not found.
enum llvm::TypeTestResolution::Kind TheKind
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:223
GlobalValue::LinkageTypes linkage() const
Return linkage type recorded for this global value.
StringRef str() const
Explicit conversion to StringRef.
Definition: SmallString.h:267
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:48
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
Definition: StringRef.h:716
SummaryKind
Sububclass discriminator (for dyn_cast<> et al.)
GlobalValueSummary(SummaryKind K, GVFlags Flags, std::vector< ValueInfo > Refs)
GlobalValueSummary constructor.
Test a byte array (first example)
const_gvsummary_iterator end() const
GlobalVarSummary(GVFlags Flags, std::vector< ValueInfo > Refs)
Summary constructors.
std::map< GlobalValue::GUID, GlobalValueSummary * > GVSummaryMapTy
Map of global value GUID to its summary, used to identify values defined in a particular module...
CalleeInfo()=default
void setLinkage(GlobalValue::LinkageTypes Linkage)
Sets the linkage to the value determined by global summary-based optimization.
GVFlags(GlobalValue::LinkageTypes Linkage, bool NotEligibleToImport, bool LiveRoot)
Convenience Constructors.
All-ones bit vector ("Eliminating Bit Vector Checks for All-Ones Bit Vectors") ...
#define I(x, y, z)
Definition: MD5.cpp:54
const_gvsummary_iterator begin() const
void setOriginalName(GlobalValue::GUID Name)
Initialize the original name hash in this summary.
Inlined bit vector ("Short Inline Bit Vectors")
unsigned SizeM1BitWidth
Range of size-1 expressed as a bit width.
Function summary information to aid decisions and implementation of importing.
GlobalValueSummary & getAliasee()
void setModulePath(StringRef ModPath)
Set the path to the module containing this function, for use in the combined index.
GlobalValue::GUID getGUID() const
Accessor for GUID value.
static std::string utohexstr(uint64_t X, bool LowerCase=false)
Definition: StringExtras.h:48
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
const GlobalValueSummaryList & getGlobalValueSummaryList(StringRef ValueName)
Get the list of global value summary objects for a given value name.
gvsummary_iterator end()
void setAliasee(GlobalValueSummary *Aliasee)
GlobalValueSummary * getGlobalValueSummary(const GlobalValue &GV, bool PerModuleIndex=true) const
Returns the first GlobalValueSummary for GV, asserting that there is only one if PerModuleIndex.
ValueInfoKind Kind
The value representation.
Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
ArrayRef< ValueInfo > refs() const
Return the list of values referenced by this global value definition.
std::string Hash(const Unit &U)
Definition: FuzzerSHA1.cpp:216
gvsummary_iterator begin()
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
bool isGUID() const
auto find_if(R &&Range, UnaryPredicate P) -> decltype(std::begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:764
std::array< uint32_t, 5 > ModuleHash
160 bits SHA1
ValueInfo(GlobalValue::GUID Id=0)
Constructor for a GUID value.