35 sizeof(
Constant) + 2 *
sizeof(
void *) + 2 *
sizeof(
unsigned),
36 "unexpected GlobalValue size growth");
40 "unexpected GlobalObject size growth");
43 if (
const Function *
F = dyn_cast<Function>(
this))
44 return F->isMaterializable();
51void GlobalValue::destroyConstantImpl() {
68 if (Src->hasSanitizerMetadata())
76#define HANDLE_GLOBAL_VALUE(NAME) \
77 case Value::NAME##Val: \
78 return static_cast<NAME *>(this)->removeFromParent();
79#include "llvm/IR/Value.def"
88#define HANDLE_GLOBAL_VALUE(NAME) \
89 case Value::NAME##Val: \
90 return static_cast<NAME *>(this)->eraseFromParent();
91#include "llvm/IR/Value.def"
111 auto isDeduplicateComdat = [](
const Comdat *
C) {
116 !isa<GlobalIFunc>(
this) && !isDeduplicateComdat(
getComdat());
121 "Alignment is greater than MaximumAlignment!");
130 "Alignment is greater than MaximumAlignment!");
135 "Alignment representation error!");
154 std::string NewName = std::string(
Name);
160 if (FileName.
empty())
161 NewName = NewName.insert(0,
"<unknown>:");
163 NewName = NewName.insert(0, FileName.
str() +
":");
174 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
177 return GO->getSection();
180 return cast<GlobalObject>(
this)->getSection();
184 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
191 if (isa<GlobalIFunc>(
this))
193 return cast<GlobalObject>(
this)->getComdat();
241 MetadataMap.
erase(
this);
245StringRef GlobalObject::getSectionImpl()
const {
266bool GlobalValue::isNobuiltinFnDef()
const {
267 const Function *
F = dyn_cast<Function>(
this);
268 if (!
F ||
F->empty())
270 return F->hasFnAttribute(Attribute::NoBuiltin);
276 return GV->getNumOperands() == 0;
279 if (
const Function *
F = dyn_cast<Function>(
this))
280 return F->empty() && !
F->isMaterializable();
283 assert(isa<GlobalAlias>(
this) || isa<GlobalIFunc>(
this));
328template <
typename Operation>
332 if (
auto *GO = dyn_cast<GlobalObject>(
C)) {
336 if (
auto *GA = dyn_cast<GlobalAlias>(
C)) {
338 if (Aliases.
insert(GA).second)
341 if (
auto *CE = dyn_cast<ConstantExpr>(
C)) {
342 switch (CE->getOpcode()) {
343 case Instruction::Add: {
350 case Instruction::Sub: {
355 case Instruction::IntToPtr:
356 case Instruction::PtrToInt:
357 case Instruction::BitCast:
358 case Instruction::GetElementPtr:
373 auto *GO = dyn_cast<GlobalObject>(
this);
377 return GO->getMetadata(LLVMContext::MD_absolute_symbol);
381 auto *GO = dyn_cast<GlobalObject>(
this);
385 MDNode *MD = GO->getMetadata(LLVMContext::MD_absolute_symbol);
403 if (
auto *Var = dyn_cast<GlobalVariable>(
this))
404 if (!Var->isConstant())
417 bool isExternallyInitialized)
421 isConstantGlobal(constant),
422 isExternallyInitializedConstant(isExternallyInitialized) {
424 "invalid type for global variable");
428 "Initializer should be the same type as the GlobalVariable!");
438 bool isExternallyInitialized)
442 : M.getDataLayout().getDefaultGlobalsAddressSpace(),
443 isExternallyInitialized) {
447 M.insertGlobalVariable(
this);
464 Op<0>().set(
nullptr);
469 "Initializer type must match GlobalVariable type");
475 Op<0>().set(InitVal);
540 "Alias and aliasee types should match!");
541 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.
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
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...
bool isInterposable() const
Return true if this global's definition can be substituted with an arbitrary definition at link time ...
void setVisibility(VisibilityTypes V)
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.
void setAttributes(AttributeSet A)
Set attribute list for this global.
void copyAttributesFrom(const GlobalVariable *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
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.
void insertGlobalVariable(GlobalVariable *GV)
Insert global variable GV at the end of the global variable list and take ownership.
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.
std::string str() const
str - Get the contents as an std::string.
constexpr bool empty() const
empty - Check if the string is empty.
Triple - Helper class for working with autoconf configuration names.
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.
void setGlobalVariableNumOperands(unsigned NumOps)
Set the number of operands on a GlobalVariable.
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.
self_iterator getIterator()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
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.
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.
Compile-time customization of User operands.