38 sizeof(
Constant) + 2 *
sizeof(
void *) + 2 *
sizeof(
unsigned),
39 "unexpected GlobalValue size growth");
43 "unexpected GlobalObject size growth");
46 if (
const Function *
F = dyn_cast<Function>(
this))
47 return F->isMaterializable();
56 void GlobalValue::destroyConstantImpl() {
73 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
76 return GO->getAlignment();
87 assert((Align & (Align-1)) == 0 &&
"Alignment is not a power of 2!");
89 "Alignment is greater than MaximumAlignment!");
90 unsigned AlignmentData =
Log2_32(Align) + 1;
110 if (
const auto *GV = dyn_cast<GlobalObject>(Src)) {
126 std::string NewName =
Name;
132 if (FileName.
empty())
133 NewName = NewName.insert(0,
"<unknown>:");
135 NewName = NewName.insert(0, FileName.
str() +
":");
146 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
149 return GO->getSection();
152 return cast<GlobalObject>(
this)->
getSection();
156 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
159 return const_cast<GlobalObject *>(GO)->getComdat();
163 if (isa<GlobalIFunc>(
this))
165 return cast<GlobalObject>(
this)->
getComdat();
168 StringRef GlobalObject::getSectionImpl()
const {
191 return GV->getNumOperands() == 0;
194 if (
const Function *
F = dyn_cast<Function>(
this))
195 return F->empty() && !
F->isMaterializable();
198 assert(isa<GlobalIndirectSymbol>(
this));
244 if (
auto *GO = dyn_cast<GlobalObject>(
this))
246 if (
auto *GA = dyn_cast<GlobalAlias>(
this))
278 bool isExternallyInitialized)
281 InitVal != nullptr, Link, Name, AddressSpace),
282 isConstantGlobal(constant),
283 isExternallyInitializedConstant(isExternallyInitialized) {
287 "Initializer should be the same type as the GlobalVariable!");
296 bool isExternallyInitialized)
299 InitVal != nullptr, Link, Name, AddressSpace),
300 isConstantGlobal(constant),
301 isExternallyInitializedConstant(isExternallyInitialized) {
305 "Initializer should be the same type as the GlobalVariable!");
329 Op<0>().set(
nullptr);
334 "Initializer type must match GlobalVariable type");
340 Op<0>().set(InitVal);
348 if (
const GlobalVariable *SrcVar = dyn_cast<GlobalVariable>(Src)) {
366 :
GlobalValue(Ty, VTy, &
Op<0>(), 1, Linkage, Name, AddressSpace) {
387 return new GlobalAlias(Ty, AddressSpace, Link, Name, Aliasee, ParentModule);
393 return create(Ty, AddressSpace, Linkage, Name,
nullptr, Parent);
399 return create(Ty, AddressSpace, Linkage, Name, Aliasee, Aliasee->
getParent());
423 "Alias and aliasee types should match!");
431 GlobalIFunc::GlobalIFunc(
Type *Ty,
unsigned AddressSpace, LinkageTypes Link,
443 return new GlobalIFunc(Ty, AddressSpace, Link, Name, Resolver, ParentModule);
void setVisibility(VisibilityTypes V)
LinkageTypes getLinkage() const
VisibilityTypes getVisibility() const
virtual void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
void dropAllReferences()
Drop all references to operands.
iterator erase(iterator where)
A Module instance is used to store all the information related to an LLVM module. ...
const GlobalListType & getGlobalList() const
Get the Module's list of global variables (constant).
UnnamedAddr getUnnamedAddr() const
Type * getValueType() const
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Type * getElementType() const
void setAlignment(unsigned Align)
const AliasListType & getAliasList() const
Get the Module's list of aliases (constant).
bool canIncreaseAlignment() const
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
const IFuncListType & getIFuncList() const
Get the Module's list of ifuncs (constant).
static bool isLocalLinkage(LinkageTypes Linkage)
StringRef getName() const
Return a constant reference to the value's name.
unsigned getGlobalObjectSubClassData() const
void setIndirectSymbol(Constant *Symbol)
These methods set and retrieve indirect symbol.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool hasDefaultVisibility() const
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
void removeFromParent() final
This method unlinks 'this' from the containing module, but does not delete it.
void setThreadLocalMode(ThreadLocalMode Val)
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...
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
static const unsigned MaximumAlignment
void eraseFromParent() override
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
void setDLLStorageClass(DLLStorageClassTypes C)
unsigned getAlignment() const
bool isMaterializable() const
If this function's Module is being lazily streamed in functions from disk or some other source...
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 ...
Class to represent pointers.
bool hasSection() const
Check if this global has a custom object file section.
ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
void setExternallyInitialized(bool Val)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
void removeFromParent() override
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it...
self_iterator getIterator()
void setGlobalVariableNumOperands(unsigned NumOps)
Set the number of operands on a GlobalVariable.
Error materialize()
Make sure this GlobalValue is fully read.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
DenseMap< const GlobalObject *, StringRef > GlobalObjectSections
Collection of per-GlobalObject sections used in this context.
LLVMContext & getContext() const
All values hold a context through their type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::pair< typename base::iterator, bool > insert(StringRef Key)
LLVMContextImpl *const pImpl
Triple - Helper class for working with autoconf configuration names.
Optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns None...
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
std::string getGlobalIdentifier() const
Return the modified name for this global value suitable to be used as the key for a global lookup (e...
void copyAttributesFrom(const GlobalValue *Src) override
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
ValueTy
Concrete subclass of this.
unsigned Log2_32(uint32_t Value)
Log2_32 - This function returns the floor log base 2 of the specified value, -1 if the value is zero...
bool hasInitializer() const
Definitions have initializers, declarations don't.
void eraseFromParent() override
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
void push_back(pointer val)
LinkageTypes
An enumeration for the kinds of linkage for global values.
void setGlobalValueSubClassData(unsigned V)
const GlobalObject * getBaseObject() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
void dropAllReferences()
Drop all references in preparation to destroy the GlobalVariable.
unsigned getGlobalValueSubClassData() const
pointer remove(iterator &IT)
PointerType * getType() const
Global values are always pointers.
iterator insert(iterator where, pointer New)
void setUnnamedAddr(UnnamedAddr Val)
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Compile-time customization of User operands.
llvm::Error materialize(GlobalValue *GV)
Make sure the GlobalValue is fully read.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
void eraseFromParent() final
This method unlinks 'this' from the containing module and deletes it.
bool hasLocalLinkage() const
void copyAttributesFrom(const GlobalValue *Src) override
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getAlignment() const
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Lightweight error class with error context and mandatory checking.
GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Symbol)
DLLStorageClassTypes getDLLStorageClass() const
StringRef - Represent a constant reference to a string, i.e.
void setSection(StringRef S)
Change the section for this global.
void setGlobalObjectSubClassData(unsigned Val)
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 setAliasee(Constant *Aliasee)
These methods retrieve and set alias target.
StringSet SectionStrings
Stable collection of section strings.
bool isAbsoluteSymbolRef() const
Returns whether this is a reference to an absolute symbol.
void removeFromParent() override
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it...
StringRef getSection() const