21 bool FunctionImportGlobalProcessing::doImportAsDefinition(
25 if (!GlobalsToImport->
count(const_cast<GlobalValue *>(SGV)))
28 assert(!isa<GlobalAlias>(SGV) &&
29 "Unexpected global alias in the import list.");
35 bool FunctionImportGlobalProcessing::doImportAsDefinition(
37 if (!isPerformingImport())
39 return FunctionImportGlobalProcessing::doImportAsDefinition(SGV,
43 bool FunctionImportGlobalProcessing::shouldPromoteLocalToGlobal(
48 if (!isPerformingImport() && !isModuleExporting())
51 if (isPerformingImport()) {
52 assert((!GlobalsToImport->count(const_cast<GlobalValue *>(SGV)) ||
53 !isNonRenamableLocal(*SGV)) &&
54 "Attempting to promote non-renamable local");
70 assert(Summary &&
"Missing summary for global value when exporting");
71 auto Linkage = Summary->linkage();
73 assert(!isNonRenamableLocal(*SGV) &&
74 "Attempting to promote non-renamable local");
82 bool FunctionImportGlobalProcessing::isNonRenamableLocal(
89 if (Used.count(const_cast<GlobalValue *>(&GV)))
95 std::string FunctionImportGlobalProcessing::getName(
const GlobalValue *SGV,
110 FunctionImportGlobalProcessing::getLinkage(
const GlobalValue *SGV,
116 if (isModuleExporting()) {
123 if (!isPerformingImport())
142 if (!doImportAsDefinition(SGV))
152 assert(!doImportAsDefinition(SGV));
161 if (doImportAsDefinition(SGV) && !dyn_cast<GlobalAlias>(SGV))
179 if (doImportAsDefinition(SGV) && !dyn_cast<GlobalAlias>(SGV))
190 assert(!doImportAsDefinition(SGV));
203 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)
bool hasLocalLinkage() const
Special purpose, only applies to global arrays.
Compute iterated dominance frontiers using a linear time algorithm.
A Module instance is used to store all the information related to an LLVM module. ...
Same, but only replaced by something equivalent.
GlobalValueSummary * findSummaryInModule(GlobalValue::GUID ValueGUID, StringRef ModuleId) const
Find the summary for global GUID in module ModuleId, or nullptr if not found.
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.
bool hasDLLImportStorageClass() const
static bool isLocalLinkage(LinkageTypes Linkage)
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.
void setDLLStorageClass(DLLStorageClassTypes C)
LinkageTypes getLinkage() const
Class to hold module path string table and global value map, and encapsulate methods for operating on...
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
ExternalWeak linkage description.
Same, but only replaced by something equivalent.
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...
const ModuleHash & getModuleHash(const StringRef ModPath) const
Get the module SHA1 hash recorded for the given module path.
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Struct that holds a reference to a particular GUID in a global value summary.
Keep one copy of function when linking (inline)
void setLinkage(LinkageTypes LT)
LinkageTypes
An enumeration for the kinds of linkage for global values.
ValueInfo getValueInfo(const GlobalValueSummaryMapTy::value_type &R) const
Return a ValueInfo for the index value_type (convenient when iterating index).
StringRef getName() const
Return a constant reference to the value's name.
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).
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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()
void setDSOLocal(bool Local)