16 #ifndef LLVM_IR_MODULESUMMARYINDEX_H
17 #define LLVM_IR_MODULESUMMARYINDEX_H
132 : Linkage(Linkage), NotEligibleToImport(NotEligibleToImport),
133 LiveRoot(LiveRoot) {}
160 std::vector<ValueInfo> RefEdgeList;
165 : Kind(K), Flags(Flags), RefEdgeList(std::move(Refs)) {}
240 assert(AliaseeSummary &&
"Unexpected missing aliasee summary");
241 return *AliaseeSummary;
250 typedef std::pair<ValueInfo, CalleeInfo>
EdgeTy;
258 std::vector<EdgeTy> CallGraphEdgeList;
261 std::vector<GlobalValue::GUID> TypeIdList;
266 std::vector<EdgeTy> CGEdges,
267 std::vector<GlobalValue::GUID> TypeIds)
269 InstCount(NumInsts), CallGraphEdgeList(std::move(CGEdges)),
270 TypeIdList(std::move(TypeIds)) {}
343 typedef std::map<GlobalValue::GUID, GlobalValueSummaryList>
373 std::map<std::string, TypeIdSummary> TypeIdMap;
383 size_t size()
const {
return GlobalValueMap.size(); }
399 return GlobalValueMap.find(ValueGUID);
404 std::unique_ptr<GlobalValueSummary> Summary) {
411 std::unique_ptr<GlobalValueSummary> Summary) {
412 GlobalValueMap[ValueGUID].push_back(std::move(Summary));
420 if (CalleeInfoList ==
end()) {
425 [&](
const std::unique_ptr<GlobalValueSummary> &Summary) {
426 return Summary->modulePath() == ModuleId;
428 if (Summary == CalleeInfoList->second.end())
430 return Summary->get();
436 bool PerModuleIndex =
true)
const {
437 assert(GV.
hasName() &&
"Can't get GlobalValueSummary for GV with no name");
446 bool PerModuleIndex =
true)
const;
450 return ModulePathStringTable;
455 return ModulePathStringTable;
460 return ModulePathStringTable.lookup(ModPath).first;
465 auto It = ModulePathStringTable.find(ModPath);
466 assert(It != ModulePathStringTable.end() &&
"Module not registered");
467 return It->second.second;
474 void mergeFrom(std::unique_ptr<ModuleSummaryIndex> Other,
475 uint64_t NextModuleId);
483 return NewName.
str();
489 std::pair<StringRef, StringRef> Pair = Name.
split(
".llvm.");
498 return ModulePathStringTable.insert(std::make_pair(
500 std::make_pair(ModId,
Hash))).first;
515 void removeEmptySummaryEntries();
519 void collectDefinedFunctionsForModule(
StringRef ModulePath,
524 void collectDefinedGVSummariesPerModule(
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.
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
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.
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. ...
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
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.
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.
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.
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)...
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.
static ValueInfo getEmptyKey()
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.
static ValueInfo getTombstoneKey()
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"...
GlobalValue::LinkageTypes linkage() const
Return linkage type recorded for this global value.
StringRef str() const
Explicit conversion to StringRef.
LinkageTypes
An enumeration for the kinds of linkage for global values.
LLVM_NODISCARD std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
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...
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") ...
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)
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.
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)
gvsummary_iterator begin()
StringRef - Represent a constant reference to a string, i.e.
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...
std::array< uint32_t, 5 > ModuleHash
160 bits SHA1
ValueInfo(GlobalValue::GUID Id=0)
Constructor for a GUID value.