Go to the documentation of this file.
19 bool FunctionImportGlobalProcessing::doImportAsDefinition(
21 if (!isPerformingImport())
25 if (!GlobalsToImport->count(
const_cast<GlobalValue *
>(SGV)))
28 assert(!isa<GlobalAlias>(SGV) &&
29 "Unexpected global alias in the import list.");
35 bool FunctionImportGlobalProcessing::shouldPromoteLocalToGlobal(
40 if (!isPerformingImport() && !isModuleExporting())
43 if (isPerformingImport()) {
45 !isNonRenamableLocal(*SGV)) &&
46 "Attempting to promote non-renamable local");
62 assert(Summary &&
"Missing summary for global value when exporting");
63 auto Linkage = Summary->linkage();
65 assert(!isNonRenamableLocal(*SGV) &&
66 "Attempting to promote non-renamable local");
74 bool FunctionImportGlobalProcessing::isNonRenamableLocal(
88 FunctionImportGlobalProcessing::getPromotedName(
const GlobalValue *SGV) {
99 FunctionImportGlobalProcessing::getLinkage(
const GlobalValue *SGV,
105 if (isModuleExporting()) {
112 if (!isPerformingImport())
122 if (doImportAsDefinition(SGV) && !isa<GlobalAlias>(SGV))
130 if (!doImportAsDefinition(SGV))
142 assert(!doImportAsDefinition(SGV));
151 if (doImportAsDefinition(SGV) && !isa<GlobalAlias>(SGV))
169 if (doImportAsDefinition(SGV) && !isa<GlobalAlias>(SGV))
180 assert(!doImportAsDefinition(SGV));
193 void FunctionImportGlobalProcessing::processGlobalForThinLTO(
GlobalValue &GV) {
200 if (
Function *
F = dyn_cast<Function>(&GV)) {
201 if (!
F->isDeclaration()) {
202 for (
auto &
S :
VI.getSummaryList()) {
203 auto *
FS = cast<FunctionSummary>(
S->getBaseObject());
218 (isPerformingImport() && !doImportAsDefinition(&GV)));
240 auto *GVS = dyn_cast_or_null<GlobalVarSummary>(
244 V->addAttribute(
"thinlto-internalize");
261 GV.
setName(getPromotedName(&GV));
269 if (
C->getName() ==
Name)
277 if (ClearDSOLocalOnDeclarations &&
279 (isPerformingImport() && !doImportAsDefinition(&GV))) &&
293 auto *GO = dyn_cast<GlobalObject>(&GV);
294 if (GO && GO->isDeclarationForLinker() && GO->hasComdat()) {
298 assert(GO->hasAvailableExternallyLinkage() &&
299 "Expected comdat on definition (possibly available external)");
300 GO->setComdat(
nullptr);
304 void FunctionImportGlobalProcessing::processGlobalsForThinLTO() {
306 processGlobalForThinLTO(GV);
308 processGlobalForThinLTO(SF);
310 processGlobalForThinLTO(GA);
314 if (!RenamedComdats.empty())
315 for (
auto &GO :
M.global_objects())
316 if (
auto *
C = GO.getComdat()) {
317 auto Replacement = RenamedComdats.find(
C);
318 if (Replacement != RenamedComdats.end())
319 GO.setComdat(Replacement->second);
324 processGlobalsForThinLTO();
329 bool ClearDSOLocalOnDeclarations,
332 ClearDSOLocalOnDeclarations);
333 return ThinLTOProcessing.
run();
bool hasSyntheticEntryCounts() const
This is an optimization pass for GlobalISel generic memory operations.
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
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
bool isReadOnly(const GlobalVarSummary *GVS) const
const ModuleHash & getModuleHash(const StringRef ModPath) const
Get the module SHA1 hash recorded for the given module path.
LinkageTypes getLinkage() const
@ HiddenVisibility
The GV is hidden.
bool isImplicitDSOLocal() const
bool renameModuleForThinLTO(Module &M, const ModuleSummaryIndex &Index, bool ClearDSOLocalOnDeclarations, SetVector< GlobalValue * > *GlobalsToImport=nullptr)
Perform in-place global value handling on the given Module for exported local functions renamed and p...
static bool isLocalLinkage(LinkageTypes Linkage)
LinkageTypes
An enumeration for the kinds of linkage for global values.
void setDSOLocal(bool Local)
bool withDSOLocalPropagation() const
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
iterator_range< global_iterator > globals()
(vector float) vec_cmpeq(*A, *B) C
void setName(const Twine &Name)
Change the name of the value.
GlobalValueSummary * findSummaryInModule(ValueInfo VI, StringRef ModuleId) const
Find the summary for ValueInfo VI in module ModuleId, or nullptr if not found.
@ InternalLinkage
Rename collisions when linking (static functions).
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
Struct that holds a reference to a particular GUID in a global value summary.
Module * getParent()
Get the module that this global value is contained inside of...
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
ValueInfo getValueInfo(const GlobalValueSummaryMapTy::value_type &R) const
Return a ValueInfo for the index value_type (convenient when iterating index).
void setLinkage(LinkageTypes LT)
Comdat * getOrInsertComdat(StringRef Name)
Return the Comdat in the module with the specified name.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasLocalLinkage() const
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
A Module instance is used to store all the information related to an LLVM module.
@ AppendingLinkage
Special purpose, only applies to global arrays.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ WeakODRLinkage
Same, but only replaced by something equivalent.
void setDLLStorageClass(DLLStorageClassTypes C)
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
@ AvailableExternallyLinkage
Available for inspection, not emission.
Linkage
Describes symbol linkage.
StringRef getName() const
Return a constant reference to the value's name.
@ CommonLinkage
Tentative definitions.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
const Comdat * getComdat() const
Class to handle necessary GlobalValue changes required by ThinLTO function importing,...
@ ExternalLinkage
Externally visible function.
bool isWriteOnly(const GlobalVarSummary *GVS) const
@ PrivateLinkage
Like Internal, but omit from symbol table.
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,...
bool isDeclarationForLinker() const
bool hasDLLImportStorageClass() const
bool withAttributePropagation() const
Class to represent profile counts.
@ ExternalWeakLinkage
ExternalWeak linkage description.
A vector that has set insertion semantics.
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
void setVisibility(VisibilityTypes V)