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