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() {
75 #define HANDLE_GLOBAL_VALUE(NAME) \ 76 case Value::NAME##Val: \ 77 return static_cast<NAME *>(this)->removeFromParent(); 78 #include "llvm/IR/Value.def" 87 #define HANDLE_GLOBAL_VALUE(NAME) \ 88 case Value::NAME##Val: \ 89 return static_cast<NAME *>(this)->eraseFromParent(); 90 #include "llvm/IR/Value.def" 98 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
101 return GO->getAlignment();
117 assert((Align & (Align-1)) == 0 &&
"Alignment is not a power of 2!");
119 "Alignment is greater than MaximumAlignment!");
120 unsigned AlignmentData =
Log2_32(Align) + 1;
142 std::string NewName =
Name;
148 if (FileName.
empty())
149 NewName = NewName.insert(0,
"<unknown>:");
151 NewName = NewName.insert(0, FileName.
str() +
":");
162 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
165 return GO->getSection();
168 return cast<GlobalObject>(
this)->
getSection();
172 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
175 return const_cast<GlobalObject *>(GO)->getComdat();
179 if (isa<GlobalIFunc>(
this))
181 return cast<GlobalObject>(
this)->
getComdat();
184 StringRef GlobalObject::getSectionImpl()
const {
203 setGlobalObjectFlag(HasSectionHashEntryBit, !S.
empty());
209 return GV->getNumOperands() == 0;
212 if (
const Function *
F = dyn_cast<Function>(
this))
213 return F->empty() && !
F->isMaterializable();
216 assert(isa<GlobalIndirectSymbol>(
this));
262 if (
auto *GO = dyn_cast<GlobalObject>(
this))
264 if (
auto *GA = dyn_cast<GlobalIndirectSymbol>(
this))
300 if (
auto *Var = dyn_cast<GlobalVariable>(
this))
301 if (!Var->isConstant())
314 bool isExternallyInitialized)
317 InitVal != nullptr, Link, Name, AddressSpace),
318 isConstantGlobal(constant),
319 isExternallyInitializedConstant(isExternallyInitialized) {
321 "invalid type for global variable");
325 "Initializer should be the same type as the GlobalVariable!");
337 InitVal != nullptr, Link, Name, AddressSpace),
338 isConstantGlobal(constant),
339 isExternallyInitializedConstant(isExternallyInitialized) {
341 "invalid type for global variable");
345 "Initializer should be the same type as the GlobalVariable!");
369 Op<0>().
set(
nullptr);
374 "Initializer type must match GlobalVariable type");
380 Op<0>().
set(InitVal);
405 :
GlobalValue(Ty, VTy, &
Op<0>(), 1, Linkage, Name, AddressSpace) {
426 return new GlobalAlias(Ty, AddressSpace, Link, Name, Aliasee, ParentModule);
432 return create(Ty, AddressSpace, Linkage, Name,
nullptr, Parent);
438 return create(Ty, AddressSpace, Linkage, Name, Aliasee, Aliasee->
getParent());
462 "Alias and aliasee types should match!");
470 GlobalIFunc::GlobalIFunc(
Type *Ty,
unsigned AddressSpace,
LinkageTypes Link,
482 return new GlobalIFunc(Ty, AddressSpace, Link, Name, Resolver, ParentModule);
void setVisibility(VisibilityTypes V)
AttributeSet getAttributes() const
Return the attribute set for this global.
StringRef getSection() const
Get the custom section of this global if it has one.
unsigned getAlignment() const
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
ThreadLocalMode getThreadLocalMode() const
void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
unsigned getValueID() const
Return an ID for the concrete type of this object.
void dropAllReferences()
Drop all references to operands.
iterator erase(iterator where)
This class represents lattice values for constants.
A Module instance is used to store all the information related to an LLVM module. ...
bool isMaterializable() const
If this function's Module is being lazily streamed in functions from disk or some other source...
LLVMContext & getContext() const
All values hold a context through their type.
Optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns None...
const GlobalListType & getGlobalList() const
Get the Module's list of global variables (constant).
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 setAlignment(unsigned Align)
bool canBeOmittedFromSymbolTable() const
True if GV can be left out of the object symbol table.
static bool isLocalLinkage(LinkageTypes Linkage)
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
const AliasListType & getAliasList() const
Get the Module's list of aliases (constant).
void setIndirectSymbol(Constant *Symbol)
These methods set and retrieve indirect symbol.
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
UnnamedAddr getUnnamedAddr() const
bool hasAtLeastLocalUnnamedAddr() const
Returns true if this value's address is not significant in this module.
void setThreadLocalMode(ThreadLocalMode Val)
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
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...
static const unsigned MaximumAlignment
void setDLLStorageClass(DLLStorageClassTypes C)
Type * getType() const
All values are typed, get the type of this value.
void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
LinkageTypes getLinkage() const
unsigned getAlignment() const
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).
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 hasLinkOnceODRLinkage() const
bool canIncreaseAlignment() const
DLLStorageClassTypes getDLLStorageClass() const
VisibilityTypes getVisibility() const
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...
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
void setExternallyInitialized(bool Val)
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
unsigned getAddressSpace() const
unsigned getAddressSpace() const
Return the address space of the Pointer type.
self_iterator getIterator()
void setGlobalVariableNumOperands(unsigned NumOps)
Set the number of operands on a GlobalVariable.
unsigned getGlobalValueSubClassData() const
Error materialize()
Make sure this GlobalValue is fully read.
DenseMap< const GlobalObject *, StringRef > GlobalObjectSections
Collection of per-GlobalObject sections used in this context.
StringRef getSection() const
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it...
#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
const IFuncListType & getIFuncList() const
Get the Module's list of ifuncs (constant).
Triple - Helper class for working with autoconf configuration names.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
BlockVerifier::State From
Module.h This file contains the declarations for the Module class.
bool hasGlobalUnnamedAddr() const
ValueTy
Concrete subclass of this.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
const Comdat * getComdat() const
void push_back(pointer val)
LinkageTypes
An enumeration for the kinds of linkage for global values.
void setGlobalValueSubClassData(unsigned V)
void setAttributes(AttributeSet A)
Set attribute list for this global.
void dropAllReferences()
Drop all references in preparation to destroy the GlobalVariable.
pointer remove(iterator &IT)
void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
iterator insert(iterator where, pointer New)
bool isFunctionTy() const
True if this is an instance of FunctionType.
bool isAbsoluteSymbolRef() const
Returns whether this is a reference to an absolute symbol.
void setUnnamedAddr(UnnamedAddr Val)
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it...
StringRef getName() const
Return a constant reference to the value's name.
void copyAttributesFrom(const GlobalVariable *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
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)
Type * getValueType() const
void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
const GlobalObject * getBaseObject() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
bool hasInitializer() const
Definitions have initializers, declarations don't.
Lightweight error class with error context and mandatory checking.
GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Symbol)
StringRef - Represent a constant reference to a string, i.e.
void copyAttributesFrom(const GlobalObject *Src)
void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
bool isExternallyInitialized() const
void setSection(StringRef S)
Change the section for this global.
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.
Type * getElementType() const
void setDSOLocal(bool Local)
PointerType * getType() const
Global values are always pointers.
StringSet SectionStrings
Stable collection of section strings.