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"
116 auto isDeduplicateComdat = [](
const Comdat *
C) {
121 !isa<GlobalIFunc>(
this) && !isDeduplicateComdat(
getComdat());
130 "Alignment is greater than MaximumAlignment!");
139 "Alignment is greater than MaximumAlignment!");
144 "Alignment representation error!");
159 Name.consume_front(
"\1");
161 std::string GlobalName;
167 if (FileName.
empty())
168 GlobalName +=
"<unknown>";
170 GlobalName += FileName;
184 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
187 return GO->getSection();
190 return cast<GlobalObject>(
this)->getSection();
194 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
201 if (isa<GlobalIFunc>(
this))
203 return cast<GlobalObject>(
this)->getComdat();
251 MetadataMap.
erase(
this);
257 Meta.NoAddress =
true;
258 Meta.NoHWAddress =
true;
262StringRef GlobalObject::getSectionImpl()
const {
283bool GlobalValue::isNobuiltinFnDef()
const {
284 const Function *
F = dyn_cast<Function>(
this);
285 if (!
F ||
F->empty())
287 return F->hasFnAttribute(Attribute::NoBuiltin);
293 return GV->getNumOperands() == 0;
296 if (
const Function *
F = dyn_cast<Function>(
this))
297 return F->empty() && !
F->isMaterializable();
300 assert(isa<GlobalAlias>(
this) || isa<GlobalIFunc>(
this));
349 if (GV->hasAttribute(
"toc-data"))
355template <
typename Operation>
359 if (
auto *GO = dyn_cast<GlobalObject>(
C)) {
363 if (
auto *GA = dyn_cast<GlobalAlias>(
C)) {
365 if (Aliases.
insert(GA).second)
368 if (
auto *CE = dyn_cast<ConstantExpr>(
C)) {
369 switch (CE->getOpcode()) {
370 case Instruction::Add: {
377 case Instruction::Sub: {
382 case Instruction::IntToPtr:
383 case Instruction::PtrToInt:
384 case Instruction::BitCast:
385 case Instruction::GetElementPtr:
400 auto *GO = dyn_cast<GlobalObject>(
this);
404 return GO->getMetadata(LLVMContext::MD_absolute_symbol);
408 auto *GO = dyn_cast<GlobalObject>(
this);
412 MDNode *MD = GO->getMetadata(LLVMContext::MD_absolute_symbol);
430 if (
auto *Var = dyn_cast<GlobalVariable>(
this))
431 if (!Var->isConstant())
444 bool isExternallyInitialized)
448 isConstantGlobal(constant),
449 isExternallyInitializedConstant(isExternallyInitialized) {
451 "invalid type for global variable");
455 "Initializer should be the same type as the GlobalVariable!");
465 bool isExternallyInitialized)
469 : M.getDataLayout().getDefaultGlobalsAddressSpace(),
470 isExternallyInitialized) {
472 Before->getParent()->insertGlobalVariable(
Before->getIterator(),
this);
474 M.insertGlobalVariable(
this);
491 Op<0>().set(
nullptr);
496 "Initializer type must match GlobalVariable type");
502 Op<0>().set(InitVal);
507 assert(InitVal &&
"Can't compute type of null initializer");
518 if (
auto CM = Src->getCodeModel())
528 unsigned CodeModelData =
static_cast<unsigned>(CM) + 1;
530 unsigned NewData = (OldData & ~(CodeModelMask << CodeModelShift)) |
531 (CodeModelData << CodeModelShift);
584 "Alias and aliasee types should match!");
585 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.
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.
#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.
Compile-time customization of User operands.