15#ifndef LLVM_IR_MODULESUMMARYINDEX_H
16#define LLVM_IR_MODULESUMMARYINDEX_H
49template <
class GraphType>
struct GraphTraits;
98 Temp /= Scaled64::get(EntryFreq);
123class GlobalValueSummary;
165 std::map<GlobalValue::GUID, GlobalValueSummaryInfo>;
175 ValueInfo(
bool HaveGVs,
const GlobalValueSummaryMapTy::value_type *R) {
185 return getRef()->second.U.GV;
189 return getRef()->second.SummaryList;
194 :
getRef()->second.U.Name;
225 const GlobalValueSummaryMapTy::value_type *
getRef()
const {
236 bool isDSOLocal(
bool WithDSOLocalPropagation =
false)
const;
244 if (!
VI.name().empty())
245 OS <<
" (" <<
VI.name() <<
")";
251 "Need ValueInfo with non-null Ref for comparison");
252 return A.getRef() ==
B.getRef();
257 "Need ValueInfo with non-null Ref for comparison");
258 return A.getRef() !=
B.getRef();
263 "Need ValueInfo with non-null Ref to compare GUIDs");
264 return A.getGUID() <
B.getGUID();
269 return ValueInfo(
false, (GlobalValueSummaryMapTy::value_type *)-8);
273 return ValueInfo(
false, (GlobalValueSummaryMapTy::value_type *)-16);
277 return V == getTombstoneKey() || V == getEmptyKey();
283 assert(isSpecialKey(L) || isSpecialKey(R) || (L.haveGVs() == R.haveGVs()));
284 return L.getRef() == R.getRef();
322 for (
auto V : SNI.
Clones) {
412 for (
auto &M : AE.
MIBs) {
413 OS <<
"\t\t" << M <<
"\n";
499 std::vector<ValueInfo> RefEdgeList;
505 "Expect no references for AliasSummary");
539 Flags.Linkage = Linkage;
593 AliaseeSummary(
nullptr) {}
601 AliaseeValueInfo = AliaseeVI;
602 AliaseeSummary = Aliasee;
606 assert(!!AliaseeSummary == (AliaseeValueInfo &&
608 "Expect to have both aliasee summary and summary list or neither");
609 return !!AliaseeSummary;
613 assert(AliaseeSummary &&
"Unexpected missing aliasee summary");
614 return *AliaseeSummary;
622 assert(AliaseeValueInfo &&
"Unexpected missing aliasee");
623 return AliaseeValueInfo;
626 assert(AliaseeValueInfo &&
"Unexpected missing aliasee");
627 return AliaseeValueInfo.
getGUID();
632 if (
auto *AS = dyn_cast<AliasSummary>(
this))
633 return &AS->getAliasee();
638 if (
auto *AS = dyn_cast<AliasSummary>(
this))
639 return &AS->getAliasee();
648 using EdgeTy = std::pair<ValueInfo, CalleeInfo>;
744 operator std::string() {
747 OS <<
"funcFlags: (";
749 OS <<
", readOnly: " << this->
ReadOnly;
750 OS <<
", noRecurse: " << this->
NoRecurse;
752 OS <<
", noInline: " << this->
NoInline;
754 OS <<
", noUnwind: " << this->
NoUnwind;
755 OS <<
", mayThrow: " << this->
MayThrow;
808 std::vector<ValueInfo>(), std::move(Edges),
809 std::vector<GlobalValue::GUID>(),
810 std::vector<FunctionSummary::VFuncId>(),
811 std::vector<FunctionSummary::VFuncId>(),
812 std::vector<FunctionSummary::ConstVCall>(),
813 std::vector<FunctionSummary::ConstVCall>(),
814 std::vector<FunctionSummary::ParamAccess>(),
815 std::vector<CallsiteInfo>(), std::vector<AllocInfo>());
835 std::vector<EdgeTy> CallGraphEdgeList;
837 std::unique_ptr<TypeIdInfo> TIdInfo;
840 using ParamAccessesTy = std::vector<ParamAccess>;
841 std::unique_ptr<ParamAccessesTy> ParamAccesses;
849 using CallsitesTy = std::vector<CallsiteInfo>;
850 std::unique_ptr<CallsitesTy> Callsites;
859 using AllocsTy = std::vector<AllocInfo>;
860 std::unique_ptr<AllocsTy> Allocs;
864 uint64_t EntryCount, std::vector<ValueInfo> Refs,
865 std::vector<EdgeTy> CGEdges,
866 std::vector<GlobalValue::GUID> TypeTests,
867 std::vector<VFuncId> TypeTestAssumeVCalls,
868 std::vector<VFuncId> TypeCheckedLoadVCalls,
869 std::vector<ConstVCall> TypeTestAssumeConstVCalls,
870 std::vector<ConstVCall> TypeCheckedLoadConstVCalls,
871 std::vector<ParamAccess> Params, CallsitesTy CallsiteList,
874 InstCount(NumInsts), FunFlags(FunFlags), EntryCount(EntryCount),
875 CallGraphEdgeList(
std::
move(CGEdges)) {
876 if (!TypeTests.empty() || !TypeTestAssumeVCalls.empty() ||
877 !TypeCheckedLoadVCalls.empty() || !TypeTestAssumeConstVCalls.empty() ||
878 !TypeCheckedLoadConstVCalls.empty())
879 TIdInfo = std::make_unique<TypeIdInfo>(
880 TypeIdInfo{std::move(TypeTests), std::move(TypeTestAssumeVCalls),
881 std::move(TypeCheckedLoadVCalls),
882 std::move(TypeTestAssumeConstVCalls),
883 std::move(TypeCheckedLoadConstVCalls)});
885 ParamAccesses = std::make_unique<ParamAccessesTy>(std::move(Params));
886 if (!CallsiteList.empty())
887 Callsites = std::make_unique<CallsitesTy>(std::move(CallsiteList));
888 if (!AllocList.empty())
889 Allocs = std::make_unique<AllocsTy>(std::move(AllocList));
927 return TIdInfo->TypeTests;
936 return TIdInfo->TypeTestAssumeVCalls;
945 return TIdInfo->TypeCheckedLoadVCalls;
954 return TIdInfo->TypeTestAssumeConstVCalls;
962 return TIdInfo->TypeCheckedLoadConstVCalls;
969 return *ParamAccesses;
975 if (NewParams.empty())
976 ParamAccesses.reset();
977 else if (ParamAccesses)
978 *ParamAccesses = std::move(NewParams);
980 ParamAccesses = std::make_unique<ParamAccessesTy>(std::move(NewParams));
987 TIdInfo = std::make_unique<TypeIdInfo>();
988 TIdInfo->TypeTests.push_back(Guid);
1026 return L.GUID == R.GUID && L.Offset == R.Offset;
1048 return I.VFunc.GUID;
1077 std::unique_ptr<VTableFuncList> VTableFuncs;
1111 std::vector<ValueInfo> Refs)
1135 VTableFuncs = std::make_unique<VTableFuncList>(std::move(Funcs));
1140 return *VTableFuncs;
1218 std::map<uint64_t, WholeProgramDevirtResolution>
WPDRes;
1240 std::multimap<GlobalValue::GUID, std::pair<std::string, TypeIdSummary>>;
1284 std::map<std::string, TypeIdCompatibleVtableInfo, std::less<>>
1285 TypeIdCompatibleVtableMap;
1289 std::map<GlobalValue::GUID, GlobalValue::GUID> OidGuidMap;
1294 bool WithGlobalValueDeadStripping =
false;
1299 bool WithAttributePropagation =
false;
1303 bool WithDSOLocalPropagation =
false;
1306 bool WithWholeProgramVisibility =
false;
1309 bool HasSyntheticEntryCounts =
false;
1312 bool WithSupportsHotColdNew =
false;
1319 bool SkipModuleByDistributedBackend =
false;
1328 bool EnableSplitLTOUnit;
1332 bool PartiallySplitLTOUnits =
false;
1335 bool HasParamAccess =
false;
1337 std::set<std::string> CfiFunctionDefs;
1338 std::set<std::string> CfiFunctionDecls;
1358 std::vector<uint64_t> StackIds;
1362 std::map<uint64_t, unsigned> StackIdToIndex;
1367 GlobalValueSummaryMapTy::value_type *
1376 : HaveGVs(HaveGVs), EnableSplitLTOUnit(EnableSplitLTOUnit), Saver(Alloc),
1388 return "[Regular LTO]";
1404 size_t size()
const {
return GlobalValueMap.size(); }
1406 const std::vector<uint64_t> &
stackIds()
const {
return StackIds; }
1409 auto Inserted = StackIdToIndex.insert({StackId, StackIds.size()});
1410 if (Inserted.second)
1411 StackIds.push_back(StackId);
1412 return Inserted.first->second;
1417 return StackIds[
Index];
1426 assert(StackIdToIndex.size() == StackIds.size());
1427 StackIdToIndex.clear();
1428 StackIds.shrink_to_fit();
1434 std::map<ValueInfo, bool> &FunctionHasParent) {
1435 if (!V.getSummaryList().size())
1439 auto S = FunctionHasParent.emplace(V,
false);
1446 dyn_cast<FunctionSummary>(V.getSummaryList().front().get());
1447 assert(
F !=
nullptr &&
"Expected FunctionSummary node");
1449 for (
const auto &
C :
F->calls()) {
1451 auto S = FunctionHasParent.emplace(
C.first,
true);
1454 if (!S.second && S.first->second)
1460 S.first->second =
true;
1469 std::map<ValueInfo, bool> FunctionHasParent;
1471 for (
auto &S : *
this) {
1473 if (!S.second.SummaryList.size() ||
1474 !isa<FunctionSummary>(S.second.SummaryList.front().get()))
1479 std::vector<FunctionSummary::EdgeTy> Edges;
1481 for (
auto &
P : FunctionHasParent) {
1484 Edges.push_back(std::make_pair(
P.first,
CalleeInfo{}));
1486 if (Edges.empty()) {
1491 return CallGraphRoot;
1495 return WithGlobalValueDeadStripping;
1498 WithGlobalValueDeadStripping =
true;
1503 WithAttributePropagation =
true;
1526 return SkipModuleByDistributedBackend;
1529 SkipModuleByDistributedBackend =
true;
1541 return !WithGlobalValueDeadStripping || GVS->
isLive();
1553 auto I = GlobalValueMap.find(GUID);
1554 return ValueInfo(HaveGVs,
I == GlobalValueMap.end() ?
nullptr : &*
I);
1559 return ValueInfo(HaveGVs, getOrInsertValuePtr(GUID));
1570 auto VP = getOrInsertValuePtr(GUID);
1571 VP->second.U.Name =
Name;
1578 auto VP = getOrInsertValuePtr(GV->
getGUID());
1579 VP->second.U.GV = GV;
1585 const auto I = OidGuidMap.find(OriginalID);
1586 return I == OidGuidMap.end() ? 0 :
I->second;
1597 std::unique_ptr<GlobalValueSummary> Summary) {
1603 std::unique_ptr<GlobalValueSummary> Summary) {
1605 std::move(Summary));
1610 std::unique_ptr<GlobalValueSummary> Summary) {
1611 if (
const FunctionSummary *FS = dyn_cast<FunctionSummary>(Summary.get()))
1612 HasParamAccess |= !FS->paramAccesses().empty();
1616 const_cast<GlobalValueSummaryMapTy::value_type *
>(
VI.getRef())
1617 ->second.SummaryList.push_back(std::move(Summary));
1623 if (OrigGUID == 0 || ValueGUID == OrigGUID)
1625 if (OidGuidMap.count(OrigGUID) && OidGuidMap[OrigGUID] != ValueGUID)
1626 OidGuidMap[OrigGUID] = 0;
1628 OidGuidMap[OrigGUID] = ValueGUID;
1634 auto SummaryList =
VI.getSummaryList();
1637 [&](
const std::unique_ptr<GlobalValueSummary> &Summary) {
1638 return Summary->modulePath() == ModuleId;
1640 if (Summary == SummaryList.end())
1642 return Summary->get();
1658 bool PerModuleIndex =
true)
const {
1659 assert(GV.
hasName() &&
"Can't get GlobalValueSummary for GV with no name");
1667 bool PerModuleIndex =
true)
const;
1671 return ModulePathStringTable;
1676 return ModulePathStringTable;
1681 return ModulePathStringTable.
lookup(ModPath).first;
1686 auto It = ModulePathStringTable.
find(ModPath);
1687 assert(It != ModulePathStringTable.
end() &&
"Module not registered");
1688 return It->second.second;
1694 std::string Suffix = utostr((
uint64_t(ModHash[0]) << 32) |
1701 NewName +=
".llvm.";
1703 return std::string(NewName.
str());
1711 std::pair<StringRef, StringRef> Pair =
Name.rsplit(
".llvm.");
1721 return &*ModulePathStringTable.
insert({ModPath, {ModId, Hash}}).first;
1726 auto It = ModulePathStringTable.
find(ModPath);
1727 assert(It != ModulePathStringTable.
end() &&
"Module not registered");
1733 auto It = ModulePathStringTable.
find(ModPath);
1734 assert(It != ModulePathStringTable.
end() &&
"Module not registered");
1742 return ModulePathStringTable.
count(M.getModuleIdentifier());
1752 for (
auto It = TidIter.first; It != TidIter.second; ++It)
1753 if (It->second.first == TypeId)
1754 return It->second.second;
1755 auto It = TypeIdMap.insert(
1757 return It->second.second;
1764 for (
auto It = TidIter.first; It != TidIter.second; ++It)
1765 if (It->second.first == TypeId)
1766 return &It->second.second;
1777 return TypeIdCompatibleVtableMap;
1785 return TypeIdCompatibleVtableMap[std::string(TypeId)];
1790 std::optional<TypeIdCompatibleVtableInfo>
1792 auto I = TypeIdCompatibleVtableMap.find(TypeId);
1793 if (
I == TypeIdCompatibleVtableMap.end())
1794 return std::nullopt;
1805 template <
class Map>
1808 for (
const auto &GlobalList : *
this) {
1809 auto GUID = GlobalList.first;
1810 for (
const auto &Summary : GlobalList.second.SummaryList) {
1811 ModuleToDefinedGVSummaries[Summary->modulePath()][GUID] = Summary.get();
1847 decltype(&valueInfoFromEdge)>;
1854 if (!
N.getSummaryList().size())
1857 &valueInfoFromEdge);
1859 cast<FunctionSummary>(
N.getSummaryList().front()->getBaseObject());
1864 if (!
N.getSummaryList().size())
1867 &valueInfoFromEdge);
1869 cast<FunctionSummary>(
N.getSummaryList().front()->getBaseObject());
1874 if (!
N.getSummaryList().size())
1878 cast<FunctionSummary>(
N.getSummaryList().front()->getBaseObject());
1879 return F->CallGraphEdgeList.begin();
1883 if (!
N.getSummaryList().size())
1887 cast<FunctionSummary>(
N.getSummaryList().front()->getBaseObject());
1888 return F->CallGraphEdgeList.end();
1897 std::unique_ptr<GlobalValueSummary> Root =
1898 std::make_unique<FunctionSummary>(
I->calculateCallGraphRoot());
1900 G.SummaryList.push_back(std::move(Root));
This file defines the StringMap class.
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
Looks at all the uses of the given value Returns the Liveness deduced from the uses of this value Adds all uses that cause the result to be MaybeLive to MaybeLiveRetUses If the result is Live
This file defines the DenseMap class.
static const char * PreservedSymbols[]
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the SmallVector class.
ScaledNumber< uint64_t > Scaled64
Alias summary information.
GlobalValue::GUID getAliaseeGUID() const
const GlobalValueSummary & getAliasee() const
ValueInfo getAliaseeVI() const
static bool classof(const GlobalValueSummary *GVS)
Check if this is an alias summary.
AliasSummary(GVFlags Flags)
GlobalValueSummary & getAliasee()
void setAliasee(ValueInfo &AliaseeVI, GlobalValueSummary *Aliasee)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Allocate memory in an ever growing pool, as if by bump-pointer.
This class represents a range of values.
This is an important base class in LLVM.
Implements a dense probed hash-table based set.
Function summary information to aid decisions and implementation of importing.
static FunctionSummary ExternalNode
A dummy node to reference external functions that aren't in the index.
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)
ArrayRef< VFuncId > type_test_assume_vcalls() const
Returns the list of virtual calls made by this function using llvm.assume(llvm.type....
AllocsTy & mutableAllocs()
ArrayRef< ConstVCall > type_test_assume_const_vcalls() const
Returns the list of virtual calls made by this function using llvm.assume(llvm.type....
static FunctionSummary makeDummyFunctionSummary(std::vector< FunctionSummary::EdgeTy > Edges)
Create an empty FunctionSummary (with specified call edges).
std::pair< ValueInfo, CalleeInfo > EdgeTy
<CalleeValueInfo, CalleeInfo> call edge pair.
std::pair< unsigned, unsigned > specialRefCounts() const
void setEntryCount(uint64_t EC)
Set the synthetic entry count for this function.
ArrayRef< AllocInfo > allocs() const
ArrayRef< CallsiteInfo > callsites() const
void addTypeTest(GlobalValue::GUID Guid)
Add a type test to the summary.
uint64_t entryCount() const
Get the synthetic entry count for this function.
std::vector< EdgeTy > & mutableCalls()
ArrayRef< VFuncId > type_checked_load_vcalls() const
Returns the list of virtual calls made by this function using llvm.type.checked.load intrinsics that ...
void setParamAccesses(std::vector< ParamAccess > NewParams)
Sets the list of known uses of pointer parameters.
unsigned instCount() const
Get the instruction count recorded for this function.
const TypeIdInfo * getTypeIdInfo() const
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 ...
ArrayRef< EdgeTy > calls() const
Return the list of <CalleeValueInfo, CalleeInfo> pairs.
ArrayRef< ParamAccess > paramAccesses() const
Returns the list of known uses of pointer parameters.
CallsitesTy & mutableCallsites()
ForceSummaryHotnessType
Types for -force-summary-edges-cold debugging option.
FFlags fflags() const
Get function summary flags.
ArrayRef< GlobalValue::GUID > type_tests() const
Returns the list of type identifiers used by this function in llvm.type.test intrinsics other than by...
static bool classof(const GlobalValueSummary *GVS)
Check if this is a function summary.
Function and variable summary information to aid decisions and implementation of importing.
SummaryKind
Sububclass discriminator (for dyn_cast<> et al.)
GVFlags flags() const
Get the flags for this GlobalValue (see struct GVFlags).
void setDSOLocal(bool Local)
StringRef modulePath() const
Get the path to the module containing this function.
GlobalValueSummary * getBaseObject()
If this is an alias summary, returns the summary of the aliased object (a global variable or function...
SummaryKind getSummaryKind() const
Which kind of summary subclass this is.
GlobalValue::GUID getOriginalName() const
Returns the hash of the original name, it is identical to the GUID for externally visible symbols,...
GlobalValue::VisibilityTypes getVisibility() const
ArrayRef< ValueInfo > refs() const
Return the list of values referenced by this global value definition.
GlobalValueSummary(SummaryKind K, GVFlags Flags, std::vector< ValueInfo > Refs)
void setLinkage(GlobalValue::LinkageTypes Linkage)
Sets the linkage to the value determined by global summary-based optimization.
void setVisibility(GlobalValue::VisibilityTypes Vis)
virtual ~GlobalValueSummary()=default
void setModulePath(StringRef ModPath)
Set the path to the module containing this function, for use in the combined index.
void setNotEligibleToImport()
Flag that this global value cannot be imported.
void setCanAutoHide(bool CanAutoHide)
GlobalValue::LinkageTypes linkage() const
Return linkage type recorded for this global value.
bool notEligibleToImport() const
Return true if this global value can't be imported.
void setOriginalName(GlobalValue::GUID Name)
Initialize the original name hash in this summary.
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
VisibilityTypes
An enumeration for the kinds of visibility of global values.
@ DefaultVisibility
The GV is visible.
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
LinkageTypes
An enumeration for the kinds of linkage for global values.
@ AvailableExternallyLinkage
Available for inspection, not emission.
Global variable summary information to aid decisions and implementation of importing.
void setWriteOnly(bool WO)
bool maybeWriteOnly() const
void setVCallVisibility(GlobalObject::VCallVisibility Vis)
struct llvm::GlobalVarSummary::GVarFlags VarFlags
GVarFlags varflags() const
bool maybeReadOnly() const
void setReadOnly(bool RO)
ArrayRef< VirtFuncOffset > vTableFuncs() const
GlobalObject::VCallVisibility getVCallVisibility() const
static bool classof(const GlobalValueSummary *GVS)
Check if this is a global variable summary.
GlobalVarSummary(GVFlags Flags, GVarFlags VarFlags, std::vector< ValueInfo > Refs)
void setVTableFuncs(VTableFuncList Funcs)
Class to hold module path string table and global value map, and encapsulate methods for operating on...
bool withAttributePropagation() const
std::set< std::string > & cfiFunctionDecls()
const std::set< std::string > & cfiFunctionDecls() const
TypeIdSummary & getOrInsertTypeIdSummary(StringRef TypeId)
Return an existing or new TypeIdSummary entry for TypeId.
std::optional< TypeIdCompatibleVtableInfo > getTypeIdCompatibleVtableSummary(StringRef TypeId) const
For the given TypeId, this returns the TypeIdCompatibleVtableMap entry if present in the summary map.
void addGlobalValueSummary(ValueInfo VI, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for the given ValueInfo.
ModulePathStringTableTy::value_type ModuleInfo
uint64_t getBlockCount() const
ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID)
Return a ValueInfo for GUID.
bool withGlobalValueDeadStripping() const
const std::set< std::string > & cfiFunctionDefs() const
static void discoverNodes(ValueInfo V, std::map< ValueInfo, bool > &FunctionHasParent)
Convenience function for doing a DFS on a ValueInfo.
StringRef saveString(StringRef String)
bool withWholeProgramVisibility() const
const TypeIdSummaryMapTy & typeIds() const
static StringRef getOriginalNameBeforePromote(StringRef Name)
Helper to obtain the unpromoted name for a global value (or the original name if not promoted).
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 ...
bool isGUIDLive(GlobalValue::GUID GUID) const
StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths()
Table of modules, containing hash and id.
gvsummary_iterator begin()
const_gvsummary_iterator end() const
bool isReadOnly(const GlobalVarSummary *GVS) const
void setFlags(uint64_t Flags)
const_gvsummary_iterator begin() const
uint64_t getModuleId(const StringRef ModPath) const
Get the module ID recorded for the given module path.
bool isWriteOnly(const GlobalVarSummary *GVS) const
ModuleSummaryIndex(bool HaveGVs, bool EnableSplitLTOUnit=false)
void addBlockCount(uint64_t C)
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 setPartiallySplitLTOUnits()
const std::vector< uint64_t > & stackIds() const
GlobalValueSummary * findSummaryInModule(GlobalValue::GUID ValueGUID, StringRef ModuleId) const
Find the summary for global GUID in module ModuleId, or nullptr if not found.
void releaseTemporaryMemory()
void setBlockCount(uint64_t C)
ValueInfo getValueInfo(const GlobalValueSummaryMapTy::value_type &R) const
Return a ValueInfo for the index value_type (convenient when iterating index).
const ModuleHash & getModuleHash(const StringRef ModPath) const
Get the module SHA1 hash recorded for the given module path.
static constexpr const char * getRegularLTOModuleName()
void setEnableSplitLTOUnit()
void setHasSyntheticEntryCounts()
void addGlobalValueSummary(StringRef ValueName, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for a value of the given name.
bool hasSyntheticEntryCounts() const
bool partiallySplitLTOUnits() const
void collectDefinedFunctionsForModule(StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const
Collect for the given module the list of functions it defines (GUID -> Summary).
const auto & typeIdCompatibleVtableMap() const
void dumpSCCs(raw_ostream &OS)
Print out strongly connected components for debugging.
bool isGlobalValueLive(const GlobalValueSummary *GVS) const
bool enableSplitLTOUnit() const
void setWithSupportsHotColdNew()
const ModuleInfo * getModule(StringRef ModPath) const
Return module entry for module with the given ModPath.
void propagateAttributes(const DenseSet< GlobalValue::GUID > &PreservedSymbols)
Do the access attribute and DSOLocal propagation in combined index.
void setSkipModuleByDistributedBackend()
void setWithAttributePropagation()
bool withSupportsHotColdNew() const
void dump() const
Dump to stderr (for debugging).
void collectDefinedGVSummariesPerModule(Map &ModuleToDefinedGVSummaries) const
Collect for each module the list of Summaries it defines (GUID -> Summary).
void addGlobalValueSummary(const GlobalValue &GV, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for a value.
bool hasExportedFunctions(const Module &M) const
Check if the given Module has any functions available for exporting in the index.
static std::string getGlobalNameForLocal(StringRef Name, ModuleHash ModHash)
Convenience method for creating a promoted global name for the given value name of a local,...
static constexpr uint64_t BitcodeSummaryVersion
bool withDSOLocalPropagation() const
void exportToDot(raw_ostream &OS, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols) const
Export summary to dot file for GraphViz.
bool hasParamAccess() const
void setWithDSOLocalPropagation()
uint64_t getStackIdAtIndex(unsigned Index) const
void print(raw_ostream &OS, bool IsForDebug=false) const
Print to an output stream.
bool skipModuleByDistributedBackend() const
ValueInfo getOrInsertValueInfo(const GlobalValue *GV)
Return a ValueInfo for GV and mark it as belonging to GV.
GlobalValueSummary * findSummaryInModule(ValueInfo VI, StringRef ModuleId) const
Find the summary for ValueInfo VI in module ModuleId, or nullptr if not found.
const StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths() const
Table of modules, containing module hash and id.
ValueInfo getValueInfo(GlobalValue::GUID GUID) const
Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
uint64_t getFlags() const
unsigned addOrGetStackIdIndex(uint64_t StackId)
GlobalValue::GUID getGUIDFromOriginalID(GlobalValue::GUID OriginalID) const
Return the GUID for OriginalId in the OidGuidMap.
GlobalValueSummary * getGlobalValueSummary(const GlobalValue &GV, bool PerModuleIndex=true) const
Returns the first GlobalValueSummary for GV, asserting that there is only one if PerModuleIndex.
std::set< std::string > & cfiFunctionDefs()
void setWithGlobalValueDeadStripping()
ModuleInfo * getModule(StringRef ModPath)
Return module entry for module with the given ModPath.
ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID, StringRef Name)
Return a ValueInfo for GUID setting value Name.
void setWithWholeProgramVisibility()
bool canImportGlobalVar(const GlobalValueSummary *S, bool AnalyzeRefs) const
Checks if we can import global variable from another module.
static std::string getGlobalNameForLocal(StringRef Name, StringRef Suffix)
void addOriginalName(GlobalValue::GUID ValueGUID, GlobalValue::GUID OrigGUID)
Add an original name for the value of the given GUID.
FunctionSummary calculateCallGraphRoot()
TypeIdSummary * getTypeIdSummary(StringRef TypeId)
TypeIdCompatibleVtableInfo & getOrInsertTypeIdCompatibleVtableSummary(StringRef TypeId)
Return an existing or new TypeIdCompatibleVtableMap entry for TypeId.
A Module instance is used to store all the information related to an LLVM module.
PointerIntPair - This class implements a pair of a pointer and small integer.
void setPointer(PointerTy PtrVal) &
void setInt(IntType IntVal) &
PointerTy getPointer() const
Simple representation of a scaled number.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef str() const
Explicit conversion to StringRef.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
iterator find(StringRef Key)
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
StringRef - Represent a constant reference to a string, i.e.
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
StringRef save(const char *S)
A Use represents the edge between a Value definition and its users.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Cold
Attempts to make code in the caller as efficient as possible under the assumption that the call is no...
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
GlobalValueSummaryMapTy::iterator gvsummary_iterator
bool operator<(int64_t V1, const APSInt &V2)
const char * getHotnessName(CalleeInfo::HotnessType HT)
bool operator!=(uint64_t V1, const APInt &V2)
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
std::vector< VirtFuncOffset > VTableFuncList
List of functions referenced by a particular vtable definition.
std::vector< std::unique_ptr< GlobalValueSummary > > GlobalValueSummaryList
GlobalValueSummaryMapTy::const_iterator const_gvsummary_iterator
Type used for iterating through the global value summary map.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
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).
auto find_if(R &&Range, UnaryPredicate P)
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
std::map< GlobalValue::GUID, GlobalValueSummaryInfo > GlobalValueSummaryMapTy
Map from global value GUID to corresponding summary structures.
std::vector< TypeIdOffsetVtableInfo > TypeIdCompatibleVtableInfo
List of vtable definitions decorated by a particular type identifier, and their corresponding offsets...
Summary of memprof metadata on allocations.
AllocInfo(std::vector< MIBInfo > MIBs)
AllocInfo(SmallVector< uint8_t > Versions, std::vector< MIBInfo > MIBs)
SmallVector< uint8_t > Versions
std::vector< MIBInfo > MIBs
Class to accumulate and hold information about a callee.
static constexpr uint64_t MaxRelBlockFreq
uint32_t RelBlockFreq
The value stored in RelBlockFreq has to be interpreted as the digits of a scaled number with a scale ...
void updateHotness(const HotnessType OtherHotness)
HotnessType getHotness() const
static constexpr int32_t ScaleShift
CalleeInfo(HotnessType Hotness, uint64_t RelBF)
void updateRelBlockFreq(uint64_t BlockFreq, uint64_t EntryFreq)
Update RelBlockFreq from BlockFreq and EntryFreq.
Summary of memprof callsite metadata.
SmallVector< unsigned > StackIdIndices
SmallVector< unsigned > Clones
CallsiteInfo(ValueInfo Callee, SmallVector< unsigned > StackIdIndices)
CallsiteInfo(ValueInfo Callee, SmallVector< unsigned > Clones, SmallVector< unsigned > StackIdIndices)
static FunctionSummary::ConstVCall getEmptyKey()
static FunctionSummary::ConstVCall getTombstoneKey()
static unsigned getHashValue(FunctionSummary::ConstVCall I)
static bool isEqual(FunctionSummary::ConstVCall L, FunctionSummary::ConstVCall R)
static FunctionSummary::VFuncId getEmptyKey()
static bool isEqual(FunctionSummary::VFuncId L, FunctionSummary::VFuncId R)
static FunctionSummary::VFuncId getTombstoneKey()
static unsigned getHashValue(FunctionSummary::VFuncId I)
static bool isEqual(ValueInfo L, ValueInfo R)
static ValueInfo getEmptyKey()
static ValueInfo getTombstoneKey()
static bool isSpecialKey(ValueInfo V)
static unsigned getHashValue(ValueInfo I)
An information struct used to provide DenseMap with the various necessary components for a given valu...
A specification for a virtual function call with all constant integer arguments.
std::vector< uint64_t > Args
Flags specific to function summaries.
FFlags & operator&=(const FFlags &RHS)
unsigned ReturnDoesNotAlias
unsigned MustBeUnreachable
Describes the use of a value in a call instruction, specifying the call's target, the value's paramet...
Call(uint64_t ParamNo, ValueInfo Callee, const ConstantRange &Offsets)
Describes the uses of a parameter by the function.
ParamAccess(uint64_t ParamNo, const ConstantRange &Use)
std::vector< Call > Calls
In the per-module summary, it summarizes the byte offset applied to each pointer parameter before pas...
static constexpr uint32_t RangeWidth
All type identifier related information.
std::vector< ConstVCall > TypeCheckedLoadConstVCalls
std::vector< VFuncId > TypeCheckedLoadVCalls
std::vector< ConstVCall > TypeTestAssumeConstVCalls
List of virtual calls made by this function using (respectively) llvm.assume(llvm....
std::vector< GlobalValue::GUID > TypeTests
List of type identifiers used by this function in llvm.type.test intrinsics referenced by something o...
std::vector< VFuncId > TypeTestAssumeVCalls
List of virtual calls made by this function using (respectively) llvm.assume(llvm....
An "identifier" for a virtual function.
GlobalValueSummaryList SummaryList
List of global value summary structures for a particular value held in the GlobalValueMap.
GlobalValueSummaryInfo(bool HaveGVs)
union llvm::GlobalValueSummaryInfo::NameOrGV U
Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
GVFlags(GlobalValue::LinkageTypes Linkage, GlobalValue::VisibilityTypes Visibility, bool NotEligibleToImport, bool Live, bool IsLocal, bool CanAutoHide)
Convenience Constructors.
unsigned DSOLocal
Indicates that the linker resolved the symbol to a definition from within the same linkage unit.
unsigned CanAutoHide
In the per-module summary, indicates that the global value is linkonce_odr and global unnamed addr (s...
unsigned NotEligibleToImport
Indicate if the global value cannot be imported (e.g.
unsigned Linkage
The linkage type of the associated global value.
unsigned Visibility
Indicates the visibility.
unsigned Live
In per-module summary, indicate that the global value must be considered a live root for index-based ...
GVarFlags(bool ReadOnly, bool WriteOnly, bool Constant, GlobalObject::VCallVisibility Vis)
static NodeRef getEntryNode(ModuleSummaryIndex *I)
static NodeRef valueInfoFromEdge(FunctionSummary::EdgeTy &P)
static ChildIteratorType child_begin(NodeRef N)
static ChildEdgeIteratorType child_edge_begin(NodeRef N)
static NodeRef edge_dest(EdgeRef E)
std::vector< FunctionSummary::EdgeTy >::iterator ChildEdgeIteratorType
static NodeRef getEntryNode(ValueInfo V)
static ChildIteratorType child_end(NodeRef N)
static ChildEdgeIteratorType child_edge_end(NodeRef N)
FunctionSummary::EdgeTy & EdgeRef
Summary of a single MIB in a memprof metadata on allocations.
MIBInfo(AllocationType AllocType, SmallVector< unsigned > StackIdIndices)
SmallVector< unsigned > StackIdIndices
The following data structures summarize type metadata information.
TypeIdOffsetVtableInfo(uint64_t Offset, ValueInfo VI)
uint64_t AddressPointOffset
std::map< uint64_t, WholeProgramDevirtResolution > WPDRes
Mapping from byte offset to whole-program devirt resolution for that (typeid, byte offset) pair.
Kind
Specifies which kind of type check we should emit for this byte array.
@ Unknown
Unknown (analysis not performed, don't lower)
@ Single
Single element (last example in "Short Inline Bit Vectors")
@ Inline
Inlined bit vector ("Short Inline Bit Vectors")
@ Unsat
Unsatisfiable type (i.e. no global has this type metadata)
@ AllOnes
All-ones bit vector ("Eliminating Bit Vector Checks for All-Ones Bit Vectors")
@ ByteArray
Test a byte array (first example)
unsigned SizeM1BitWidth
Range of size-1 expressed as a bit width.
enum llvm::TypeTestResolution::Kind TheKind
Struct that holds a reference to a particular GUID in a global value summary.
PointerIntPair< const GlobalValueSummaryMapTy::value_type *, 3, int > RefAndFlags
GlobalValue::VisibilityTypes getELFVisibility() const
Returns the most constraining visibility among summaries.
bool isValidAccessSpecifier() const
const GlobalValueSummaryMapTy::value_type * getRef() const
ArrayRef< std::unique_ptr< GlobalValueSummary > > getSummaryList() const
const GlobalValue * getValue() const
ValueInfo(bool HaveGVs, const GlobalValueSummaryMapTy::value_type *R)
bool canAutoHide() const
Checks if all copies are eligible for auto-hiding (have flag set).
unsigned getAccessSpecifier() const
bool isDSOLocal(bool WithDSOLocalPropagation=false) const
Checks if all summaries are DSO local (have the flag set).
GlobalValue::GUID getGUID() const
The ValueInfo and offset for a function within a vtable definition initializer array.
VirtFuncOffset(ValueInfo VI, uint64_t Offset)
@ UniformRetVal
Uniform return value optimization.
@ VirtualConstProp
Virtual constant propagation.
@ UniqueRetVal
Unique return value optimization.
@ Indir
Just do a regular virtual call.
uint64_t Info
Additional information for the resolution:
enum llvm::WholeProgramDevirtResolution::ByArg::Kind TheKind
enum llvm::WholeProgramDevirtResolution::Kind TheKind
std::map< std::vector< uint64_t >, ByArg > ResByArg
Resolutions for calls with all constant integer arguments (excluding the first argument,...
std::string SingleImplName
@ SingleImpl
Single implementation devirtualization.
@ Indir
Just do a regular virtual call.
@ BranchFunnel
When retpoline mitigation is enabled, use a branch funnel that is defined in the merged module.
const GlobalValue * GV
The GlobalValue corresponding to this summary.
StringRef Name
Summary string representation.