15 #ifndef LLVM_IR_MODULESUMMARYINDEX_H 16 #define LLVM_IR_MODULESUMMARYINDEX_H 70 static constexpr int32_t ScaleShift = 8;
71 static constexpr uint64_t MaxRelBlockFreq = (1 << 29) - 1;
76 : Hotness(static_cast<
uint32_t>(Hotness)), RelBlockFreq(RelBF) {}
79 Hotness =
std::max(Hotness, static_cast<uint32_t>(OtherHotness));
93 Scaled64 Temp(BlockFreq, ScaleShift);
94 Temp /= Scaled64::get(EntryFreq);
97 SaturatingAdd<uint64_t>(Temp.toInt<uint64_t>(), RelBlockFreq);
98 Sum = std::min(Sum, uint64_t(MaxRelBlockFreq));
99 RelBlockFreq =
static_cast<uint32_t>(Sum);
161 std::map<GlobalValue::GUID, GlobalValueSummaryInfo>;
166 enum Flags { HaveGV = 1, ReadOnly = 2, WriteOnly = 4 };
171 ValueInfo(
bool HaveGVs,
const GlobalValueSummaryMapTy::value_type *R) {
172 RefAndFlags.setPointer(R);
173 RefAndFlags.setInt(HaveGVs);
176 explicit operator bool()
const {
return getRef(); }
181 return getRef()->second.U.GV;
185 return getRef()->second.SummaryList;
189 return haveGVs() ? getRef()->second.U.GV->getName()
190 : getRef()->second.U.Name;
193 bool haveGVs()
const {
return RefAndFlags.getInt() & HaveGV; }
195 assert(isValidAccessSpecifier());
196 return RefAndFlags.getInt() & ReadOnly;
199 assert(isValidAccessSpecifier());
200 return RefAndFlags.getInt() & WriteOnly;
203 assert(isValidAccessSpecifier());
204 return RefAndFlags.getInt() & (ReadOnly | WriteOnly);
207 unsigned BadAccessMask = ReadOnly | WriteOnly;
208 return (RefAndFlags.getInt() & BadAccessMask) != BadAccessMask;
213 assert(getAccessSpecifier() == 0);
214 RefAndFlags.setInt(RefAndFlags.getInt() | ReadOnly);
217 assert(getAccessSpecifier() == 0);
218 RefAndFlags.setInt(RefAndFlags.getInt() | WriteOnly);
221 const GlobalValueSummaryMapTy::value_type *
getRef()
const {
222 return RefAndFlags.getPointer();
225 bool isDSOLocal()
const;
228 bool canAutoHide()
const;
234 OS <<
" (" << VI.
name() <<
")";
240 "Need ValueInfo with non-null Ref for comparison");
246 "Need ValueInfo with non-null Ref for comparison");
252 "Need ValueInfo with non-null Ref to compare GUIDs");
258 return ValueInfo(
false, (GlobalValueSummaryMapTy::value_type *)-8);
262 return ValueInfo(
false, (GlobalValueSummaryMapTy::value_type *)-16);
266 return V == getTombstoneKey() || V == getEmptyKey();
283 enum SummaryKind :
unsigned { AliasKind, FunctionKind, GlobalVarKind };
324 bool NotEligibleToImport,
bool Live,
bool IsLocal,
326 : Linkage(Linkage), NotEligibleToImport(NotEligibleToImport),
327 Live(Live), DSOLocal(IsLocal), CanAutoHide(CanAutoHide) {}
354 std::vector<ValueInfo> RefEdgeList;
358 : Kind(K), Flags(Flags), RefEdgeList(
std::move(Refs)) {
359 assert((K != AliasKind || Refs.empty()) &&
360 "Expect no references for AliasSummary");
439 AliaseeSummary(
nullptr) {}
447 AliaseeValueInfo = AliaseeVI;
448 AliaseeSummary = Aliasee;
452 assert(!!AliaseeSummary == (AliaseeValueInfo &&
454 "Expect to have both aliasee summary and summary list or neither");
455 return !!AliaseeSummary;
459 assert(AliaseeSummary &&
"Unexpected missing aliasee summary");
460 return *AliaseeSummary;
468 assert(AliaseeValueInfo &&
"Unexpected missing aliasee");
469 return AliaseeValueInfo;
472 assert(AliaseeValueInfo &&
"Unexpected missing aliasee");
473 return AliaseeValueInfo.
getGUID();
478 if (
auto *AS = dyn_cast<AliasSummary>(
this))
479 return &AS->getAliasee();
484 if (
auto *AS = dyn_cast<AliasSummary>(
this))
485 return &AS->getAliasee();
494 using EdgeTy = std::pair<ValueInfo, CalleeInfo>;
537 TypeCheckedLoadConstVCalls;
561 GlobalValue::LinkageTypes::AvailableExternallyLinkage,
565 std::vector<ValueInfo>(), std::move(Edges),
566 std::vector<GlobalValue::GUID>(),
567 std::vector<FunctionSummary::VFuncId>(),
568 std::vector<FunctionSummary::VFuncId>(),
569 std::vector<FunctionSummary::ConstVCall>(),
570 std::vector<FunctionSummary::ConstVCall>());
587 uint64_t EntryCount = 0;
590 std::vector<EdgeTy> CallGraphEdgeList;
592 std::unique_ptr<TypeIdInfo> TIdInfo;
596 uint64_t EntryCount, std::vector<ValueInfo> Refs,
597 std::vector<EdgeTy> CGEdges,
598 std::vector<GlobalValue::GUID> TypeTests,
599 std::vector<VFuncId> TypeTestAssumeVCalls,
600 std::vector<VFuncId> TypeCheckedLoadVCalls,
601 std::vector<ConstVCall> TypeTestAssumeConstVCalls,
602 std::vector<ConstVCall> TypeCheckedLoadConstVCalls)
604 InstCount(NumInsts), FunFlags(FunFlags), EntryCount(EntryCount),
605 CallGraphEdgeList(
std::move(CGEdges)) {
606 if (!TypeTests.empty() || !TypeTestAssumeVCalls.empty() ||
607 !TypeCheckedLoadVCalls.empty() || !TypeTestAssumeConstVCalls.empty() ||
608 !TypeCheckedLoadConstVCalls.empty())
609 TIdInfo = std::make_unique<TypeIdInfo>(
TypeIdInfo{
610 std::move(TypeTests), std::move(TypeTestAssumeVCalls),
611 std::move(TypeCheckedLoadVCalls),
612 std::move(TypeTestAssumeConstVCalls),
613 std::move(TypeCheckedLoadConstVCalls)});
616 std::pair<unsigned, unsigned> specialRefCounts()
const;
645 return TIdInfo->TypeTests;
654 return TIdInfo->TypeTestAssumeVCalls;
663 return TIdInfo->TypeCheckedLoadVCalls;
672 return TIdInfo->TypeTestAssumeConstVCalls;
680 return TIdInfo->TypeCheckedLoadConstVCalls;
688 TIdInfo = std::make_unique<TypeIdInfo>();
689 TIdInfo->TypeTests.push_back(Guid);
692 const TypeIdInfo *getTypeIdInfo()
const {
return TIdInfo.get(); };
701 return {0, uint64_t(-2)};
713 return {{0, uint64_t(-1)}, {}};
717 return {{0, uint64_t(-2)}, {}};
735 : FuncVI(VI), VTableOffset(Offset) {}
756 std::unique_ptr<VTableFuncList> VTableFuncs;
761 : MaybeReadOnly(ReadOnly), MaybeWriteOnly(WriteOnly) {}
771 std::vector<ValueInfo> Refs)
773 VarFlags(VarFlags) {}
788 VTableFuncs = std::make_unique<VTableFuncList>(std::move(Funcs));
815 unsigned SizeM1BitWidth = 0;
822 uint64_t AlignLog2 = 0;
825 uint64_t InlineBits = 0;
870 std::map<uint64_t, WholeProgramDevirtResolution>
WPDRes;
892 std::multimap<GlobalValue::GUID, std::pair<std::string, TypeIdSummary>>;
906 : AddressPointOffset(Offset), VTableVI(VI) {}
936 std::map<std::string, TypeIdCompatibleVtableInfo> TypeIdCompatibleVtableMap;
940 std::map<GlobalValue::GUID, GlobalValue::GUID> OidGuidMap;
945 bool WithGlobalValueDeadStripping =
false;
950 bool WithAttributePropagation =
false;
953 bool HasSyntheticEntryCounts =
false;
960 bool SkipModuleByDistributedBackend =
false;
969 bool EnableSplitLTOUnit;
973 bool PartiallySplitLTOUnits =
false;
975 std::set<std::string> CfiFunctionDefs;
976 std::set<std::string> CfiFunctionDecls;
986 GlobalValueSummaryMapTy::value_type *
995 : HaveGVs(HaveGVs), EnableSplitLTOUnit(EnableSplitLTOUnit), Saver(Alloc) {
1003 static constexpr uint64_t BitcodeSummaryVersion = 8;
1011 size_t size()
const {
return GlobalValueMap.size(); }
1016 std::map<ValueInfo, bool> &FunctionHasParent) {
1021 auto S = FunctionHasParent.emplace(V,
false);
1029 assert(F !=
nullptr &&
"Expected FunctionSummary node");
1031 for (
auto &
C : F->
calls()) {
1033 auto S = FunctionHasParent.emplace(
C.first,
true);
1036 if (!S.second && S.first->second)
1040 discoverNodes(
C.first, FunctionHasParent);
1042 S.first->second =
true;
1051 std::map<ValueInfo, bool> FunctionHasParent;
1053 for (
auto &S : *
this) {
1055 if (!S.second.SummaryList.size() ||
1056 !isa<FunctionSummary>(S.second.SummaryList.front().get()))
1058 discoverNodes(ValueInfo(HaveGVs, &S), FunctionHasParent);
1061 std::vector<FunctionSummary::EdgeTy> Edges;
1063 for (
auto &
P : FunctionHasParent) {
1066 Edges.push_back(std::make_pair(
P.first,
CalleeInfo{}));
1068 if (Edges.empty()) {
1073 return CallGraphRoot;
1077 return WithGlobalValueDeadStripping;
1080 WithGlobalValueDeadStripping =
true;
1085 WithAttributePropagation =
true;
1099 return SkipModuleByDistributedBackend;
1102 SkipModuleByDistributedBackend =
true;
1112 return !WithGlobalValueDeadStripping || GVS->
isLive();
1118 ValueInfo
getValueInfo(
const GlobalValueSummaryMapTy::value_type &R)
const {
1119 return ValueInfo(HaveGVs, &R);
1124 auto I = GlobalValueMap.find(GUID);
1125 return ValueInfo(HaveGVs,
I == GlobalValueMap.end() ? nullptr : &*
I);
1130 return ValueInfo(HaveGVs, getOrInsertValuePtr(GUID));
1141 auto VP = getOrInsertValuePtr(GUID);
1142 VP->second.U.Name =
Name;
1143 return ValueInfo(HaveGVs, VP);
1149 auto VP = getOrInsertValuePtr(GV->
getGUID());
1150 VP->second.U.GV = GV;
1151 return ValueInfo(HaveGVs, VP);
1156 const auto I = OidGuidMap.find(OriginalID);
1157 return I == OidGuidMap.end() ? 0 :
I->second;
1168 std::unique_ptr<GlobalValueSummary> Summary) {
1169 addGlobalValueSummary(getOrInsertValueInfo(&GV), std::move(Summary));
1174 std::unique_ptr<GlobalValueSummary> Summary) {
1176 std::move(Summary));
1181 std::unique_ptr<GlobalValueSummary> Summary) {
1182 addOriginalName(VI.
getGUID(), Summary->getOriginalName());
1185 const_cast<GlobalValueSummaryMapTy::value_type *
>(VI.
getRef())
1186 ->
second.SummaryList.push_back(std::move(Summary));
1192 if (OrigGUID == 0 || ValueGUID == OrigGUID)
1194 if (OidGuidMap.count(OrigGUID) && OidGuidMap[OrigGUID] != ValueGUID)
1195 OidGuidMap[OrigGUID] = 0;
1197 OidGuidMap[OrigGUID] = ValueGUID;
1206 [&](
const std::unique_ptr<GlobalValueSummary> &Summary) {
1207 return Summary->modulePath() == ModuleId;
1209 if (Summary == SummaryList.end())
1211 return Summary->get();
1221 return findSummaryInModule(
CalleeInfo, ModuleId);
1227 bool PerModuleIndex =
true)
const {
1228 assert(GV.
hasName() &&
"Can't get GlobalValueSummary for GV with no name");
1229 return getGlobalValueSummary(GV.
getGUID(), PerModuleIndex);
1236 bool PerModuleIndex =
true)
const;
1240 return ModulePathStringTable;
1245 return ModulePathStringTable;
1250 return ModulePathStringTable.
lookup(ModPath).first;
1255 auto It = ModulePathStringTable.
find(ModPath);
1256 assert(It != ModulePathStringTable.
end() &&
"Module not registered");
1257 return It->second.second;
1264 NewName +=
".llvm.";
1265 NewName +=
utostr((uint64_t(ModHash[0]) << 32) |
1267 return NewName.
str();
1275 std::pair<StringRef, StringRef> Pair = Name.
rsplit(
".llvm.");
1285 return &*ModulePathStringTable.
insert({ModPath, {ModId, Hash}}).
first;
1290 auto It = ModulePathStringTable.
find(ModPath);
1291 assert(It != ModulePathStringTable.
end() &&
"Module not registered");
1309 for (
auto It = TidIter.first; It != TidIter.second; ++It)
1310 if (It->second.first == TypeId)
1311 return It->second.second;
1312 auto It = TypeIdMap.insert(
1314 return It->second.second;
1321 for (
auto It = TidIter.first; It != TidIter.second; ++It)
1322 if (It->second.first == TypeId)
1323 return &It->second.second;
1333 const std::map<std::string, TypeIdCompatibleVtableInfo> &
1335 return TypeIdCompatibleVtableMap;
1343 return TypeIdCompatibleVtableMap[TypeId];
1350 auto I = TypeIdCompatibleVtableMap.find(TypeId);
1351 if (
I == TypeIdCompatibleVtableMap.end())
1358 void collectDefinedFunctionsForModule(
StringRef ModulePath,
1363 template <
class Map>
1366 for (
auto &GlobalList : *
this) {
1367 auto GUID = GlobalList.first;
1368 for (
auto &Summary : GlobalList.second.SummaryList) {
1369 ModuleToDefinedGVSummaries[Summary->modulePath()][GUID] = Summary.get();
1405 decltype(&valueInfoFromEdge)>;
1415 &valueInfoFromEdge);
1417 cast<FunctionSummary>(N.
getSummaryList().front()->getBaseObject());
1425 &valueInfoFromEdge);
1427 cast<FunctionSummary>(N.
getSummaryList().front()->getBaseObject());
1436 cast<FunctionSummary>(N.
getSummaryList().front()->getBaseObject());
1437 return F->CallGraphEdgeList.begin();
1445 cast<FunctionSummary>(N.
getSummaryList().front()->getBaseObject());
1446 return F->CallGraphEdgeList.end();
1455 std::unique_ptr<GlobalValueSummary> Root =
1458 G.SummaryList.push_back(std::move(Root));
1461 return ValueInfo(I->
haveGVs(), &
P);
1466 #endif // LLVM_IR_MODULESUMMARYINDEX_H static FunctionSummary::ConstVCall getEmptyKey()
std::vector< TypeIdOffsetVtableInfo > TypeIdCompatibleVtableInfo
List of vtable definitions decorated by a particular type identifier, and their corresponding offsets...
unsigned Live
In per-module summary, indicate that the global value must be considered a live root for index-based ...
void setNotEligibleToImport()
Flag that this global value cannot be imported.
static bool classof(const GlobalValueSummary *GVS)
Check if this is an alias summary.
bool operator==(const BinaryRef &LHS, const BinaryRef &RHS)
static FunctionSummary::ConstVCall getTombstoneKey()
void setEnableSplitLTOUnit()
std::vector< std::unique_ptr< GlobalValueSummary > > GlobalValueSummaryList
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
This class represents lattice values for constants.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
ValueInfo getValueInfo(GlobalValue::GUID GUID) const
Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
unsigned Linkage
The linkage type of the associated global value.
const GlobalValueSummary & getAliasee() const
StringRef Name
Summary string representation.
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).
A Module instance is used to store all the information related to an LLVM module. ...
GlobalValueSummary * findSummaryInModule(GlobalValue::GUID ValueGUID, StringRef ModuleId) const
Find the summary for global GUID in module ModuleId, or nullptr if not found.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
GlobalValueSummary * getGlobalValueSummary(const GlobalValue &GV, bool PerModuleIndex=true) const
Returns the first GlobalValueSummary for GV, asserting that there is only one if PerModuleIndex.
const GlobalValue * getValue() const
ArrayRef< VFuncId > type_test_assume_vcalls() const
Returns the list of virtual calls made by this function using llvm.assume(llvm.type.test) intrinsics that do not have all constant integer arguments.
Global variable summary information to aid decisions and implementation of importing.
Unsatisfiable type (i.e. no global has this type metadata)
Implements a dense probed hash-table based set.
void addTypeTest(GlobalValue::GUID Guid)
Add a type test to the summary.
ArrayRef< ValueInfo > refs() const
Return the list of values referenced by this global value definition.
static void discoverNodes(ValueInfo V, std::map< ValueInfo, bool > &FunctionHasParent)
Convenience function for doing a DFS on a ValueInfo.
bool withAttributePropagation() const
GlobalValueSummaryMapTy::iterator gvsummary_iterator
iterator find(StringRef Key)
const StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths() const
Table of modules, containing module hash and id.
const std::map< std::string, TypeIdCompatibleVtableInfo > & typeIdCompatibleVtableMap() const
GlobalValue::LinkageTypes linkage() const
Return linkage type recorded for this global value.
std::vector< VFuncId > TypeTestAssumeVCalls
List of virtual calls made by this function using (respectively) llvm.assume(llvm.type.test) or llvm.type.checked.load intrinsics that do not have all constant integer arguments.
static StringRef getOriginalNameBeforePromote(StringRef Name)
Helper to obtain the unpromoted name for a global value (or the original name if not promoted)...
LLVM_NODISCARD std::pair< StringRef, StringRef > rsplit(StringRef Separator) const
Split into two substrings around the last occurrence of a separator string.
const std::set< std::string > & cfiFunctionDecls() const
VirtFuncOffset(ValueInfo VI, uint64_t Offset)
bool isGlobalValueLive(const GlobalValueSummary *GVS) const
Kind
Specifies which kind of type check we should emit for this byte array.
static unsigned getHashValue(ValueInfo I)
Virtual constant propagation.
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 ...
std::map< uint64_t, WholeProgramDevirtResolution > WPDRes
Mapping from byte offset to whole-program devirt resolution for that (typeid, byte offset) pair...
StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths()
Table of modules, containing hash and id.
bool isReadOnly(const GlobalVarSummary *GVS) const
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
bool partiallySplitLTOUnits() const
bool hasExportedFunctions(const Module &M) const
Check if the given Module has any functions available for exporting in the index. ...
static bool isSpecialKey(ValueInfo V)
void addOriginalName(GlobalValue::GUID ValueGUID, GlobalValue::GUID OrigGUID)
Add an original name for the value of the given GUID.
static bool isEqual(ValueInfo L, ValueInfo R)
const GlobalValue * GV
The GlobalValue corresponding to this summary.
GVarFlags(bool ReadOnly, bool WriteOnly)
uint32_t RelBlockFreq
The value stored in RelBlockFreq has to be interpreted as the digits of a scaled number with a scale ...
TypeIdOffsetVtableInfo(uint64_t Offset, ValueInfo VI)
unsigned NotEligibleToImport
Indicate if the global value cannot be imported (e.g.
GlobalValue::GUID getGUID() const
bool skipModuleByDistributedBackend() const
bool isValidAccessSpecifier() const
ModuleInfo * getModule(StringRef ModPath)
Return module entry for module with the given ModPath.
static unsigned getHashValue(FunctionSummary::VFuncId I)
StringRef saveString(StringRef String)
const_gvsummary_iterator begin() const
static std::string getGlobalNameForLocal(StringRef Name, ModuleHash ModHash)
Convenience method for creating a promoted global name for the given value name of a local...
const TypeIdSummaryMapTy & typeIds() const
std::array< uint32_t, 5 > ModuleHash
160 bits SHA1
bool enableSplitLTOUnit() const
void setSkipModuleByDistributedBackend()
Just do a regular virtual call.
std::map< GlobalValue::GUID, GlobalValueSummaryInfo > GlobalValueSummaryMapTy
Map from global value GUID to corresponding summary structures.
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
ArrayRef< GlobalValue::GUID > type_tests() const
Returns the list of type identifiers used by this function in llvm.type.test intrinsics other than by...
void setWithGlobalValueDeadStripping()
StringRef str() const
Explicit conversion to StringRef.
Uniform return value optimization.
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 ...
static NodeRef getEntryNode(ValueInfo V)
static bool isEqual(const Function &Caller, const Function &Callee)
ArrayRef< VFuncId > type_checked_load_vcalls() const
Returns the list of virtual calls made by this function using llvm.type.checked.load intrinsics that ...
std::pair< ValueInfo, CalleeInfo > EdgeTy
<CalleeValueInfo, CalleeInfo> call edge pair.
The ValueInfo and offset for a function within a vtable definition initializer array.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
TypeIdSummary & getOrInsertTypeIdSummary(StringRef TypeId)
Return an existing or new TypeIdSummary entry for TypeId.
ModuleSummaryIndex(bool HaveGVs, bool EnableSplitLTOUnit=false)
void setCanAutoHide(bool CanAutoHide)
ModulePathStringTableTy::value_type ModuleInfo
Class to hold module path string table and global value map, and encapsulate methods for operating on...
static ChildEdgeIteratorType child_edge_begin(NodeRef N)
ArrayRef< std::unique_ptr< GlobalValueSummary > > getSummaryList() const
static ChildEdgeIteratorType child_edge_end(NodeRef N)
Analysis containing CSE Info
static bool isEqual(FunctionSummary::VFuncId L, FunctionSummary::VFuncId R)
void setWriteOnly(bool WO)
void setVTableFuncs(VTableFuncList Funcs)
ForceSummaryHotnessType
Types for -force-summary-edges-cold debugging option.
static unsigned getHashValue(FunctionSummary::ConstVCall I)
GlobalValueSummaryMapTy::const_iterator const_gvsummary_iterator
Type used for iterating through the global value summary map.
static FunctionSummary::VFuncId getEmptyKey()
GlobalValue::GUID getGUIDFromOriginalID(GlobalValue::GUID OriginalID) const
Return the GUID for OriginalId in the OidGuidMap.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
GlobalValue::GUID getAliaseeGUID() const
PointerIntPair< const GlobalValueSummaryMapTy::value_type *, 3, int > RefAndFlags
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
Allocate memory in an ever growing pool, as if by bump-pointer.
static bool classof(const GlobalValueSummary *GVS)
Check if this is a global variable summary.
ValueInfo(bool HaveGVs, const GlobalValueSummaryMapTy::value_type *R)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
SummaryKind getSummaryKind() const
Which kind of summary subclass this is.
const std::set< std::string > & cfiFunctionDefs() const
unsigned instCount() const
Get the instruction count recorded for this function.
std::vector< uint64_t > Args
static ValueInfo getEmptyKey()
CalleeInfo(HotnessType Hotness, uint64_t RelBF)
Class to accumulate and hold information about a callee.
Single element (last example in "Short Inline Bit Vectors")
GlobalVarSummary(GVFlags Flags, GVarFlags VarFlags, std::vector< ValueInfo > Refs)
TypeIdCompatibleVtableInfo & getOrInsertTypeIdCompatibleVtableSummary(StringRef TypeId)
Return an existing or new TypeIdCompatibleVtableMap entry for TypeId.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
void setPartiallySplitLTOUnits()
uint64_t entryCount() const
Get the synthetic entry count for this function.
const ModuleHash & getModuleHash(const StringRef ModPath) const
Get the module SHA1 hash recorded for the given module path.
GlobalValue::GUID getOriginalName() const
Returns the hash of the original name, it is identical to the GUID for externally visible symbols...
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
ValueInfo getOrInsertValueInfo(const GlobalValue *GV)
Return a ValueInfo for GV and mark it as belonging to GV.
auto find_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly...
All type identifier related information.
Function and variable summary information to aid decisions and implementation of importing.
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
std::vector< FunctionSummary::EdgeTy >::iterator ChildEdgeIteratorType
Optional< TypeIdCompatibleVtableInfo > getTypeIdCompatibleVtableSummary(StringRef TypeId) const
For the given TypeId, this returns the TypeIdCompatibleVtableMap entry if present in the summary map...
const_gvsummary_iterator end() const
static ValueInfo getTombstoneKey()
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
GVFlags flags() const
Get the flags for this GlobalValue (see struct GVFlags).
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
void addGlobalValueSummary(StringRef ValueName, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for a value of the given name.
void setWithAttributePropagation()
An "identifier" for a virtual function.
ArrayRef< ConstVCall > type_test_assume_const_vcalls() const
Returns the list of virtual calls made by this function using llvm.assume(llvm.type.test) intrinsics with all constant integer arguments.
void addGlobalValueSummary(ValueInfo VI, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for the given ValueInfo.
Struct that holds a reference to a particular GUID in a global value summary.
void setReadOnly(bool RO)
HotnessType getHotness() const
void updateHotness(const HotnessType OtherHotness)
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...
void setHasSyntheticEntryCounts()
static bool classof(const GlobalValueSummary *GVS)
Check if this is a function summary.
const char * getHotnessName(CalleeInfo::HotnessType HT)
GlobalValueSummary * getBaseObject()
If this is an alias summary, returns the summary of the aliased object (a global variable or function...
Align max(MaybeAlign Lhs, Align Rhs)
void setDSOLocal(bool Local)
bool isWriteOnly(const GlobalVarSummary *GVS) const
static ChildIteratorType child_end(NodeRef N)
Module.h This file contains the declarations for the Module class.
Single implementation devirtualization.
ValueInfo getAliaseeVI() const
ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID, StringRef Name)
Return a ValueInfo for GUID setting value Name.
uint64_t getModuleId(const StringRef ModPath) const
Get the module ID recorded for the given module path.
Alias summary information.
static NodeRef getEntryNode(ModuleSummaryIndex *I)
std::string utostr(uint64_t X, bool isNeg=false)
ArrayRef< VirtFuncOffset > vTableFuncs() const
FunctionSummary::EdgeTy & EdgeRef
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
std::string SingleImplName
static FunctionSummary makeDummyFunctionSummary(std::vector< FunctionSummary::EdgeTy > Edges)
Create an empty FunctionSummary (with specified call edges).
StringRef save(const char *S)
A specification for a virtual function call with all constant integer arguments.
LinkageTypes
An enumeration for the kinds of linkage for global values.
bool hasSyntheticEntryCounts() const
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
SummaryKind
Sububclass discriminator (for dyn_cast<> et al.)
ValueInfo getValueInfo(const GlobalValueSummaryMapTy::value_type &R) const
Return a ValueInfo for the index value_type (convenient when iterating index).
ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID)
Return a ValueInfo for GUID.
bool withGlobalValueDeadStripping() const
FFlags fflags() const
Get function summary flags.
GlobalValueSummary(SummaryKind K, GVFlags Flags, std::vector< ValueInfo > Refs)
std::set< std::string > & cfiFunctionDefs()
bool operator!=(uint64_t V1, const APInt &V2)
Test a byte array (first example)
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer...
FunctionSummary calculateCallGraphRoot()
std::map< std::vector< uint64_t >, ByArg > ResByArg
Resolutions for calls with all constant integer arguments (excluding the first argument, "this"), where the key is the argument vector.
unsigned getAccessSpecifier() const
void setAliasee(ValueInfo &AliaseeVI, GlobalValueSummary *Aliasee)
StringRef modulePath() const
Get the path to the module containing this function.
void setLinkage(GlobalValue::LinkageTypes Linkage)
Sets the linkage to the value determined by global summary-based optimization.
Linkage
Describes symbol linkage.
unsigned DSOLocal
Indicates that the linker resolved the symbol to a definition from within the same linkage unit...
void addGlobalValueSummary(const GlobalValue &GV, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for a value.
unsigned CanAutoHide
In the per-module summary, indicates that the global value is linkonce_odr and global unnamed addr (s...
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
ArrayRef< EdgeTy > calls() const
Return the list of <CalleeValueInfo, CalleeInfo> pairs.
void setOriginalName(GlobalValue::GUID Name)
Initialize the original name hash in this summary.
static NodeRef valueInfoFromEdge(FunctionSummary::EdgeTy &P)
Flags specific to function summaries.
GlobalValueSummary * findSummaryInModule(ValueInfo VI, StringRef ModuleId) const
Find the summary for ValueInfo VI in module ModuleId, or nullptr if not found.
Inlined bit vector ("Short Inline Bit Vectors")
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.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
bool notEligibleToImport() const
Return true if this global value can't be imported.
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)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
std::set< std::string > & cfiFunctionDecls()
GVFlags(GlobalValue::LinkageTypes Linkage, bool NotEligibleToImport, bool Live, bool IsLocal, bool CanAutoHide)
Convenience Constructors.
uint64_t AddressPointOffset
bool maybeReadOnly() const
void collectDefinedGVSummariesPerModule(Map &ModuleToDefinedGVSummaries) const
Collect for each module the list of Summaries it defines (GUID -> Summary).
TypeIdSummary * getTypeIdSummary(StringRef TypeId)
bool operator<(int64_t V1, const APSInt &V2)
std::vector< VirtFuncOffset > VTableFuncList
List of functions referenced by a particular vtable definition.
void setEntryCount(uint64_t EC)
Set the synthetic entry count for this function.
ScaledNumber< uint64_t > Scaled64
static FunctionSummary::VFuncId getTombstoneKey()
static ChildIteratorType child_begin(NodeRef N)
Just do a regular virtual call.
GVarFlags varflags() const
Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
This class implements an extremely fast bulk output stream that can only output to a stream...
gvsummary_iterator begin()
StringRef - Represent a constant reference to a string, i.e.
const GlobalValueSummaryMapTy::value_type * getRef() const
AliasSummary(GVFlags Flags)
static bool isEqual(FunctionSummary::ConstVCall L, FunctionSummary::ConstVCall R)
GlobalValueSummaryInfo(bool HaveGVs)
GraphTraits definition to build SCC for the index.
static NodeRef edge_dest(EdgeRef E)
unsigned ReturnDoesNotAlias
void updateRelBlockFreq(uint64_t BlockFreq, uint64_t EntryFreq)
Update RelBlockFreq from BlockFreq and EntryFreq.
The following data structures summarize type metadata information.
GlobalValueSummaryList SummaryList
List of global value summary structures for a particular value held in the GlobalValueMap.
Unique return value optimization.
bool maybeWriteOnly() const
std::vector< GlobalValue::GUID > TypeTests
List of type identifiers used by this function in llvm.type.test intrinsics referenced by something o...
static FunctionSummary ExternalNode
A dummy node to reference external functions that aren't in the index.
std::vector< ConstVCall > TypeTestAssumeConstVCalls
List of virtual calls made by this function using (respectively) llvm.assume(llvm.type.test) or llvm.type.checked.load intrinsics with all constant integer arguments.