Go to the documentation of this file.
15 #ifndef LLVM_IR_MODULESUMMARYINDEX_H
16 #define LLVM_IR_MODULESUMMARYINDEX_H
47 template <
class GraphType>
struct GraphTraits;
121 class GlobalValueSummary;
163 std::map<GlobalValue::GUID, GlobalValueSummaryInfo>;
173 ValueInfo(
bool HaveGVs,
const GlobalValueSummaryMapTy::value_type *R) {
178 explicit operator bool()
const {
return getRef(); }
183 return getRef()->second.U.GV;
187 return getRef()->second.SummaryList;
192 :
getRef()->second.U.Name;
223 const GlobalValueSummaryMapTy::value_type *
getRef()
const {
234 bool isDSOLocal(
bool WithDSOLocalPropagation =
false)
const;
242 if (!
VI.name().empty())
243 OS <<
" (" <<
VI.name() <<
")";
248 assert(A.getRef() &&
B.getRef() &&
249 "Need ValueInfo with non-null Ref for comparison");
250 return A.getRef() ==
B.getRef();
254 assert(A.getRef() &&
B.getRef() &&
255 "Need ValueInfo with non-null Ref for comparison");
256 return A.getRef() !=
B.getRef();
260 assert(A.getRef() &&
B.getRef() &&
261 "Need ValueInfo with non-null Ref to compare GUIDs");
262 return A.getGUID() <
B.getGUID();
267 return ValueInfo(
false, (GlobalValueSummaryMapTy::value_type *)-8);
271 return ValueInfo(
false, (GlobalValueSummaryMapTy::value_type *)-16);
275 return V == getTombstoneKey() || V == getEmptyKey();
281 assert(isSpecialKey(L) || isSpecialKey(R) || (L.
haveGVs() == R.haveGVs()));
282 return L.
getRef() == R.getRef();
368 std::vector<ValueInfo> RefEdgeList;
372 : Kind(K), Flags(Flags), RefEdgeList(
std::
move(Refs)) {
374 "Expect no references for AliasSummary");
408 Flags.Linkage = Linkage;
414 bool isLive()
const {
return Flags.Live; }
416 void setLive(
bool Live) { Flags.Live = Live; }
430 Flags.Visibility = (unsigned)Vis;
460 AliaseeSummary(
nullptr) {}
468 AliaseeValueInfo = AliaseeVI;
469 AliaseeSummary = Aliasee;
473 assert(!!AliaseeSummary == (AliaseeValueInfo &&
475 "Expect to have both aliasee summary and summary list or neither");
476 return !!AliaseeSummary;
480 assert(AliaseeSummary &&
"Unexpected missing aliasee summary");
481 return *AliaseeSummary;
489 assert(AliaseeValueInfo &&
"Unexpected missing aliasee");
490 return AliaseeValueInfo;
493 assert(AliaseeValueInfo &&
"Unexpected missing aliasee");
494 return AliaseeValueInfo.
getGUID();
499 if (
auto *AS = dyn_cast<AliasSummary>(
this))
500 return &AS->getAliasee();
505 if (
auto *AS = dyn_cast<AliasSummary>(
this))
506 return &AS->getAliasee();
515 using EdgeTy = std::pair<ValueInfo, CalleeInfo>;
611 operator std::string() {
614 OS <<
"funcFlags: (";
615 OS <<
"readNone: " << this->
ReadNone;
616 OS <<
", readOnly: " << this->
ReadOnly;
617 OS <<
", noRecurse: " << this->
NoRecurse;
619 OS <<
", noInline: " << this->
NoInline;
621 OS <<
", noUnwind: " << this->
NoUnwind;
622 OS <<
", mayThrow: " << this->
MayThrow;
670 GlobalValue::LinkageTypes::AvailableExternallyLinkage,
675 std::vector<ValueInfo>(),
std::move(Edges),
676 std::vector<GlobalValue::GUID>(),
677 std::vector<FunctionSummary::VFuncId>(),
678 std::vector<FunctionSummary::VFuncId>(),
679 std::vector<FunctionSummary::ConstVCall>(),
680 std::vector<FunctionSummary::ConstVCall>(),
681 std::vector<FunctionSummary::ParamAccess>());
701 std::vector<EdgeTy> CallGraphEdgeList;
703 std::unique_ptr<TypeIdInfo> TIdInfo;
706 using ParamAccessesTy = std::vector<ParamAccess>;
707 std::unique_ptr<ParamAccessesTy> ParamAccesses;
711 uint64_t EntryCount, std::vector<ValueInfo> Refs,
712 std::vector<EdgeTy> CGEdges,
713 std::vector<GlobalValue::GUID> TypeTests,
714 std::vector<VFuncId> TypeTestAssumeVCalls,
715 std::vector<VFuncId> TypeCheckedLoadVCalls,
716 std::vector<ConstVCall> TypeTestAssumeConstVCalls,
717 std::vector<ConstVCall> TypeCheckedLoadConstVCalls,
718 std::vector<ParamAccess> Params)
720 InstCount(NumInsts), FunFlags(FunFlags), EntryCount(EntryCount),
721 CallGraphEdgeList(
std::
move(CGEdges)) {
722 if (!TypeTests.empty() || !TypeTestAssumeVCalls.empty() ||
723 !TypeCheckedLoadVCalls.empty() || !TypeTestAssumeConstVCalls.empty() ||
724 !TypeCheckedLoadConstVCalls.empty())
725 TIdInfo = std::make_unique<TypeIdInfo>(
731 ParamAccesses = std::make_unique<ParamAccessesTy>(
std::move(Params));
769 return TIdInfo->TypeTests;
778 return TIdInfo->TypeTestAssumeVCalls;
787 return TIdInfo->TypeCheckedLoadVCalls;
796 return TIdInfo->TypeTestAssumeConstVCalls;
804 return TIdInfo->TypeCheckedLoadConstVCalls;
811 return *ParamAccesses;
817 if (NewParams.empty())
818 ParamAccesses.reset();
819 else if (ParamAccesses)
822 ParamAccesses = std::make_unique<ParamAccessesTy>(
std::move(NewParams));
829 TIdInfo = std::make_unique<TypeIdInfo>();
830 TIdInfo->TypeTests.push_back(Guid);
846 return L.
GUID == R.GUID && L.
Offset == R.Offset;
897 std::unique_ptr<VTableFuncList> VTableFuncs;
931 std::vector<ValueInfo> Refs)
955 VTableFuncs = std::make_unique<VTableFuncList>(
std::move(Funcs));
1038 std::map<uint64_t, WholeProgramDevirtResolution>
WPDRes;
1060 std::multimap<GlobalValue::GUID, std::pair<std::string, TypeIdSummary>>;
1104 std::map<std::string, TypeIdCompatibleVtableInfo, std::less<>>
1105 TypeIdCompatibleVtableMap;
1109 std::map<GlobalValue::GUID, GlobalValue::GUID> OidGuidMap;
1114 bool WithGlobalValueDeadStripping =
false;
1119 bool WithAttributePropagation =
false;
1123 bool WithDSOLocalPropagation =
false;
1126 bool HasSyntheticEntryCounts =
false;
1133 bool SkipModuleByDistributedBackend =
false;
1142 bool EnableSplitLTOUnit;
1146 bool PartiallySplitLTOUnits =
false;
1149 bool HasParamAccess =
false;
1151 std::set<std::string> CfiFunctionDefs;
1152 std::set<std::string> CfiFunctionDecls;
1166 GlobalValueSummaryMapTy::value_type *
1175 : HaveGVs(HaveGVs), EnableSplitLTOUnit(EnableSplitLTOUnit), Saver(Alloc),
1187 return "[Regular LTO]";
1203 size_t size()
const {
return GlobalValueMap.size(); }
1208 std::map<ValueInfo, bool> &FunctionHasParent) {
1213 auto S = FunctionHasParent.emplace(V,
false);
1221 assert(
F !=
nullptr &&
"Expected FunctionSummary node");
1223 for (
auto &
C :
F->calls()) {
1225 auto S = FunctionHasParent.emplace(
C.first,
true);
1228 if (!
S.second &&
S.first->second)
1234 S.first->second =
true;
1243 std::map<ValueInfo, bool> FunctionHasParent;
1245 for (
auto &
S : *
this) {
1247 if (!
S.second.SummaryList.size() ||
1248 !isa<FunctionSummary>(
S.second.SummaryList.front().get()))
1253 std::vector<FunctionSummary::EdgeTy> Edges;
1255 for (
auto &
P : FunctionHasParent) {
1258 Edges.push_back(std::make_pair(
P.first,
CalleeInfo{}));
1260 if (Edges.empty()) {
1265 return CallGraphRoot;
1269 return WithGlobalValueDeadStripping;
1272 WithGlobalValueDeadStripping =
true;
1277 WithAttributePropagation =
true;
1294 return SkipModuleByDistributedBackend;
1297 SkipModuleByDistributedBackend =
true;
1309 return !WithGlobalValueDeadStripping || GVS->
isLive();
1321 auto I = GlobalValueMap.find(GUID);
1322 return ValueInfo(HaveGVs,
I == GlobalValueMap.end() ?
nullptr : &*
I);
1327 return ValueInfo(HaveGVs, getOrInsertValuePtr(GUID));
1338 auto VP = getOrInsertValuePtr(GUID);
1339 VP->second.U.Name =
Name;
1346 auto VP = getOrInsertValuePtr(GV->
getGUID());
1347 VP->second.U.GV = GV;
1353 const auto I = OidGuidMap.find(OriginalID);
1354 return I == OidGuidMap.end() ? 0 :
I->second;
1365 std::unique_ptr<GlobalValueSummary> Summary) {
1371 std::unique_ptr<GlobalValueSummary> Summary) {
1378 std::unique_ptr<GlobalValueSummary> Summary) {
1380 HasParamAccess |= !
FS->paramAccesses().empty();
1384 const_cast<GlobalValueSummaryMapTy::value_type *
>(
VI.getRef())
1385 ->second.SummaryList.push_back(
std::move(Summary));
1391 if (OrigGUID == 0 || ValueGUID == OrigGUID)
1393 if (OidGuidMap.count(OrigGUID) && OidGuidMap[OrigGUID] != ValueGUID)
1394 OidGuidMap[OrigGUID] = 0;
1396 OidGuidMap[OrigGUID] = ValueGUID;
1402 auto SummaryList =
VI.getSummaryList();
1405 [&](
const std::unique_ptr<GlobalValueSummary> &Summary) {
1406 return Summary->modulePath() == ModuleId;
1408 if (Summary == SummaryList.end())
1410 return Summary->get();
1426 bool PerModuleIndex =
true)
const {
1427 assert(GV.
hasName() &&
"Can't get GlobalValueSummary for GV with no name");
1435 bool PerModuleIndex =
true)
const;
1439 return ModulePathStringTable;
1444 return ModulePathStringTable;
1449 return ModulePathStringTable.
lookup(ModPath).first;
1454 auto It = ModulePathStringTable.
find(ModPath);
1455 assert(It != ModulePathStringTable.
end() &&
"Module not registered");
1456 return It->second.second;
1463 NewName +=
".llvm.";
1464 NewName += utostr((
uint64_t(ModHash[0]) << 32) |
1466 return std::string(NewName.
str());
1474 std::pair<StringRef, StringRef> Pair =
Name.rsplit(
".llvm.");
1484 return &*ModulePathStringTable.
insert({ModPath, {ModId, Hash}}).first;
1489 auto It = ModulePathStringTable.
find(ModPath);
1490 assert(It != ModulePathStringTable.
end() &&
"Module not registered");
1498 return ModulePathStringTable.
count(
M.getModuleIdentifier());
1508 for (
auto It = TidIter.first; It != TidIter.second; ++It)
1509 if (It->second.first == TypeId)
1510 return It->second.second;
1511 auto It = TypeIdMap.insert(
1513 return It->second.second;
1520 for (
auto It = TidIter.first; It != TidIter.second; ++It)
1521 if (It->second.first == TypeId)
1522 return &It->second.second;
1533 return TypeIdCompatibleVtableMap;
1541 return TypeIdCompatibleVtableMap[std::string(TypeId)];
1548 auto I = TypeIdCompatibleVtableMap.find(TypeId);
1549 if (
I == TypeIdCompatibleVtableMap.end())
1561 template <
class Map>
1564 for (
auto &GlobalList : *
this) {
1565 auto GUID = GlobalList.first;
1566 for (
auto &Summary : GlobalList.second.SummaryList) {
1567 ModuleToDefinedGVSummaries[Summary->modulePath()][GUID] = Summary.get();
1601 using ChildIteratorType =
1603 decltype(&valueInfoFromEdge)>;
1610 if (!
N.getSummaryList().size())
1613 &valueInfoFromEdge);
1615 cast<FunctionSummary>(
N.getSummaryList().front()->getBaseObject());
1620 if (!
N.getSummaryList().size())
1623 &valueInfoFromEdge);
1625 cast<FunctionSummary>(
N.getSummaryList().front()->getBaseObject());
1630 if (!
N.getSummaryList().size())
1634 cast<FunctionSummary>(
N.getSummaryList().front()->getBaseObject());
1635 return F->CallGraphEdgeList.begin();
1639 if (!
N.getSummaryList().size())
1643 cast<FunctionSummary>(
N.getSummaryList().front()->getBaseObject());
1644 return F->CallGraphEdgeList.end();
1653 std::unique_ptr<GlobalValueSummary> Root =
1654 std::make_unique<FunctionSummary>(
I->calculateCallGraphRoot());
1664 #endif // LLVM_IR_MODULESUMMARYINDEX_H
All type identifier related information.
std::map< std::vector< uint64_t >, ByArg > ResByArg
Resolutions for calls with all constant integer arguments (excluding the first argument,...
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
ValueInfo(bool HaveGVs, const GlobalValueSummaryMapTy::value_type *R)
GlobalValueSummaryMapTy::const_iterator const_gvsummary_iterator
Type used for iterating through the global value summary map.
ArrayRef< std::unique_ptr< GlobalValueSummary > > getSummaryList() const
void addGlobalValueSummary(StringRef ValueName, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for a value of the given name.
bool hasSyntheticEntryCounts() const
static bool isEqual(FunctionSummary::VFuncId L, FunctionSummary::VFuncId R)
const GlobalValue * GV
The GlobalValue corresponding to this summary.
This is an optimization pass for GlobalISel generic memory operations.
std::vector< uint64_t > Args
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID, StringRef Name)
Return a ValueInfo for GUID setting value Name.
static ValueInfo getEmptyKey()
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
TypeIdSummary * getTypeIdSummary(StringRef TypeId)
enum llvm::WholeProgramDevirtResolution::ByArg::Kind TheKind
static NodeRef edge_dest(EdgeRef E)
void setNotEligibleToImport()
Flag that this global value cannot be imported.
static NodeRef getEntryNode(ValueInfo V)
void setModulePath(StringRef ModPath)
Set the path to the module containing this function, for use in the combined index.
static ChildIteratorType child_begin(NodeRef N)
const_gvsummary_iterator begin() const
ModuleInfo * getModule(StringRef ModPath)
Return module entry for module with the given ModPath.
ModulePathStringTableTy::value_type ModuleInfo
void setInt(IntType IntVal) &
std::map< GlobalValue::GUID, GlobalValueSummaryInfo > GlobalValueSummaryMapTy
Map from global value GUID to corresponding summary structures.
static bool isEqual(ValueInfo L, ValueInfo R)
void setPartiallySplitLTOUnits()
bool isReadOnly(const GlobalVarSummary *GVS) const
static bool classof(const GlobalValueSummary *GVS)
Check if this is a function summary.
const ModuleHash & getModuleHash(const StringRef ModPath) const
Get the module SHA1 hash recorded for the given module path.
ArrayRef< EdgeTy > calls() const
Return the list of <CalleeValueInfo, CalleeInfo> pairs.
void setEnableSplitLTOUnit()
static constexpr uint64_t MaxRelBlockFreq
StringRef saveString(StringRef String)
Kind
Specifies which kind of type check we should emit for this byte array.
FFlags fflags() const
Get function summary flags.
ArrayRef< ParamAccess > paramAccesses() const
Returns the list of known uses of pointer parameters.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Global variable summary information to aid decisions and implementation of importing.
A raw_ostream that writes to an std::string.
void setWriteOnly(bool WO)
static ChildEdgeIteratorType child_edge_end(NodeRef N)
std::vector< FunctionSummary::EdgeTy >::iterator ChildEdgeIteratorType
GlobalValue::GUID getGUID() const
bool notEligibleToImport() const
Return true if this global value can't be imported.
@ Unsat
Unsatisfiable type (i.e. no global has this type metadata)
const_gvsummary_iterator end() const
GlobalVarSummary(GVFlags Flags, GVarFlags VarFlags, std::vector< ValueInfo > Refs)
TypeIdSummary & getOrInsertTypeIdSummary(StringRef TypeId)
Return an existing or new TypeIdSummary entry for TypeId.
Alias summary information.
GlobalValueSummaryList SummaryList
List of global value summary structures for a particular value held in the GlobalValueMap.
@ AllOnes
All-ones bit vector ("Eliminating Bit Vector Checks for All-Ones Bit Vectors")
The ValueInfo and offset for a function within a vtable definition initializer array.
const GlobalValue * getValue() const
ArrayRef< ConstVCall > type_test_assume_const_vcalls() const
Returns the list of virtual calls made by this function using llvm.assume(llvm.type....
FFlags & operator&=(const FFlags &RHS)
void setVisibility(GlobalValue::VisibilityTypes Vis)
The following data structures summarize type metadata information.
unsigned Linkage
The linkage type of the associated global value.
bool operator!=(uint64_t V1, const APInt &V2)
VirtFuncOffset(ValueInfo VI, uint64_t Offset)
GlobalObject::VCallVisibility getVCallVisibility() const
@ DefaultVisibility
The GV is visible.
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 isGlobalValueLive(const GlobalValueSummary *GVS) const
std::vector< ConstVCall > TypeTestAssumeConstVCalls
List of virtual calls made by this function using (respectively) llvm.assume(llvm....
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
unsigned ReturnDoesNotAlias
void setAliasee(ValueInfo &AliaseeVI, GlobalValueSummary *Aliasee)
unsigned NotEligibleToImport
Indicate if the global value cannot be imported (e.g.
static StringRef getOriginalNameBeforePromote(StringRef Name)
Helper to obtain the unpromoted name for a global value (or the original name if not promoted).
LinkageTypes
An enumeration for the kinds of linkage for global values.
iterator find(StringRef Key)
bool hasParamAccess() const
void propagateAttributes(const DenseSet< GlobalValue::GUID > &PreservedSymbols)
Do the access attribute and DSOLocal propagation in combined index.
const GlobalValueSummary & getAliasee() const
uint64_t getModuleId(const StringRef ModPath) const
Get the module ID recorded for the given module path.
GlobalValue::VisibilityTypes getVisibility() const
bool isDSOLocal(bool WithDSOLocalPropagation=false) const
Checks if all summaries are DSO local (have the flag set).
ArrayRef< ValueInfo > refs() const
Return the list of values referenced by this global value definition.
bool withDSOLocalPropagation() const
Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
std::vector< VFuncId > TypeCheckedLoadVCalls
A specification for a virtual function call with all constant integer arguments.
void setWithAttributePropagation()
Function and variable summary information to aid decisions and implementation of importing.
An information struct used to provide DenseMap with the various necessary components for a given valu...
VisibilityTypes
An enumeration for the kinds of visibility of global values.
std::pair< ValueInfo, CalleeInfo > EdgeTy
<CalleeValueInfo, CalleeInfo> call edge pair.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool enableSplitLTOUnit() const
void setCanAutoHide(bool CanAutoHide)
(vector float) vec_cmpeq(*A, *B) C
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
ArrayRef< GlobalValue::GUID > type_tests() const
Returns the list of type identifiers used by this function in llvm.type.test intrinsics other than by...
ArrayRef< VFuncId > type_test_assume_vcalls() const
Returns the list of virtual calls made by this function using llvm.assume(llvm.type....
ForceSummaryHotnessType
Types for -force-summary-edges-cold debugging option.
union llvm::GlobalValueSummaryInfo::NameOrGV U
GVFlags flags() const
Get the flags for this GlobalValue (see struct GVFlags).
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths()
Table of modules, containing hash and id.
This class implements an extremely fast bulk output stream that can only output to a stream.
std::vector< EdgeTy > & mutableCalls()
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
SummaryKind getSummaryKind() const
Which kind of summary subclass this is.
ParamAccess(uint64_t ParamNo, const ConstantRange &Use)
const char * getHotnessName(CalleeInfo::HotnessType HT)
bool maybeReadOnly() const
void addOriginalName(GlobalValue::GUID ValueGUID, GlobalValue::GUID OrigGUID)
Add an original name for the value of the given GUID.
bool hasExportedFunctions(const Module &M) const
Check if the given Module has any functions available for exporting in the index.
uint64_t getFlags() const
void updateRelBlockFreq(uint64_t BlockFreq, uint64_t EntryFreq)
Update RelBlockFreq from BlockFreq and EntryFreq.
GlobalValueSummary * findSummaryInModule(ValueInfo VI, StringRef ModuleId) const
Find the summary for ValueInfo VI in module ModuleId, or nullptr if not found.
bool withGlobalValueDeadStripping() const
@ BranchFunnel
When retpoline mitigation is enabled, use a branch funnel that is defined in the merged module.
@ Inline
Inlined bit vector ("Short Inline Bit Vectors")
GlobalValue::VisibilityTypes getELFVisibility() const
Returns the most constraining visibility among summaries.
unsigned Visibility
Indicates the visibility.
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
void addTypeTest(GlobalValue::GUID Guid)
Add a type test to the summary.
void setHasSyntheticEntryCounts()
Class to accumulate and hold information about a callee.
@ SingleImpl
Single implementation devirtualization.
Struct that holds a reference to a particular GUID in a global value summary.
bool canAutoHide() const
Checks if all copies are eligible for auto-hiding (have flag set).
void setVCallVisibility(GlobalObject::VCallVisibility Vis)
std::string SingleImplName
GlobalValueSummary * findSummaryInModule(GlobalValue::GUID ValueGUID, StringRef ModuleId) const
Find the summary for global GUID in module ModuleId, or nullptr if not found.
bool maybeWriteOnly() const
@ Single
Single element (last example in "Short Inline Bit Vectors")
@ UniformRetVal
Uniform return value optimization.
PointerTy getPointer() const
Implements a dense probed hash-table based set.
bool isGUIDLive(GlobalValue::GUID GUID) const
An "identifier" for a virtual function.
@ Indir
Just do a regular virtual call.
This is an important base class in LLVM.
GlobalValue::LinkageTypes linkage() const
Return linkage type recorded for this global value.
ArrayRef< VirtFuncOffset > vTableFuncs() const
GVFlags(GlobalValue::LinkageTypes Linkage, GlobalValue::VisibilityTypes Visibility, bool NotEligibleToImport, bool Live, bool IsLocal, bool CanAutoHide)
Convenience Constructors.
@ Indir
Just do a regular virtual call.
unsigned getAccessSpecifier() const
void dumpSCCs(raw_ostream &OS)
Print out strongly connected components for debugging.
Allocate memory in an ever growing pool, as if by bump-pointer.
ValueInfo getValueInfo(const GlobalValueSummaryMapTy::value_type &R) const
Return a ValueInfo for the index value_type (convenient when iterating index).
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
GlobalValue::GUID getGUIDFromOriginalID(GlobalValue::GUID OriginalID) const
Return the GUID for OriginalId in the OidGuidMap.
uint64_t getBlockCount() const
AliasSummary(GVFlags Flags)
bool operator<(int64_t V1, const APSInt &V2)
std::vector< VirtFuncOffset > VTableFuncList
List of functions referenced by a particular vtable definition.
static FunctionSummary::ConstVCall getTombstoneKey()
unsigned MustBeUnreachable
ValueTy lookup(StringRef Key) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
static ChildIteratorType child_end(NodeRef N)
void setBlockCount(uint64_t C)
static NodeRef getEntryNode(ModuleSummaryIndex *I)
void print(raw_ostream &OS, bool IsForDebug=false) const
Print to an output stream.
Optional< TypeIdCompatibleVtableInfo > getTypeIdCompatibleVtableSummary(StringRef TypeId) const
For the given TypeId, this returns the TypeIdCompatibleVtableMap entry if present in the summary map.
bool skipModuleByDistributedBackend() const
static FunctionSummary makeDummyFunctionSummary(std::vector< FunctionSummary::EdgeTy > Edges)
Create an empty FunctionSummary (with specified call edges).
@ UniqueRetVal
Unique return value optimization.
GlobalValueSummaryMapTy::iterator gvsummary_iterator
TypeIdOffsetVtableInfo(uint64_t Offset, ValueInfo VI)
const StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths() const
Table of modules, containing module hash and id.
void addBlockCount(uint64_t C)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
static const char * PreservedSymbols[]
ValueInfo getOrInsertValueInfo(GlobalValue::GUID GUID)
Return a ValueInfo for GUID.
bool operator==(uint64_t V1, const APInt &V2)
const TypeIdSummaryMapTy & typeIds() const
void setWithDSOLocalPropagation()
gvsummary_iterator begin()
A Module instance is used to store all the information related to an LLVM module.
std::set< std::string > & cfiFunctionDefs()
ModuleSummaryIndex(bool HaveGVs, bool EnableSplitLTOUnit=false)
Flags specific to function summaries.
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer.
bool partiallySplitLTOUnits() const
static FunctionSummary::VFuncId getEmptyKey()
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.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
SummaryKind
Sububclass discriminator (for dyn_cast<> et al.)
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
void exportToDot(raw_ostream &OS, const DenseSet< GlobalValue::GUID > &GUIDPreservedSymbols) const
Export summary to dot file for GraphViz.
void setFlags(uint64_t Flags)
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ValueInfo getValueInfo(GlobalValue::GUID GUID) const
Return a ValueInfo for GUID if it exists, otherwise return ValueInfo().
void collectDefinedGVSummariesPerModule(Map &ModuleToDefinedGVSummaries) const
Collect for each module the list of Summaries it defines (GUID -> Summary).
void setPointer(PointerTy PtrVal) &
GlobalValueSummary(SummaryKind K, GVFlags Flags, std::vector< ValueInfo > Refs)
Call(uint64_t ParamNo, ValueInfo Callee, const ConstantRange &Offsets)
void updateHotness(const HotnessType OtherHotness)
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
GlobalValueSummary & getAliasee()
std::vector< TypeIdOffsetVtableInfo > TypeIdCompatibleVtableInfo
List of vtable definitions decorated by a particular type identifier, and their corresponding offsets...
std::set< std::string > & cfiFunctionDecls()
StringRef Name
Summary string representation.
PointerIntPair< const GlobalValueSummaryMapTy::value_type *, 3, int > RefAndFlags
uint64_t entryCount() const
Get the synthetic entry count for this function.
enum llvm::TypeTestResolution::Kind TheKind
@ Unknown
Unknown (analysis not performed, don't lower)
void setVTableFuncs(VTableFuncList Funcs)
const GlobalValueSummaryMapTy::value_type * getRef() const
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
bool canImportGlobalVar(GlobalValueSummary *S, bool AnalyzeRefs) const
Checks if we can import global variable from another module.
static unsigned getHashValue(FunctionSummary::VFuncId I)
std::vector< std::unique_ptr< GlobalValueSummary > > GlobalValueSummaryList
ArrayRef< VFuncId > type_checked_load_vcalls() const
Returns the list of virtual calls made by this function using llvm.type.checked.load intrinsics that ...
static unsigned getHashValue(ValueInfo I)
const std::set< std::string > & cfiFunctionDecls() const
static FunctionSummary::ConstVCall getEmptyKey()
static FunctionSummary ExternalNode
A dummy node to reference external functions that aren't in the index.
GVarFlags varflags() const
Function summary information to aid decisions and implementation of importing.
void setWithGlobalValueDeadStripping()
static bool classof(const GlobalValueSummary *GVS)
Check if this is an alias summary.
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
Should compile to something r4 addze r3 instead we get
GlobalValue::GUID getOriginalName() const
Returns the hash of the original name, it is identical to the GUID for externally visible symbols,...
FunctionSummary calculateCallGraphRoot()
const std::set< std::string > & cfiFunctionDefs() const
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
const auto & typeIdCompatibleVtableMap() const
uint32_t RelBlockFreq
The value stored in RelBlockFreq has to be interpreted as the digits of a scaled number with a scale ...
HotnessType getHotness() const
static FunctionSummary::VFuncId getTombstoneKey()
unsigned CanAutoHide
In the per-module summary, indicates that the global value is linkonce_odr and global unnamed addr (s...
uint64_t Info
Additional information for the resolution:
@ VirtualConstProp
Virtual constant propagation.
GlobalValueSummary * getGlobalValueSummary(const GlobalValue &GV, bool PerModuleIndex=true) const
Returns the first GlobalValueSummary for GV, asserting that there is only one if PerModuleIndex.
void setReadOnly(bool RO)
ScaledNumber< uint64_t > Scaled64
std::pair< unsigned, unsigned > specialRefCounts() const
static bool isEqual(const Function &Caller, const Function &Callee)
size_type count(StringRef Key) const
count - Return 1 if the element is in the map, 0 otherwise.
StringRef str() const
Explicit conversion to StringRef.
static constexpr uint64_t BitcodeSummaryVersion
void dump() const
Dump to stderr (for debugging).
This class represents a range of values.
std::map< uint64_t, WholeProgramDevirtResolution > WPDRes
Mapping from byte offset to whole-program devirt resolution for that (typeid, byte offset) pair.
enum llvm::WholeProgramDevirtResolution::Kind TheKind
bool isWriteOnly(const GlobalVarSummary *GVS) const
static bool classof(const GlobalValueSummary *GVS)
Check if this is a global variable summary.
void setSkipModuleByDistributedBackend()
void addGlobalValueSummary(const GlobalValue &GV, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for a value.
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 ...
void setLinkage(GlobalValue::LinkageTypes Linkage)
Sets the linkage to the value determined by global summary-based optimization.
static ChildEdgeIteratorType child_edge_begin(NodeRef N)
static NodeRef valueInfoFromEdge(FunctionSummary::EdgeTy &P)
GlobalValueSummary * getBaseObject()
If this is an alias summary, returns the summary of the aliased object (a global variable or function...
Class to hold module path string table and global value map, and encapsulate methods for operating on...
static std::string getGlobalNameForLocal(StringRef Name, ModuleHash ModHash)
Convenience method for creating a promoted global name for the given value name of a local,...
StringRef modulePath() const
Get the path to the module containing this function.
Describes the uses of a parameter by the function.
CalleeInfo(HotnessType Hotness, uint64_t RelBF)
ValueInfo getOrInsertValueInfo(const GlobalValue *GV)
Return a ValueInfo for GV and mark it as belonging to GV.
StringRef save(const char *S)
Describes the use of a value in a call instruction, specifying the call's target, the value's paramet...
GlobalValueSummaryInfo(bool HaveGVs)
GVarFlags(bool ReadOnly, bool WriteOnly, bool Constant, GlobalObject::VCallVisibility Vis)
uint64_t AddressPointOffset
virtual ~GlobalValueSummary()=default
std::vector< GlobalValue::GUID > TypeTests
List of type identifiers used by this function in llvm.type.test intrinsics referenced by something o...
void setEntryCount(uint64_t EC)
Set the synthetic entry count for this function.
void collectDefinedFunctionsForModule(StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const
Collect for the given module the list of functions it defines (GUID -> Summary).
unsigned Live
In per-module summary, indicate that the global value must be considered a live root for index-based ...
unsigned DSOLocal
Indicates that the linker resolved the symbol to a definition from within the same linkage unit.
static constexpr int32_t ScaleShift
bool isValidAccessSpecifier() const
bool withAttributePropagation() const
void addGlobalValueSummary(ValueInfo VI, std::unique_ptr< GlobalValueSummary > Summary)
Add a global value summary for the given ValueInfo.
static ValueInfo getTombstoneKey()
static void discoverNodes(ValueInfo V, std::map< ValueInfo, bool > &FunctionHasParent)
Convenience function for doing a DFS on a ValueInfo.
std::vector< VFuncId > TypeTestAssumeVCalls
List of virtual calls made by this function using (respectively) llvm.assume(llvm....
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)
@ ByteArray
Test a byte array (first example)
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).
static unsigned getHashValue(FunctionSummary::ConstVCall I)
void setOriginalName(GlobalValue::GUID Name)
Initialize the original name hash in this summary.
std::array< uint32_t, 5 > ModuleHash
160 bits SHA1
std::string & str()
Returns the string's reference.
struct llvm::GlobalVarSummary::GVarFlags VarFlags
FunctionSummary::EdgeTy & EdgeRef
std::vector< ConstVCall > TypeCheckedLoadConstVCalls
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...
const TypeIdInfo * getTypeIdInfo() const
static bool isSpecialKey(ValueInfo V)
GlobalValue::GUID getAliaseeGUID() const
unsigned SizeM1BitWidth
Range of size-1 expressed as a bit width.
A Use represents the edge between a Value definition and its users.
static bool isEqual(FunctionSummary::ConstVCall L, FunctionSummary::ConstVCall R)
GraphTraits definition to build SCC for the index.
ValueInfo getAliaseeVI() const
void setDSOLocal(bool Local)
TypeIdCompatibleVtableInfo & getOrInsertTypeIdCompatibleVtableSummary(StringRef TypeId)
Return an existing or new TypeIdCompatibleVtableMap entry for TypeId.
static constexpr const char * getRegularLTOModuleName()