36 sizeof(
Constant) + 2 *
sizeof(
void *) + 2 *
sizeof(
unsigned),
37 "unexpected GlobalValue size growth");
41 "unexpected GlobalObject size growth");
44 if (
const Function *
F = dyn_cast<Function>(
this))
45 return F->isMaterializable();
52void GlobalValue::destroyConstantImpl() {
69 if (Src->hasSanitizerMetadata())
81#define HANDLE_GLOBAL_VALUE(NAME) \
82 case Value::NAME##Val: \
83 return static_cast<NAME *>(this)->removeFromParent();
84#include "llvm/IR/Value.def"
93#define HANDLE_GLOBAL_VALUE(NAME) \
94 case Value::NAME##Val: \
95 return static_cast<NAME *>(this)->eraseFromParent();
96#include "llvm/IR/Value.def"
122 auto isDeduplicateComdat = [](
const Comdat *
C) {
127 !isa<GlobalIFunc>(
this) && !isDeduplicateComdat(
getComdat());
136 "Alignment is greater than MaximumAlignment!");
145 "Alignment is greater than MaximumAlignment!");
150 "Alignment representation error!");
165 Name.consume_front(
"\1");
167 std::string GlobalName;
173 if (FileName.
empty())
174 GlobalName +=
"<unknown>";
176 GlobalName += FileName;
190 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
193 return GO->getSection();
196 return cast<GlobalObject>(
this)->getSection();
200 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
207 if (isa<GlobalIFunc>(
this))
209 return cast<GlobalObject>(
this)->getComdat();
257 MetadataMap.
erase(
this);
263 Meta.NoAddress =
true;
264 Meta.NoHWAddress =
true;
268StringRef GlobalObject::getSectionImpl()
const {
289bool GlobalValue::isNobuiltinFnDef()
const {
290 const Function *
F = dyn_cast<Function>(
this);
291 if (!
F ||
F->empty())
293 return F->hasFnAttribute(Attribute::NoBuiltin);
299 return GV->getNumOperands() == 0;
302 if (
const Function *
F = dyn_cast<Function>(
this))
303 return F->empty() && !
F->isMaterializable();
306 assert(isa<GlobalAlias>(
this) || isa<GlobalIFunc>(
this));
355 if (GV->hasAttribute(
"toc-data"))
361template <
typename Operation>
365 if (
auto *GO = dyn_cast<GlobalObject>(
C)) {
369 if (
auto *GA = dyn_cast<GlobalAlias>(
C)) {
371 if (Aliases.
insert(GA).second)
374 if (
auto *CE = dyn_cast<ConstantExpr>(
C)) {
375 switch (CE->getOpcode()) {
376 case Instruction::Add: {
383 case Instruction::Sub: {
388 case Instruction::IntToPtr:
389 case Instruction::PtrToInt:
390 case Instruction::BitCast:
391 case Instruction::GetElementPtr:
406 auto *GO = dyn_cast<GlobalObject>(
this);
410 return GO->getMetadata(LLVMContext::MD_absolute_symbol);
414 auto *GO = dyn_cast<GlobalObject>(
this);
418 MDNode *MD = GO->getMetadata(LLVMContext::MD_absolute_symbol);
436 if (
auto *Var = dyn_cast<GlobalVariable>(
this))
437 if (!Var->isConstant())
450 bool isExternallyInitialized)
453 isConstantGlobal(constant),
454 isExternallyInitializedConstant(isExternallyInitialized) {
456 "invalid type for global variable");
460 "Initializer should be the same type as the GlobalVariable!");
463 setGlobalVariableNumOperands(0);
472 bool isExternallyInitialized)
476 : M.getDataLayout().getDefaultGlobalsAddressSpace(),
477 isExternallyInitialized) {
479 Before->getParent()->insertGlobalVariable(
Before->getIterator(),
this);
481 M.insertGlobalVariable(
this);
498 Op<0>().set(
nullptr);
499 setGlobalVariableNumOperands(0);
503 "Initializer type must match GlobalVariable type");
508 setGlobalVariableNumOperands(1);
509 Op<0>().set(InitVal);
514 assert(InitVal &&
"Can't compute type of null initializer");
525 if (
auto CM = Src->getCodeModel())
535 unsigned CodeModelData =
static_cast<unsigned>(CM) + 1;
537 unsigned NewData = (OldData & ~(CodeModelMask << CodeModelShift)) |
538 (CodeModelData << CodeModelShift);
591 "Alias and aliasee types should match!");
592 Op<0>().set(Aliasee);
BlockVerifier::State From
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static const GlobalObject * findBaseObject(const Constant *C, DenseSet< const GlobalAlias * > &Aliases, const Operation &Op)
Module.h This file contains the declarations for the Module class.
PowerPC Reduce CR logical Operation
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
@ NoDeduplicate
No deduplication is performed.
This is an important base class in LLVM.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
bool erase(const KeyT &Val)
Implements a dense probed hash-table based set.
Lightweight error class with error context and mandatory checking.
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
const GlobalObject * getAliaseeObject() const
void setAliasee(Constant *Aliasee)
These methods retrieve and set alias target.
static GlobalAlias * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Aliasee, Module *Parent)
If a parent module is specified, the alias is automatically inserted into the end of the specified mo...
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
void applyAlongResolverPath(function_ref< void(const GlobalValue &)> Op) const
const Function * getResolverFunction() const
void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
static GlobalIFunc * create(Type *Ty, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Resolver, Module *Parent)
If a parent module is specified, the ifunc is automatically inserted into the end of the specified mo...
void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
const Constant * getResolver() const
MaybeAlign getAlign() const
Returns the alignment of the given variable or function.
void setAlignment(Align Align)
Sets the alignment attribute of the GlobalObject.
void setComdat(Comdat *C)
void copyAttributesFrom(const GlobalObject *Src)
void setSection(StringRef S)
Change the section for this global.
void clearMetadata()
Erase all metadata attached to this Value.
bool hasSection() const
Check if this global has a custom object file section.
bool canIncreaseAlignment() const
Returns true if the alignment of the value can be unilaterally increased.
unsigned HasSanitizerMetadata
True if this symbol has sanitizer metadata available.
bool hasPartition() const
const SanitizerMetadata & getSanitizerMetadata() const
unsigned HasPartition
True if this symbol has a partition name assigned (see https://lld.llvm.org/Partitions....
void removeSanitizerMetadata()
static bool isLocalLinkage(LinkageTypes Linkage)
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
LinkageTypes getLinkage() const
void setUnnamedAddr(UnnamedAddr Val)
bool hasDefaultVisibility() const
bool isAbsoluteSymbolRef() const
Returns whether this is a reference to an absolute symbol.
void setDLLStorageClass(DLLStorageClassTypes C)
const Comdat * getComdat() const
void setThreadLocalMode(ThreadLocalMode Val)
bool hasSanitizerMetadata() const
unsigned getAddressSpace() const
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
StringRef getSection() const
StringRef getPartition() const
Module * getParent()
Get the module that this global value is contained inside of...
const GlobalObject * getAliaseeObject() const
void setDSOLocal(bool Local)
std::optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns std::null...
void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
static bool isExternalLinkage(LinkageTypes Linkage)
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
PointerType * getType() const
Global values are always pointers.
void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
void setNoSanitizeMetadata()
bool isInterposable() const
Return true if this global's definition can be substituted with an arbitrary definition at link time ...
void setVisibility(VisibilityTypes V)
const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
bool canBenefitFromLocalAlias() const
static bool isInterposableLinkage(LinkageTypes Linkage)
Whether the definition of this global may be replaced by something non-equivalent at link time.
bool hasAtLeastLocalUnnamedAddr() const
Returns true if this value's address is not significant in this module.
unsigned getGlobalValueSubClassData() const
void setGlobalValueSubClassData(unsigned V)
bool isMaterializable() const
If this function's Module is being lazily streamed in functions from disk or some other source,...
bool hasGlobalUnnamedAddr() const
Error materialize()
Make sure this GlobalValue is fully read.
void setSanitizerMetadata(SanitizerMetadata Meta)
bool hasLinkOnceODRLinkage() const
bool canBeOmittedFromSymbolTable() const
True if GV can be left out of the object symbol table.
void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
std::string getGlobalIdentifier() const
Return the modified name for this global value suitable to be used as the key for a global lookup (e....
LinkageTypes
An enumeration for the kinds of linkage for global values.
Type * getValueType() const
void setPartition(StringRef Part)
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
bool hasInitializer() const
Definitions have initializers, declarations don't.
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
std::optional< CodeModel::Model > getCodeModel() const
Get the custom code model of this global if it has one.
void setAttributes(AttributeSet A)
Set attribute list for this global.
void replaceInitializer(Constant *InitVal)
replaceInitializer - Sets the initializer for this global variable, and sets the value type of the gl...
void copyAttributesFrom(const GlobalVariable *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
void setCodeModel(CodeModel::Model CM)
Change the code model for this global.
void setExternallyInitialized(bool Val)
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
void dropAllReferences()
Drop all references in preparation to destroy the GlobalVariable.
GlobalVariable(Type *Ty, bool isConstant, LinkageTypes Linkage, Constant *Initializer=nullptr, const Twine &Name="", ThreadLocalMode=NotThreadLocal, unsigned AddressSpace=0, bool isExternallyInitialized=false)
GlobalVariable ctor - If a parent module is specified, the global is automatically inserted into the ...
DenseMap< const GlobalValue *, StringRef > GlobalValuePartitions
Collection of per-GlobalValue partitions used in this context.
DenseMap< const GlobalValue *, GlobalValue::SanitizerMetadata > GlobalValueSanitizerMetadata
DenseMap< const GlobalObject *, StringRef > GlobalObjectSections
Collection of per-GlobalObject sections used in this context.
LLVMContextImpl *const pImpl
A Module instance is used to store all the information related to an LLVM module.
void removeIFunc(GlobalIFunc *IFunc)
Detach IFunc from the list but don't delete it.
void insertIFunc(GlobalIFunc *IFunc)
Insert IFunc at the end of the alias list and take ownership.
llvm::Error materialize(GlobalValue *GV)
Make sure the GlobalValue is fully read.
bool getSemanticInterposition() const
Returns whether semantic interposition is to be respected.
void removeAlias(GlobalAlias *Alias)
Detach Alias from the list but don't delete it.
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
void eraseIFunc(GlobalIFunc *IFunc)
Remove IFunc from the list and delete it.
void eraseAlias(GlobalAlias *Alias)
Remove Alias from the list and delete it.
void eraseGlobalVariable(GlobalVariable *GV)
Remove global variable GV from the list and delete it.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
void insertAlias(GlobalAlias *Alias)
Insert Alias at the end of the alias list and take ownership.
void removeGlobalVariable(GlobalVariable *GV)
Detach global variable GV from the list but don't delete it.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
Triple - Helper class for working with autoconf configuration names.
bool isOSBinFormatXCOFF() const
Tests whether the OS uses the XCOFF binary format.
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
bool isFunctionTy() const
True if this is an instance of FunctionType.
StringRef save(const char *S)
void dropAllReferences()
Drop all references to operands.
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
static constexpr uint64_t MaximumAlignment
const Value * stripPointerCastsAndAliases() const
Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
unsigned getValueID() const
Return an ID for the concrete type of this object.
LLVMContext & getContext() const
All values hold a context through their type.
StringRef getName() const
Return a constant reference to the value's name.
std::pair< iterator, bool > insert(const ValueT &V)
An efficient, type-erasing, non-owning reference to a callable.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
uint64_t MD5Hash(const FunctionId &Obj)
This is an optimization pass for GlobalISel generic memory operations.
unsigned encode(MaybeAlign A)
Returns a representation of the alignment that encodes undefined as 0.
ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
DWARFExpression::Operation Op
constexpr char GlobalIdentifierDelimiter
This struct is a compact representation of a valid (non-zero power of two) alignment.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.