23 bool FunctionImportGlobalProcessing::doImportAsDefinition(
27 if (
auto *GA = dyn_cast<GlobalAlias>(SGV)) {
28 if (GA->hasWeakAnyLinkage())
33 return FunctionImportGlobalProcessing::doImportAsDefinition(
37 if (GlobalsToImport->
count(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(SGV) || !isNonRenamableLocal(*SGV)) &&
61 "Attempting to promote non-renamable local");
77 assert(Summary &&
"Missing summary for global value when exporting");
78 auto Linkage = Summary->linkage();
80 assert(!isNonRenamableLocal(*SGV) &&
81 "Attempting to promote non-renamable local");
89 bool FunctionImportGlobalProcessing::isNonRenamableLocal(
96 if (Used.count(const_cast<GlobalValue *>(&GV)))
102 std::string FunctionImportGlobalProcessing::getName(
const GlobalValue *SGV,
117 FunctionImportGlobalProcessing::getLinkage(
const GlobalValue *SGV,
123 if (isModuleExporting()) {
130 if (!isPerformingImport())
147 if (!doImportAsDefinition(SGV))
163 assert(!doImportAsDefinition(SGV));
172 if (doImportAsDefinition(SGV) && !dyn_cast<GlobalAlias>(SGV))
190 if (doImportAsDefinition(SGV) && !dyn_cast<GlobalAlias>(SGV))
201 assert(!doImportAsDefinition(SGV));
214 void FunctionImportGlobalProcessing::processGlobalForThinLTO(
GlobalValue &GV) {
215 bool DoPromote =
false;
217 ((DoPromote = shouldPromoteLocalToGlobal(&GV)) || isPerformingImport())) {
222 GV.
setName(getName(&GV, DoPromote));
232 auto *GO = dyn_cast_or_null<GlobalObject>(&GV);
233 if (GO && GO->isDeclarationForLinker() && GO->hasComdat()) {
237 assert(GO->hasAvailableExternallyLinkage() &&
238 "Expected comdat on definition (possibly available external)");
239 GO->setComdat(
nullptr);
243 void FunctionImportGlobalProcessing::processGlobalsForThinLTO() {
245 processGlobalForThinLTO(GV);
247 processGlobalForThinLTO(SF);
249 processGlobalForThinLTO(GA);
253 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.
Implements a dense probed hash-table based set.
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...
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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Keep one copy of function when linking (inline)
bool renameModuleForThinLTO(Module &M, const ModuleSummaryIndex &Index, DenseSet< const GlobalValue * > *GlobalsToImport=nullptr)
Perform in-place global value handling on the given Module for exported local functions renamed and p...
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.
const GlobalObject * getBaseObject() const
size_type count(const ValueT &V) const
Return 1 if the specified key is in the set, 0 otherwise.
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())
Module * getParent()
Get the module that this global value is contained inside of...
iterator_range< global_iterator > globals()