Go to the documentation of this file.
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();
53 void GlobalValue::destroyConstantImpl() {
70 if (Src->hasSanitizerMetadata())
78 #define HANDLE_GLOBAL_VALUE(NAME) \
79 case Value::NAME##Val: \
80 return static_cast<NAME *>(this)->removeFromParent();
81 #include "llvm/IR/Value.def"
90 #define HANDLE_GLOBAL_VALUE(NAME) \
91 case Value::NAME##Val: \
92 return static_cast<NAME *>(this)->eraseFromParent();
93 #include "llvm/IR/Value.def"
113 auto isDeduplicateComdat = [](
const Comdat *
C) {
118 !isa<GlobalIFunc>(
this) && !isDeduplicateComdat(
getComdat());
128 "Alignment is greater than MaximumAlignment!");
133 "Alignment representation error!");
152 std::string NewName = std::string(
Name);
158 if (FileName.
empty())
159 NewName = NewName.insert(0,
"<unknown>:");
161 NewName = NewName.insert(0, FileName.
str() +
":");
172 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
175 return GO->getSection();
178 return cast<GlobalObject>(
this)->getSection();
182 if (
auto *GA = dyn_cast<GlobalAlias>(
this)) {
189 if (isa<GlobalIFunc>(
this))
191 return cast<GlobalObject>(
this)->getComdat();
239 MetadataMap.
erase(
this);
243 StringRef GlobalObject::getSectionImpl()
const {
267 return GV->getNumOperands() == 0;
270 if (
const Function *
F = dyn_cast<Function>(
this))
271 return F->empty() && !
F->isMaterializable();
274 assert(isa<GlobalAlias>(
this) || isa<GlobalIFunc>(
this));
321 if (
auto *GO = dyn_cast<GlobalObject>(
C))
323 if (
auto *GA = dyn_cast<GlobalAlias>(
C))
324 if (Aliases.
insert(GA).second)
326 if (
auto *CE = dyn_cast<ConstantExpr>(
C)) {
327 switch (CE->getOpcode()) {
335 case Instruction::Sub: {
340 case Instruction::IntToPtr:
341 case Instruction::PtrToInt:
342 case Instruction::BitCast:
343 case Instruction::GetElementPtr:
358 auto *GO = dyn_cast<GlobalObject>(
this);
362 return GO->getMetadata(LLVMContext::MD_absolute_symbol);
366 auto *GO = dyn_cast<GlobalObject>(
this);
370 MDNode *MD = GO->getMetadata(LLVMContext::MD_absolute_symbol);
388 if (
auto *Var = dyn_cast<GlobalVariable>(
this))
389 if (!Var->isConstant())
402 bool isExternallyInitialized)
407 isExternallyInitializedConstant(isExternallyInitialized) {
409 "invalid type for global variable");
413 "Initializer should be the same type as the GlobalVariable!");
423 bool isExternallyInitialized)
429 :
M.getDataLayout().getDefaultGlobalsAddressSpace()),
431 isExternallyInitializedConstant(isExternallyInitialized) {
433 "invalid type for global variable");
437 "Initializer should be the same type as the GlobalVariable!");
444 M.getGlobalList().push_back(
this);
461 Op<0>().set(
nullptr);
466 "Initializer type must match GlobalVariable type");
472 Op<0>().set(InitVal);
541 "Alias and aliasee types should match!");
542 Op<0>().set(Aliasee);
void setExternallyInitialized(bool Val)
bool hasSanitizerMetadata() const
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 setComdat(Comdat *C)
void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
This is an optimization pass for GlobalISel generic memory operations.
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
std::string getGlobalIdentifier() const
Return the modified name for this global value suitable to be used as the key for a global lookup (e....
static constexpr uint64_t MaximumAlignment
void copyAttributesFrom(const GlobalVariable *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
LinkageTypes getLinkage() const
@ NoDeduplicate
No deduplication is performed.
MaybeAlign getAlign() const
Returns the alignment of the given variable or function.
void dropAllReferences()
Drop all references to operands.
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.
bool erase(const KeyT &Val)
The instances of the Type class are immutable: once they are created, they are never changed.
void setSanitizerMetadata(SanitizerMetadata Meta)
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...
DenseMap< const GlobalValue *, GlobalValue::SanitizerMetadata > GlobalValueSanitizerMetadata
void setSection(StringRef S)
Change the section for this global.
const SanitizerMetadata & getSanitizerMetadata() const
(vector float) vec_cmpeq(*A, *B) C
unsigned HasSanitizerMetadata
True if this symbol has sanitizer metadata available.
void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
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.
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.
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
bool canIncreaseAlignment() const
Returns true if the alignment of the value can be unilaterally increased.
Module * getParent()
Get the module that this global value is contained inside of...
DenseMap< const GlobalObject *, StringRef > GlobalObjectSections
Collection of per-GlobalObject sections used in this context.
StringRef getPartition() const
Class to represent pointers.
const Constant * getResolver() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isExternalLinkage(LinkageTypes Linkage)
StringRef save(const char *S)
A Module instance is used to store all the information related to an LLVM module.
void clearMetadata()
Erase all metadata attached to this Value.
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
const GlobalObject * getAliaseeObject() const
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.
uint64_t getAlignment() const
FIXME: Remove this function once transition to Align is over.
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
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
GlobalValue::SanitizerMetadata SanitizerMetadata
unsigned getAddressSpace() const
void setGlobalValueSubClassData(unsigned V)
bool isAbsoluteSymbolRef() const
Returns whether this is a reference to an absolute symbol.
void removeSanitizerMetadata()
Optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns None.
const GlobalObject * getAliaseeObject() const
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.
const Function * getResolverFunction() const
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 ...