Go to the documentation of this file.
37 sizeof(
Constant) + 2 *
sizeof(
void *) + 2 *
sizeof(
unsigned),
38 "unexpected GlobalValue size growth");
42 "unexpected GlobalObject size growth");
45 if (
const Function *
F = dyn_cast<Function>(
this))
46 return F->isMaterializable();
55 void GlobalValue::destroyConstantImpl() {
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"
119 "Alignment is greater than MaximumAlignment!");
124 "Alignment representation error!");
143 std::string NewName = std::string(
Name);
149 if (FileName.
empty())
150 NewName = NewName.insert(0,
"<unknown>:");
152 NewName = NewName.insert(0, FileName.
str() +
":");
163 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
166 return GO->getSection();
169 return cast<GlobalObject>(
this)->getSection();
173 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
180 if (isa<GlobalIFunc>(
this))
182 return cast<GlobalObject>(
this)->getComdat();
207 StringRef GlobalObject::getSectionImpl()
const {
231 return GV->getNumOperands() == 0;
234 if (
const Function *
F = dyn_cast<Function>(
this))
235 return F->empty() && !
F->isMaterializable();
238 assert(isa<GlobalIndirectSymbol>(
this));
284 if (
auto *GO = dyn_cast<GlobalObject>(
this))
286 if (
auto *GA = dyn_cast<GlobalIndirectSymbol>(
this))
292 auto *GO = dyn_cast<GlobalObject>(
this);
296 return GO->getMetadata(LLVMContext::MD_absolute_symbol);
300 auto *GO = dyn_cast<GlobalObject>(
this);
304 MDNode *MD = GO->getMetadata(LLVMContext::MD_absolute_symbol);
322 if (
auto *Var = dyn_cast<GlobalVariable>(
this))
323 if (!Var->isConstant())
336 bool isExternallyInitialized)
341 isExternallyInitializedConstant(isExternallyInitialized) {
343 "invalid type for global variable");
347 "Initializer should be the same type as the GlobalVariable!");
357 bool isExternallyInitialized)
363 :
M.getDataLayout().getDefaultGlobalsAddressSpace()),
365 isExternallyInitializedConstant(isExternallyInitialized) {
367 "invalid type for global variable");
371 "Initializer should be the same type as the GlobalVariable!");
378 M.getGlobalList().push_back(
this);
395 Op<0>().set(
nullptr);
400 "Initializer type must match GlobalVariable type");
406 Op<0>().set(InitVal);
436 if (
auto *GO = dyn_cast<GlobalObject>(
C))
438 if (
auto *GA = dyn_cast<GlobalAlias>(
C))
439 if (Aliases.
insert(GA).second)
441 if (
auto *CE = dyn_cast<ConstantExpr>(
C)) {
442 switch (CE->getOpcode()) {
448 return LHS ? LHS : RHS;
450 case Instruction::Sub: {
455 case Instruction::IntToPtr:
456 case Instruction::PtrToInt:
457 case Instruction::BitCast:
458 case Instruction::GetElementPtr:
524 "Alias and aliasee types should match!");
void setExternallyInitialized(bool Val)
LLVMContextImpl *const pImpl
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
we should consider alternate ways to model stack dependencies Lots of things could be done in WebAssemblyTargetTransformInfo cpp there are numerous optimization related hooks that can be overridden in WebAssemblyTargetLowering Instead of the OptimizeReturned which should consider preserving the returned attribute through to MachineInstrs and extending the MemIntrinsicResults pass to do this optimization on calls too That would also let the WebAssemblyPeephole pass clean up dead defs for such as it does for stores Consider implementing and or getMachineCombinerPatterns Find a clean way to fix the problem which leads to the Shrink Wrapping pass being run after the WebAssembly PEI pass When setting multiple variables to the same constant
void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
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 GlobalVariable *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
LinkageTypes getLinkage() const
void setIndirectSymbol(Constant *Symbol)
These methods set and retrieve indirect symbol.
Type * getElementType() const
StringRef getSection() const
Get the custom section of this global if it has one.
void dropAllReferences()
Drop all references to operands.
bool isExternallyInitialized() const
static bool isLocalLinkage(LinkageTypes Linkage)
Error materialize()
Make sure this GlobalValue is fully read.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
unsigned HasPartition
True if this symbol has a partition name assigned (see https://lld.llvm.org/Partitions....
void setThreadLocalMode(ThreadLocalMode Val)
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
void setUnnamedAddr(UnnamedAddr Val)
LinkageTypes
An enumeration for the kinds of linkage for global values.
ConstantRange getConstantRangeFromMetadata(const MDNode &RangeMD)
Parse out a conservative ConstantRange from !range metadata.
std::pair< iterator, bool > insert(const ValueT &V)
const GlobalListType & getGlobalList() const
Get the Module's list of global variables (constant).
void setDSOLocal(bool Local)
DenseMap< const GlobalValue *, StringRef > GlobalValuePartitions
Collection of per-GlobalValue partitions used in this context.
bool hasInitializer() const
Definitions have initializers, declarations don't.
void setGlobalVariableNumOperands(unsigned NumOps)
Set the number of operands on a GlobalVariable.
StringRef getSection() const
Interface for looking up the initializer for a variable name, used by Init::resolveReferences.
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Compile-time customization of User operands.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
void setSection(StringRef S)
Change the section for this global.
(vector float) vec_cmpeq(*A, *B) C
ThreadLocalMode getThreadLocalMode() const
void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Symbol)
bool hasAtLeastLocalUnnamedAddr() const
Returns true if this value's address is not significant in this module.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
unsigned getValueID() const
Return an ID for the concrete type of this object.
const AliasListType & getAliasList() const
Get the Module's list of aliases (constant).
static const GlobalObject * findBaseObject(const Constant *C, DenseSet< const GlobalAlias * > &Aliases)
unsigned encode(MaybeAlign A)
Returns a representation of the alignment that encodes undefined as 0.
void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
bool hasGlobalUnnamedAddr() const
This struct is a compact representation of a valid (non-zero power of two) alignment.
bool isFunctionTy() const
True if this is an instance of FunctionType.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
const GlobalObject * getBaseObject() const
bool hasDefaultVisibility() const
void dropAllReferences()
Drop all references in preparation to destroy the GlobalVariable.
Implements a dense probed hash-table based set.
bool hasSection() const
Check if this global has a custom object file section.
bool canBenefitFromLocalAlias() const
This is an important base class in LLVM.
bool canIncreaseAlignment() const
Returns true if the alignment of the value can be unilaterally increased.
VisibilityTypes getVisibility() const
Module * getParent()
Get the module that this global value is contained inside of...
DLLStorageClassTypes getDLLStorageClass() const
DenseMap< const GlobalObject *, StringRef > GlobalObjectSections
Collection of per-GlobalObject sections used in this context.
StringRef getPartition() const
Class to represent pointers.
static const unsigned MaximumAlignment
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isExternalLinkage(LinkageTypes Linkage)
StringRef save(const char *S)
unsigned getAlignment() const
FIXME: Remove this function once transition to Align is over.
A Module instance is used to store all the information related to an LLVM module.
void clearMetadata()
Erase all metadata attached to this Value.
ValueTy
Concrete subclass of this.
bool isMaterializable() const
If this function's Module is being lazily streamed in functions from disk or some other source,...
bool canBeOmittedFromSymbolTable() const
True if GV can be left out of the object symbol table.
unsigned getGlobalValueSubClassData() const
StringRef - Represent a constant reference to a string, i.e.
Analysis the ScalarEvolution expression for r is this
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
void setDLLStorageClass(DLLStorageClassTypes C)
LLVMContext & getContext() const
All values hold a context through their type.
self_iterator getIterator()
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Linkage
Describes symbol linkage.
StringRef getName() const
Return a constant reference to the value's name.
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...
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 ...
void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
UnnamedAddr getUnnamedAddr() const
bool getSemanticInterposition() const
Returns whether semantic interposition is to be respected.
llvm::Error materialize(GlobalValue *GV)
Make sure the GlobalValue is fully read.
bool isInterposable() const
Return true if this global's definition can be substituted with an arbitrary definition at link time ...
const IFuncListType & getIFuncList() const
Get the Module's list of ifuncs (constant).
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool hasLinkOnceODRLinkage() const
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...
static bool isInterposableLinkage(LinkageTypes Linkage)
Whether the definition of this global may be replaced by something non-equivalent at link time.
Lightweight error class with error context and mandatory checking.
const Comdat * getComdat() const
AttributeSet getAttributes() const
Return the attribute set for this global.
const GlobalObject * getBaseObject() const
unsigned getAddressSpace() const
void setGlobalValueSubClassData(unsigned V)
bool isAbsoluteSymbolRef() const
Returns whether this is a reference to an absolute symbol.
Optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns None.
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
void setAttributes(AttributeSet A)
Set attribute list for this global.
void copyAttributesFrom(const GlobalObject *Src)
void setPartition(StringRef Part)
PointerType * getType() const
Global values are always pointers.
Type * getValueType() const
bool hasPartition() const
BlockVerifier::State From
void eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
Value * getOperand(unsigned i) const
void setAlignment(MaybeAlign Align)
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
void setVisibility(VisibilityTypes V)
LLVM Value Representation.
void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
void removeFromParent()
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it.
void setAliasee(Constant *Aliasee)
These methods retrieve and set alias target.
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...