23 bool FunctionImportGlobalProcessing::doImportAsDefinition(
27 if (
auto *GA = dyn_cast<GlobalAlias>(SGV)) {
28 if (GA->isInterposable())
33 return FunctionImportGlobalProcessing::doImportAsDefinition(
37 if (GlobalsToImport->
count(const_cast<GlobalValue *>(SGV)))
43 bool FunctionImportGlobalProcessing::doImportAsDefinition(
45 if (!isPerformingImport())
47 return FunctionImportGlobalProcessing::doImportAsDefinition(SGV,
51 bool FunctionImportGlobalProcessing::shouldPromoteLocalToGlobal(
56 if (!isPerformingImport() && !isModuleExporting())
59 if (isPerformingImport()) {
60 assert((!GlobalsToImport->count(const_cast<GlobalValue *>(SGV)) ||
61 !isNonRenamableLocal(*SGV)) &&
62 "Attempting to promote non-renamable local");
78 assert(Summary &&
"Missing summary for global value when exporting");
79 auto Linkage = Summary->linkage();
81 assert(!isNonRenamableLocal(*SGV) &&
82 "Attempting to promote non-renamable local");
90 bool FunctionImportGlobalProcessing::isNonRenamableLocal(
97 if (Used.count(const_cast<GlobalValue *>(&GV)))
103 std::string FunctionImportGlobalProcessing::getName(
const GlobalValue *SGV,
118 FunctionImportGlobalProcessing::getLinkage(
const GlobalValue *SGV,
124 if (isModuleExporting()) {
131 if (!isPerformingImport())
148 if (!doImportAsDefinition(SGV))
164 assert(!doImportAsDefinition(SGV));
173 if (doImportAsDefinition(SGV) && !dyn_cast<GlobalAlias>(SGV))
191 if (doImportAsDefinition(SGV) && !dyn_cast<GlobalAlias>(SGV))
202 assert(!doImportAsDefinition(SGV));
215 void FunctionImportGlobalProcessing::processGlobalForThinLTO(
GlobalValue &GV) {
216 bool DoPromote =
false;
218 ((DoPromote = shouldPromoteLocalToGlobal(&GV)) || isPerformingImport())) {
223 GV.
setName(getName(&GV, DoPromote));
233 auto *GO = dyn_cast_or_null<GlobalObject>(&GV);
234 if (GO && GO->isDeclarationForLinker() && GO->hasComdat()) {
238 assert(GO->hasAvailableExternallyLinkage() &&
239 "Expected comdat on definition (possibly available external)");
240 GO->setComdat(
nullptr);
244 void FunctionImportGlobalProcessing::processGlobalsForThinLTO() {
246 processGlobalForThinLTO(GV);
248 processGlobalForThinLTO(SF);
250 processGlobalForThinLTO(GA);
254 processGlobalsForThinLTO();
261 return ThinLTOProcessing.
run();
void setVisibility(VisibilityTypes V)
LinkageTypes getLinkage() const
Special purpose, only applies to global arrays.
const ModuleHash & getModuleHash(const StringRef ModPath) const
Get the module SHA1 hash recorded for the given module path.
A Module instance is used to store all the information related to an LLVM module. ...
Same, but only replaced by something equivalent.
This is the interface to build a ModuleSummaryIndex for a module.
Available for inspection, not emission.
Like Internal, but omit from symbol table.
Externally visible function.
Class to handle necessary GlobalValue changes required by ThinLTO function importing, including linkage changes and any necessary renaming.
static bool isLocalLinkage(LinkageTypes Linkage)
StringRef getName() const
Return a constant reference to the value's name.
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 GlobalObject * getBaseObject() const
void setName(const Twine &Name)
Change the name of the value.
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
ExternalWeak linkage description.
Same, but only replaced by something equivalent.
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
Keep one copy of function when linking (inline)
GlobalValueSummary * findSummaryInModule(GlobalValue::GUID ValueGUID, StringRef ModuleId) const
Find the summary for global GUID in module ModuleId, or nullptr if not found.
void setLinkage(LinkageTypes LT)
LinkageTypes
An enumeration for the kinds of linkage for global values.
llvm_unreachable("Unknown RegBank!")
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
bool hasLinkOnceODRLinkage() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Keep one copy of named function when linking (weak)
Rename collisions when linking (static functions).
bool hasLocalLinkage() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool renameModuleForThinLTO(Module &M, const ModuleSummaryIndex &Index, SetVector< GlobalValue * > *GlobalsToImport=nullptr)
Perform in-place global value handling on the given Module for exported local functions renamed and p...
Module * getParent()
Get the module that this global value is contained inside of...
A vector that has set insertion semantics.
iterator_range< global_iterator > globals()