LLVM  6.0.0svn
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 }
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  assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
112  assert(Align <= MaximumAlignment &&
113  "Alignment is greater than MaximumAlignment!");
114  unsigned AlignmentData = Log2_32(Align) + 1;
115  unsigned OldData = getGlobalValueSubClassData();
116  setGlobalValueSubClassData((OldData & ~AlignmentMask) | AlignmentData);
117  assert(getAlignment() == Align && "Alignment representation error!");
118 }
119 
122  setAlignment(Src->getAlignment());
123  setSection(Src->getSection());
124 }
125 
128  StringRef FileName) {
129 
130  // Value names may be prefixed with a binary '1' to indicate
131  // that the backend should not modify the symbols due to any platform
132  // naming convention. Do not include that '1' in the PGO profile name.
133  if (Name[0] == '\1')
134  Name = Name.substr(1);
135 
136  std::string NewName = Name;
137  if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
138  // For local symbols, prepend the main file name to distinguish them.
139  // Do not include the full path in the file name since there's no guarantee
140  // that it will stay the same, e.g., if the files are checked out from
141  // version control in different locations.
142  if (FileName.empty())
143  NewName = NewName.insert(0, "<unknown>:");
144  else
145  NewName = NewName.insert(0, FileName.str() + ":");
146  }
147  return NewName;
148 }
149 
150 std::string GlobalValue::getGlobalIdentifier() const {
152  getParent()->getSourceFileName());
153 }
154 
156  if (auto *GA = dyn_cast<GlobalAlias>(this)) {
157  // In general we cannot compute this at the IR level, but we try.
158  if (const GlobalObject *GO = GA->getBaseObject())
159  return GO->getSection();
160  return "";
161  }
162  return cast<GlobalObject>(this)->getSection();
163 }
164 
166  if (auto *GA = dyn_cast<GlobalAlias>(this)) {
167  // In general we cannot compute this at the IR level, but we try.
168  if (const GlobalObject *GO = GA->getBaseObject())
169  return const_cast<GlobalObject *>(GO)->getComdat();
170  return nullptr;
171  }
172  // ifunc and its resolver are separate things so don't use resolver comdat.
173  if (isa<GlobalIFunc>(this))
174  return nullptr;
175  return cast<GlobalObject>(this)->getComdat();
176 }
177 
178 StringRef GlobalObject::getSectionImpl() const {
179  assert(hasSection());
180  return getContext().pImpl->GlobalObjectSections[this];
181 }
182 
184  // Do nothing if we're clearing the section and it is already empty.
185  if (!hasSection() && S.empty())
186  return;
187 
188  // Get or create a stable section name string and put it in the table in the
189  // context.
190  if (!S.empty()) {
191  S = getContext().pImpl->SectionStrings.insert(S).first->first();
192  }
194 
195  // Update the HasSectionHashEntryBit. Setting the section to the empty string
196  // means this global no longer has a section.
197  setGlobalObjectFlag(HasSectionHashEntryBit, !S.empty());
198 }
199 
201  // Globals are definitions if they have an initializer.
202  if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(this))
203  return GV->getNumOperands() == 0;
204 
205  // Functions are definitions if they have a body.
206  if (const Function *F = dyn_cast<Function>(this))
207  return F->empty() && !F->isMaterializable();
208 
209  // Aliases and ifuncs are always definitions.
210  assert(isa<GlobalIndirectSymbol>(this));
211  return false;
212 }
213 
215  // Firstly, can only increase the alignment of a global if it
216  // is a strong definition.
218  return false;
219 
220  // It also has to either not have a section defined, or, not have
221  // alignment specified. (If it is assigned a section, the global
222  // could be densely packed with other objects in the section, and
223  // increasing the alignment could cause padding issues.)
224  if (hasSection() && getAlignment() > 0)
225  return false;
226 
227  // On ELF platforms, we're further restricted in that we can't
228  // increase the alignment of any variable which might be emitted
229  // into a shared library, and which is exported. If the main
230  // executable accesses a variable found in a shared-lib, the main
231  // exe actually allocates memory for and exports the symbol ITSELF,
232  // overriding the symbol found in the library. That is, at link
233  // time, the observed alignment of the variable is copied into the
234  // executable binary. (A COPY relocation is also generated, to copy
235  // the initial data from the shadowed variable in the shared-lib
236  // into the location in the main binary, before running code.)
237  //
238  // And thus, even though you might think you are defining the
239  // global, and allocating the memory for the global in your object
240  // file, and thus should be able to set the alignment arbitrarily,
241  // that's not actually true. Doing so can cause an ABI breakage; an
242  // executable might have already been built with the previous
243  // alignment of the variable, and then assuming an increased
244  // alignment will be incorrect.
245 
246  // Conservatively assume ELF if there's no parent pointer.
247  bool isELF =
248  (!Parent || Triple(Parent->getTargetTriple()).isOSBinFormatELF());
249  if (isELF && hasDefaultVisibility() && !hasLocalLinkage())
250  return false;
251 
252  return true;
253 }
254 
256  if (auto *GO = dyn_cast<GlobalObject>(this))
257  return GO;
258  if (auto *GA = dyn_cast<GlobalIndirectSymbol>(this))
259  return GA->getBaseObject();
260  return nullptr;
261 }
262 
264  auto *GO = dyn_cast<GlobalObject>(this);
265  if (!GO)
266  return false;
267 
269 }
270 
272  auto *GO = dyn_cast<GlobalObject>(this);
273  if (!GO)
274  return None;
275 
276  MDNode *MD = GO->getMetadata(LLVMContext::MD_absolute_symbol);
277  if (!MD)
278  return None;
279 
280  return getConstantRangeFromMetadata(*MD);
281 }
282 
283 //===----------------------------------------------------------------------===//
284 // GlobalVariable Implementation
285 //===----------------------------------------------------------------------===//
286 
288  Constant *InitVal, const Twine &Name,
289  ThreadLocalMode TLMode, unsigned AddressSpace,
290  bool isExternallyInitialized)
291  : GlobalObject(Ty, Value::GlobalVariableVal,
293  InitVal != nullptr, Link, Name, AddressSpace),
294  isConstantGlobal(constant),
295  isExternallyInitializedConstant(isExternallyInitialized) {
297  "invalid type for global variable");
298  setThreadLocalMode(TLMode);
299  if (InitVal) {
300  assert(InitVal->getType() == Ty &&
301  "Initializer should be the same type as the GlobalVariable!");
302  Op<0>() = InitVal;
303  }
304 }
305 
307  LinkageTypes Link, Constant *InitVal,
308  const Twine &Name, GlobalVariable *Before,
309  ThreadLocalMode TLMode, unsigned AddressSpace,
311  : GlobalObject(Ty, Value::GlobalVariableVal,
313  InitVal != nullptr, Link, Name, AddressSpace),
314  isConstantGlobal(constant),
315  isExternallyInitializedConstant(isExternallyInitialized) {
317  "invalid type for global variable");
318  setThreadLocalMode(TLMode);
319  if (InitVal) {
320  assert(InitVal->getType() == Ty &&
321  "Initializer should be the same type as the GlobalVariable!");
322  Op<0>() = InitVal;
323  }
324 
325  if (Before)
326  Before->getParent()->getGlobalList().insert(Before->getIterator(), this);
327  else
328  M.getGlobalList().push_back(this);
329 }
330 
333 }
334 
337 }
338 
340  if (!InitVal) {
341  if (hasInitializer()) {
342  // Note, the num operands is used to compute the offset of the operand, so
343  // the order here matters. Clearing the operand then clearing the num
344  // operands ensures we have the correct offset to the operand.
345  Op<0>().set(nullptr);
347  }
348  } else {
349  assert(InitVal->getType() == getValueType() &&
350  "Initializer type must match GlobalVariable type");
351  // Note, the num operands is used to compute the offset of the operand, so
352  // the order here matters. We need to set num operands to 1 first so that
353  // we get the correct offset to the first operand when we set it.
354  if (!hasInitializer())
356  Op<0>().set(InitVal);
357  }
358 }
359 
360 /// Copy all additional attributes (those not needed to create a GlobalVariable)
361 /// from the GlobalVariable Src to this one.
367 }
368 
371  clearMetadata();
372 }
373 
374 //===----------------------------------------------------------------------===//
375 // GlobalIndirectSymbol Implementation
376 //===----------------------------------------------------------------------===//
377 
379  unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name,
380  Constant *Symbol)
381  : GlobalValue(Ty, VTy, &Op<0>(), 1, Linkage, Name, AddressSpace) {
382  Op<0>() = Symbol;
383 }
384 
385 
386 //===----------------------------------------------------------------------===//
387 // GlobalAlias Implementation
388 //===----------------------------------------------------------------------===//
389 
390 GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
391  const Twine &Name, Constant *Aliasee,
392  Module *ParentModule)
393  : GlobalIndirectSymbol(Ty, Value::GlobalAliasVal, AddressSpace, Link, Name,
394  Aliasee) {
395  if (ParentModule)
396  ParentModule->getAliasList().push_back(this);
397 }
398 
399 GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
400  LinkageTypes Link, const Twine &Name,
401  Constant *Aliasee, Module *ParentModule) {
402  return new GlobalAlias(Ty, AddressSpace, Link, Name, Aliasee, ParentModule);
403 }
404 
405 GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
406  LinkageTypes Linkage, const Twine &Name,
407  Module *Parent) {
408  return create(Ty, AddressSpace, Linkage, Name, nullptr, Parent);
409 }
410 
411 GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
412  LinkageTypes Linkage, const Twine &Name,
413  GlobalValue *Aliasee) {
414  return create(Ty, AddressSpace, Linkage, Name, Aliasee, Aliasee->getParent());
415 }
416 
418  GlobalValue *Aliasee) {
419  PointerType *PTy = Aliasee->getType();
420  return create(PTy->getElementType(), PTy->getAddressSpace(), Link, Name,
421  Aliasee);
422 }
423 
425  return create(Aliasee->getLinkage(), Name, Aliasee);
426 }
427 
429  getParent()->getAliasList().remove(getIterator());
430 }
431 
433  getParent()->getAliasList().erase(getIterator());
434 }
435 
437  assert((!Aliasee || Aliasee->getType() == getType()) &&
438  "Alias and aliasee types should match!");
439  setIndirectSymbol(Aliasee);
440 }
441 
442 //===----------------------------------------------------------------------===//
443 // GlobalIFunc Implementation
444 //===----------------------------------------------------------------------===//
445 
446 GlobalIFunc::GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
447  const Twine &Name, Constant *Resolver,
448  Module *ParentModule)
449  : GlobalIndirectSymbol(Ty, Value::GlobalIFuncVal, AddressSpace, Link, Name,
450  Resolver) {
451  if (ParentModule)
452  ParentModule->getIFuncList().push_back(this);
453 }
454 
455 GlobalIFunc *GlobalIFunc::create(Type *Ty, unsigned AddressSpace,
456  LinkageTypes Link, const Twine &Name,
457  Constant *Resolver, Module *ParentModule) {
458  return new GlobalIFunc(Ty, AddressSpace, Link, Name, Resolver, ParentModule);
459 }
460 
462  getParent()->getIFuncList().remove(getIterator());
463 }
464 
466  getParent()->getIFuncList().erase(getIterator());
467 }
void setVisibility(VisibilityTypes V)
Definition: GlobalValue.h:226
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
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:233
ThreadLocalMode getThreadLocalMode() const
Definition: GlobalValue.h:241
bool hasLocalLinkage() const
Definition: GlobalValue.h:416
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:459
void dropAllReferences()
Drop all references to operands.
Definition: User.h:279
iterator erase(iterator where)
Definition: ilist.h:280
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
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:697
Optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns None...
Definition: Globals.cpp:271
Metadata node.
Definition: Metadata.h:862
F(f)
const GlobalListType & getGlobalList() const
Get the Module&#39;s list of global variables (constant).
Definition: Module.h:498
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:150
void setAlignment(unsigned Align)
Definition: Globals.cpp:110
op_iterator op_begin()
Definition: User.h:214
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:301
void eraseFromParent()
eraseFromParent - This method unlinks &#39;this&#39; from the containing module and deletes it...
Definition: Globals.cpp:432
const AliasListType & getAliasList() const
Get the Module&#39;s list of aliases (constant).
Definition: Module.h:515
void setIndirectSymbol(Constant *Symbol)
These methods set and retrieve indirect symbol.
bool hasSection() const
Definition: GlobalValue.h:256
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:339
UnnamedAddr getUnnamedAddr() const
Definition: GlobalValue.h:200
void setThreadLocalMode(ThreadLocalMode Val)
Definition: GlobalValue.h:237
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Metadata.cpp:1431
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:455
static const unsigned MaximumAlignment
Definition: Value.h:590
void setDLLStorageClass(DLLStorageClassTypes C)
Definition: GlobalValue.h:254
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:465
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:430
unsigned getAlignment() const
Definition: Globals.cpp:96
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:287
Class to represent pointers.
Definition: DerivedTypes.h:467
bool canIncreaseAlignment() const
Definition: Globals.cpp:214
DLLStorageClassTypes getDLLStorageClass() const
Definition: GlobalValue.h:245
VisibilityTypes getVisibility() const
Definition: GlobalValue.h:220
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...
void setExternallyInitialized(bool Val)
void eraseFromParent()
eraseFromParent - This method unlinks &#39;this&#39; from the containing module and deletes it...
Definition: Globals.cpp:335
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:192
unsigned getGlobalValueSubClassData() const
Definition: GlobalValue.h:149
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:155
void removeFromParent()
removeFromParent - This method unlinks &#39;this&#39; from the containing module, but does not delete it...
Definition: Globals.cpp:331
#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:524
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:643
Module.h This file contains the declarations for the Module class.
AddressSpace
Definition: NVPTXBaseInfo.h:22
unsigned Linkage
Definition: GlobalValue.h:93
ValueTy
Concrete subclass of this.
Definition: Value.h:440
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:531
const Comdat * getComdat() const
Definition: Globals.cpp:165
void push_back(pointer val)
Definition: ilist.h:326
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:48
void setGlobalValueSubClassData(unsigned V)
Definition: GlobalValue.h:152
void setAttributes(AttributeSet A)
Set attribute list for this global.
void dropAllReferences()
Drop all references in preparation to destroy the GlobalVariable.
Definition: Globals.cpp:369
pointer remove(iterator &IT)
Definition: ilist.h:264
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:241
bool isFunctionTy() const
True if this is an instance of FunctionType.
Definition: Type.h:212
bool isAbsoluteSymbolRef() const
Returns whether this is a reference to an absolute symbol.
Definition: Globals.cpp:263
void setUnnamedAddr(UnnamedAddr Val)
Definition: GlobalValue.h:203
bool isStrongDefinitionForLinker() const
Returns true if this global&#39;s definition will be the one chosen by the linker.
Definition: GlobalValue.h:516
void removeFromParent()
removeFromParent - This method unlinks &#39;this&#39; from the containing module, but does not delete it...
Definition: Globals.cpp:428
StringRef getName() const
Return a constant reference to the value&#39;s name.
Definition: Value.cpp:218
void copyAttributesFrom(const GlobalVariable *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
Definition: Globals.cpp:362
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
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:386
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:262
void removeFromParent()
This method unlinks &#39;this&#39; from the containing module, but does not delete it.
Definition: Globals.cpp:461
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:200
const GlobalObject * getBaseObject() const
Definition: Globals.cpp:255
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:545
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:156
GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Symbol)
Definition: Globals.cpp:378
bool hasDefaultVisibility() const
Definition: GlobalValue.h:221
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Use & Op()
Definition: User.h:118
void copyAttributesFrom(const GlobalObject *Src)
Definition: Globals.cpp:120
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:183
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:399
void setAliasee(Constant *Aliasee)
These methods retrieve and set alias target.
Definition: Globals.cpp:436
Type * getElementType() const
Definition: DerivedTypes.h:486
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:260
StringSet SectionStrings
Stable collection of section strings.