LLVM  8.0.1
Globals.cpp
Go to the documentation of this file.
1 //===-- Globals.cpp - Implement the GlobalValue & GlobalVariable class ----===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the GlobalValue & GlobalVariable classes for the IR
11 // library.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "LLVMContextImpl.h"
16 #include "llvm/ADT/SmallPtrSet.h"
17 #include "llvm/ADT/Triple.h"
18 #include "llvm/IR/ConstantRange.h"
19 #include "llvm/IR/Constants.h"
20 #include "llvm/IR/DerivedTypes.h"
21 #include "llvm/IR/GlobalAlias.h"
22 #include "llvm/IR/GlobalValue.h"
23 #include "llvm/IR/GlobalVariable.h"
24 #include "llvm/IR/Module.h"
25 #include "llvm/IR/Operator.h"
26 #include "llvm/Support/Error.h"
28 using namespace llvm;
29 
30 //===----------------------------------------------------------------------===//
31 // GlobalValue Class
32 //===----------------------------------------------------------------------===//
33 
34 // GlobalValue should be a Constant, plus a type, a module, some flags, and an
35 // intrinsic ID. Add an assert to prevent people from accidentally growing
36 // GlobalValue while adding flags.
37 static_assert(sizeof(GlobalValue) ==
38  sizeof(Constant) + 2 * sizeof(void *) + 2 * sizeof(unsigned),
39  "unexpected GlobalValue size growth");
40 
41 // GlobalObject adds a comdat.
42 static_assert(sizeof(GlobalObject) == sizeof(GlobalValue) + sizeof(void *),
43  "unexpected GlobalObject size growth");
44 
46  if (const Function *F = dyn_cast<Function>(this))
47  return F->isMaterializable();
48  return false;
49 }
51  return getParent()->materialize(this);
52 }
53 
54 /// Override destroyConstantImpl to make sure it doesn't get called on
55 /// GlobalValue's because they shouldn't be treated like other constants.
56 void GlobalValue::destroyConstantImpl() {
57  llvm_unreachable("You can't GV->destroyConstantImpl()!");
58 }
59 
60 Value *GlobalValue::handleOperandChangeImpl(Value *From, Value *To) {
61  llvm_unreachable("Unsupported class for handleOperandChange()!");
62 }
63 
64 /// copyAttributesFrom - copy all additional attributes (those not needed to
65 /// create a GlobalValue) from the GlobalValue Src to this one.
70  setDSOLocal(Src->isDSOLocal());
71 }
72 
74  switch (getValueID()) {
75 #define HANDLE_GLOBAL_VALUE(NAME) \
76  case Value::NAME##Val: \
77  return static_cast<NAME *>(this)->removeFromParent();
78 #include "llvm/IR/Value.def"
79  default:
80  break;
81  }
82  llvm_unreachable("not a global");
83 }
84 
86  switch (getValueID()) {
87 #define HANDLE_GLOBAL_VALUE(NAME) \
88  case Value::NAME##Val: \
89  return static_cast<NAME *>(this)->eraseFromParent();
90 #include "llvm/IR/Value.def"
91  default:
92  break;
93  }
94  llvm_unreachable("not a global");
95 }
96 
97 unsigned GlobalValue::getAlignment() const {
98  if (auto *GA = dyn_cast<GlobalAlias>(this)) {
99  // In general we cannot compute this at the IR level, but we try.
100  if (const GlobalObject *GO = GA->getBaseObject())
101  return GO->getAlignment();
102 
103  // FIXME: we should also be able to handle:
104  // Alias = Global + Offset
105  // Alias = Absolute
106  return 0;
107  }
108  return cast<GlobalObject>(this)->getAlignment();
109 }
110 
112  PointerType *PtrTy = getType();
113  return PtrTy->getAddressSpace();
114 }
115 
117  assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
118  assert(Align <= MaximumAlignment &&
119  "Alignment is greater than MaximumAlignment!");
120  unsigned AlignmentData = Log2_32(Align) + 1;
121  unsigned OldData = getGlobalValueSubClassData();
122  setGlobalValueSubClassData((OldData & ~AlignmentMask) | AlignmentData);
123  assert(getAlignment() == Align && "Alignment representation error!");
124 }
125 
128  setAlignment(Src->getAlignment());
129  setSection(Src->getSection());
130 }
131 
134  StringRef FileName) {
135 
136  // Value names may be prefixed with a binary '1' to indicate
137  // that the backend should not modify the symbols due to any platform
138  // naming convention. Do not include that '1' in the PGO profile name.
139  if (Name[0] == '\1')
140  Name = Name.substr(1);
141 
142  std::string NewName = Name;
143  if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
144  // For local symbols, prepend the main file name to distinguish them.
145  // Do not include the full path in the file name since there's no guarantee
146  // that it will stay the same, e.g., if the files are checked out from
147  // version control in different locations.
148  if (FileName.empty())
149  NewName = NewName.insert(0, "<unknown>:");
150  else
151  NewName = NewName.insert(0, FileName.str() + ":");
152  }
153  return NewName;
154 }
155 
156 std::string GlobalValue::getGlobalIdentifier() const {
158  getParent()->getSourceFileName());
159 }
160 
162  if (auto *GA = dyn_cast<GlobalAlias>(this)) {
163  // In general we cannot compute this at the IR level, but we try.
164  if (const GlobalObject *GO = GA->getBaseObject())
165  return GO->getSection();
166  return "";
167  }
168  return cast<GlobalObject>(this)->getSection();
169 }
170 
172  if (auto *GA = dyn_cast<GlobalAlias>(this)) {
173  // In general we cannot compute this at the IR level, but we try.
174  if (const GlobalObject *GO = GA->getBaseObject())
175  return const_cast<GlobalObject *>(GO)->getComdat();
176  return nullptr;
177  }
178  // ifunc and its resolver are separate things so don't use resolver comdat.
179  if (isa<GlobalIFunc>(this))
180  return nullptr;
181  return cast<GlobalObject>(this)->getComdat();
182 }
183 
184 StringRef GlobalObject::getSectionImpl() const {
185  assert(hasSection());
186  return getContext().pImpl->GlobalObjectSections[this];
187 }
188 
190  // Do nothing if we're clearing the section and it is already empty.
191  if (!hasSection() && S.empty())
192  return;
193 
194  // Get or create a stable section name string and put it in the table in the
195  // context.
196  if (!S.empty()) {
197  S = getContext().pImpl->SectionStrings.insert(S).first->first();
198  }
200 
201  // Update the HasSectionHashEntryBit. Setting the section to the empty string
202  // means this global no longer has a section.
203  setGlobalObjectFlag(HasSectionHashEntryBit, !S.empty());
204 }
205 
207  // Globals are definitions if they have an initializer.
208  if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(this))
209  return GV->getNumOperands() == 0;
210 
211  // Functions are definitions if they have a body.
212  if (const Function *F = dyn_cast<Function>(this))
213  return F->empty() && !F->isMaterializable();
214 
215  // Aliases and ifuncs are always definitions.
216  assert(isa<GlobalIndirectSymbol>(this));
217  return false;
218 }
219 
221  // Firstly, can only increase the alignment of a global if it
222  // is a strong definition.
224  return false;
225 
226  // It also has to either not have a section defined, or, not have
227  // alignment specified. (If it is assigned a section, the global
228  // could be densely packed with other objects in the section, and
229  // increasing the alignment could cause padding issues.)
230  if (hasSection() && getAlignment() > 0)
231  return false;
232 
233  // On ELF platforms, we're further restricted in that we can't
234  // increase the alignment of any variable which might be emitted
235  // into a shared library, and which is exported. If the main
236  // executable accesses a variable found in a shared-lib, the main
237  // exe actually allocates memory for and exports the symbol ITSELF,
238  // overriding the symbol found in the library. That is, at link
239  // time, the observed alignment of the variable is copied into the
240  // executable binary. (A COPY relocation is also generated, to copy
241  // the initial data from the shadowed variable in the shared-lib
242  // into the location in the main binary, before running code.)
243  //
244  // And thus, even though you might think you are defining the
245  // global, and allocating the memory for the global in your object
246  // file, and thus should be able to set the alignment arbitrarily,
247  // that's not actually true. Doing so can cause an ABI breakage; an
248  // executable might have already been built with the previous
249  // alignment of the variable, and then assuming an increased
250  // alignment will be incorrect.
251 
252  // Conservatively assume ELF if there's no parent pointer.
253  bool isELF =
254  (!Parent || Triple(Parent->getTargetTriple()).isOSBinFormatELF());
255  if (isELF && !isDSOLocal())
256  return false;
257 
258  return true;
259 }
260 
262  if (auto *GO = dyn_cast<GlobalObject>(this))
263  return GO;
264  if (auto *GA = dyn_cast<GlobalIndirectSymbol>(this))
265  return GA->getBaseObject();
266  return nullptr;
267 }
268 
270  auto *GO = dyn_cast<GlobalObject>(this);
271  if (!GO)
272  return false;
273 
275 }
276 
278  auto *GO = dyn_cast<GlobalObject>(this);
279  if (!GO)
280  return None;
281 
282  MDNode *MD = GO->getMetadata(LLVMContext::MD_absolute_symbol);
283  if (!MD)
284  return None;
285 
286  return getConstantRangeFromMetadata(*MD);
287 }
288 
290  if (!hasLinkOnceODRLinkage())
291  return false;
292 
293  // We assume that anyone who sets global unnamed_addr on a non-constant
294  // knows what they're doing.
295  if (hasGlobalUnnamedAddr())
296  return true;
297 
298  // If it is a non constant variable, it needs to be uniqued across shared
299  // objects.
300  if (auto *Var = dyn_cast<GlobalVariable>(this))
301  if (!Var->isConstant())
302  return false;
303 
305 }
306 
307 //===----------------------------------------------------------------------===//
308 // GlobalVariable Implementation
309 //===----------------------------------------------------------------------===//
310 
312  Constant *InitVal, const Twine &Name,
313  ThreadLocalMode TLMode, unsigned AddressSpace,
314  bool isExternallyInitialized)
315  : GlobalObject(Ty, Value::GlobalVariableVal,
317  InitVal != nullptr, Link, Name, AddressSpace),
318  isConstantGlobal(constant),
319  isExternallyInitializedConstant(isExternallyInitialized) {
321  "invalid type for global variable");
322  setThreadLocalMode(TLMode);
323  if (InitVal) {
324  assert(InitVal->getType() == Ty &&
325  "Initializer should be the same type as the GlobalVariable!");
326  Op<0>() = InitVal;
327  }
328 }
329 
331  LinkageTypes Link, Constant *InitVal,
332  const Twine &Name, GlobalVariable *Before,
333  ThreadLocalMode TLMode, unsigned AddressSpace,
335  : GlobalObject(Ty, Value::GlobalVariableVal,
337  InitVal != nullptr, Link, Name, AddressSpace),
338  isConstantGlobal(constant),
339  isExternallyInitializedConstant(isExternallyInitialized) {
341  "invalid type for global variable");
342  setThreadLocalMode(TLMode);
343  if (InitVal) {
344  assert(InitVal->getType() == Ty &&
345  "Initializer should be the same type as the GlobalVariable!");
346  Op<0>() = InitVal;
347  }
348 
349  if (Before)
350  Before->getParent()->getGlobalList().insert(Before->getIterator(), this);
351  else
352  M.getGlobalList().push_back(this);
353 }
354 
357 }
358 
361 }
362 
364  if (!InitVal) {
365  if (hasInitializer()) {
366  // Note, the num operands is used to compute the offset of the operand, so
367  // the order here matters. Clearing the operand then clearing the num
368  // operands ensures we have the correct offset to the operand.
369  Op<0>().set(nullptr);
371  }
372  } else {
373  assert(InitVal->getType() == getValueType() &&
374  "Initializer type must match GlobalVariable type");
375  // Note, the num operands is used to compute the offset of the operand, so
376  // the order here matters. We need to set num operands to 1 first so that
377  // we get the correct offset to the first operand when we set it.
378  if (!hasInitializer())
380  Op<0>().set(InitVal);
381  }
382 }
383 
384 /// Copy all additional attributes (those not needed to create a GlobalVariable)
385 /// from the GlobalVariable Src to this one.
391 }
392 
395  clearMetadata();
396 }
397 
398 //===----------------------------------------------------------------------===//
399 // GlobalIndirectSymbol Implementation
400 //===----------------------------------------------------------------------===//
401 
403  unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name,
404  Constant *Symbol)
405  : GlobalValue(Ty, VTy, &Op<0>(), 1, Linkage, Name, AddressSpace) {
406  Op<0>() = Symbol;
407 }
408 
409 
410 //===----------------------------------------------------------------------===//
411 // GlobalAlias Implementation
412 //===----------------------------------------------------------------------===//
413 
414 GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
415  const Twine &Name, Constant *Aliasee,
416  Module *ParentModule)
417  : GlobalIndirectSymbol(Ty, Value::GlobalAliasVal, AddressSpace, Link, Name,
418  Aliasee) {
419  if (ParentModule)
420  ParentModule->getAliasList().push_back(this);
421 }
422 
423 GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
424  LinkageTypes Link, const Twine &Name,
425  Constant *Aliasee, Module *ParentModule) {
426  return new GlobalAlias(Ty, AddressSpace, Link, Name, Aliasee, ParentModule);
427 }
428 
429 GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
430  LinkageTypes Linkage, const Twine &Name,
431  Module *Parent) {
432  return create(Ty, AddressSpace, Linkage, Name, nullptr, Parent);
433 }
434 
435 GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
436  LinkageTypes Linkage, const Twine &Name,
437  GlobalValue *Aliasee) {
438  return create(Ty, AddressSpace, Linkage, Name, Aliasee, Aliasee->getParent());
439 }
440 
442  GlobalValue *Aliasee) {
443  PointerType *PTy = Aliasee->getType();
444  return create(PTy->getElementType(), PTy->getAddressSpace(), Link, Name,
445  Aliasee);
446 }
447 
449  return create(Aliasee->getLinkage(), Name, Aliasee);
450 }
451 
453  getParent()->getAliasList().remove(getIterator());
454 }
455 
457  getParent()->getAliasList().erase(getIterator());
458 }
459 
461  assert((!Aliasee || Aliasee->getType() == getType()) &&
462  "Alias and aliasee types should match!");
463  setIndirectSymbol(Aliasee);
464 }
465 
466 //===----------------------------------------------------------------------===//
467 // GlobalIFunc Implementation
468 //===----------------------------------------------------------------------===//
469 
470 GlobalIFunc::GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
471  const Twine &Name, Constant *Resolver,
472  Module *ParentModule)
473  : GlobalIndirectSymbol(Ty, Value::GlobalIFuncVal, AddressSpace, Link, Name,
474  Resolver) {
475  if (ParentModule)
476  ParentModule->getIFuncList().push_back(this);
477 }
478 
479 GlobalIFunc *GlobalIFunc::create(Type *Ty, unsigned AddressSpace,
480  LinkageTypes Link, const Twine &Name,
481  Constant *Resolver, Module *ParentModule) {
482  return new GlobalIFunc(Ty, AddressSpace, Link, Name, Resolver, ParentModule);
483 }
484 
486  getParent()->getIFuncList().remove(getIterator());
487 }
488 
490  getParent()->getIFuncList().erase(getIterator());
491 }
void setVisibility(VisibilityTypes V)
Definition: GlobalValue.h:239
const NoneType None
Definition: None.h:24
AttributeSet getAttributes() const
Return the attribute set for this global.
StringRef getSection() const
Get the custom section of this global if it has one.
Definition: GlobalObject.h:90
unsigned getAlignment() const
Definition: GlobalObject.h:59
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.
Definition: Module.h:240
ThreadLocalMode getThreadLocalMode() const
Definition: GlobalValue.h:255
void copyAttributesFrom(const GlobalValue *Src)
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
Definition: Globals.cpp:66
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:228
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:464
void dropAllReferences()
Drop all references to operands.
Definition: User.h:295
iterator erase(iterator where)
Definition: ilist.h:267
This class represents lattice values for constants.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
bool isMaterializable() const
If this function&#39;s Module is being lazily streamed in functions from disk or some other source...
Definition: Globals.cpp:45
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:705
Optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns None...
Definition: Globals.cpp:277
Metadata node.
Definition: Metadata.h:864
F(f)
const GlobalListType & getGlobalList() const
Get the Module&#39;s list of global variables (constant).
Definition: Module.h:521
std::string getGlobalIdentifier() const
Return the modified name for this global value suitable to be used as the key for a global lookup (e...
Definition: Globals.cpp:156
void setAlignment(unsigned Align)
Definition: Globals.cpp:116
op_iterator op_begin()
Definition: User.h:230
bool canBeOmittedFromSymbolTable() const
True if GV can be left out of the object symbol table.
Definition: Globals.cpp:289
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:321
void eraseFromParent()
eraseFromParent - This method unlinks &#39;this&#39; from the containing module and deletes it...
Definition: Globals.cpp:456
const AliasListType & getAliasList() const
Get the Module&#39;s list of aliases (constant).
Definition: Module.h:538
void setIndirectSymbol(Constant *Symbol)
These methods set and retrieve indirect symbol.
bool hasSection() const
Definition: GlobalValue.h:270
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...
Definition: Twine.h:81
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
Definition: Globals.cpp:363
bool isDSOLocal() const
Definition: GlobalValue.h:280
UnnamedAddr getUnnamedAddr() const
Definition: GlobalValue.h:213
bool hasAtLeastLocalUnnamedAddr() const
Returns true if this value&#39;s address is not significant in this module.
Definition: GlobalValue.h:209
void setThreadLocalMode(ThreadLocalMode Val)
Definition: GlobalValue.h:251
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Metadata.cpp:1444
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...
Definition: Globals.cpp:479
static const unsigned MaximumAlignment
Definition: Value.h:596
void setDLLStorageClass(DLLStorageClassTypes C)
Definition: GlobalValue.h:268
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
void eraseFromParent()
This method unlinks &#39;this&#39; from the containing module and deletes it.
Definition: Globals.cpp:489
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
LinkageTypes getLinkage() const
Definition: GlobalValue.h:451
unsigned getAlignment() const
Definition: Globals.cpp:97
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).
Definition: StringRef.h:598
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 ...
Definition: Globals.cpp:311
Class to represent pointers.
Definition: DerivedTypes.h:467
bool hasLinkOnceODRLinkage() const
Definition: GlobalValue.h:427
bool canIncreaseAlignment() const
Definition: Globals.cpp:220
DLLStorageClassTypes getDLLStorageClass() const
Definition: GlobalValue.h:259
VisibilityTypes getVisibility() const
Definition: GlobalValue.h:233
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...
Definition: Type.h:46
This is an important base class in LLVM.
Definition: Constant.h:42
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.
Definition: Record.h:1774
void setExternallyInitialized(bool Val)
void eraseFromParent()
eraseFromParent - This method unlinks &#39;this&#39; from the containing module and deletes it...
Definition: Globals.cpp:359
unsigned getAddressSpace() const
Definition: Globals.cpp:111
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:495
self_iterator getIterator()
Definition: ilist_node.h:82
void setGlobalVariableNumOperands(unsigned NumOps)
Set the number of operands on a GlobalVariable.
Definition: User.h:208
unsigned getGlobalValueSubClassData() const
Definition: GlobalValue.h:161
Error materialize()
Make sure this GlobalValue is fully read.
Definition: Globals.cpp:50
DenseMap< const GlobalObject *, StringRef > GlobalObjectSections
Collection of per-GlobalObject sections used in this context.
StringRef getSection() const
Definition: Globals.cpp:161
void removeFromParent()
removeFromParent - This method unlinks &#39;this&#39; from the containing module, but does not delete it...
Definition: Globals.cpp:355
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::pair< typename base::iterator, bool > insert(StringRef Key)
Definition: StringSet.h:38
LLVMContextImpl *const pImpl
Definition: LLVMContext.h:71
const IFuncListType & getIFuncList() const
Get the Module&#39;s list of ifuncs (constant).
Definition: Module.h:547
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Definition: Type.cpp:656
BlockVerifier::State From
Module.h This file contains the declarations for the Module class.
AddressSpace
Definition: NVPTXBaseInfo.h:22
unsigned Linkage
Definition: GlobalValue.h:95
bool hasGlobalUnnamedAddr() const
Definition: GlobalValue.h:200
ValueTy
Concrete subclass of this.
Definition: Value.h:445
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
Definition: MathExtras.h:539
const Comdat * getComdat() const
Definition: Globals.cpp:171
void push_back(pointer val)
Definition: ilist.h:313
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:48
void setGlobalValueSubClassData(unsigned V)
Definition: GlobalValue.h:164
void setAttributes(AttributeSet A)
Set attribute list for this global.
void dropAllReferences()
Drop all references in preparation to destroy the GlobalVariable.
Definition: Globals.cpp:393
pointer remove(iterator &IT)
Definition: ilist.h:251
void eraseFromParent()
This method unlinks &#39;this&#39; from the containing module and deletes it.
Definition: Globals.cpp:85
iterator insert(iterator where, pointer New)
Definition: ilist.h:228
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:215
bool isAbsoluteSymbolRef() const
Returns whether this is a reference to an absolute symbol.
Definition: Globals.cpp:269
void setUnnamedAddr(UnnamedAddr Val)
Definition: GlobalValue.h:216
bool isStrongDefinitionForLinker() const
Returns true if this global&#39;s definition will be the one chosen by the linker.
Definition: GlobalValue.h:537
void removeFromParent()
removeFromParent - This method unlinks &#39;this&#39; from the containing module, but does not delete it...
Definition: Globals.cpp:452
StringRef getName() const
Return a constant reference to the value&#39;s name.
Definition: Value.cpp:214
void copyAttributesFrom(const GlobalVariable *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
Definition: Globals.cpp:386
Compile-time customization of User operands.
Definition: User.h:43
llvm::Error materialize(GlobalValue *GV)
Make sure the GlobalValue is fully read.
Definition: Module.cpp:396
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Definition: Casting.h:323
Type * getValueType() const
Definition: GlobalValue.h:276
void removeFromParent()
This method unlinks &#39;this&#39; from the containing module, but does not delete it.
Definition: Globals.cpp:485
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:206
const GlobalObject * getBaseObject() const
Definition: Globals.cpp:261
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:566
LLVM Value Representation.
Definition: Value.h:73
bool hasInitializer() const
Definitions have initializers, declarations don&#39;t.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:158
GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Symbol)
Definition: Globals.cpp:402
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Use & Op()
Definition: User.h:134
void copyAttributesFrom(const GlobalObject *Src)
Definition: Globals.cpp:126
void removeFromParent()
This method unlinks &#39;this&#39; from the containing module, but does not delete it.
Definition: Globals.cpp:73
bool isExternallyInitialized() const
void setSection(StringRef S)
Change the section for this global.
Definition: Globals.cpp:189
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...
Definition: Globals.cpp:423
void setAliasee(Constant *Aliasee)
These methods retrieve and set alias target.
Definition: Globals.cpp:460
Type * getElementType() const
Definition: DerivedTypes.h:486
void setDSOLocal(bool Local)
Definition: GlobalValue.h:278
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:274
StringSet SectionStrings
Stable collection of section strings.