LLVM  4.0.0
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 "llvm/ADT/SmallPtrSet.h"
16 #include "llvm/ADT/Triple.h"
17 #include "llvm/IR/Constants.h"
18 #include "llvm/IR/ConstantRange.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 #include "LLVMContextImpl.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 
72 unsigned GlobalValue::getAlignment() const {
73  if (auto *GA = dyn_cast<GlobalAlias>(this)) {
74  // In general we cannot compute this at the IR level, but we try.
75  if (const GlobalObject *GO = GA->getBaseObject())
76  return GO->getAlignment();
77 
78  // FIXME: we should also be able to handle:
79  // Alias = Global + Offset
80  // Alias = Absolute
81  return 0;
82  }
83  return cast<GlobalObject>(this)->getAlignment();
84 }
85 
86 void GlobalObject::setAlignment(unsigned Align) {
87  assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
88  assert(Align <= MaximumAlignment &&
89  "Alignment is greater than MaximumAlignment!");
90  unsigned AlignmentData = Log2_32(Align) + 1;
91  unsigned OldData = getGlobalValueSubClassData();
92  setGlobalValueSubClassData((OldData & ~AlignmentMask) | AlignmentData);
93  assert(getAlignment() == Align && "Alignment representation error!");
94 }
95 
97  unsigned ValueData = getGlobalValueSubClassData();
98  return ValueData >> GlobalObjectBits;
99 }
100 
102  unsigned OldData = getGlobalValueSubClassData();
103  setGlobalValueSubClassData((OldData & GlobalObjectMask) |
104  (Val << GlobalObjectBits));
105  assert(getGlobalObjectSubClassData() == Val && "representation error");
106 }
107 
110  if (const auto *GV = dyn_cast<GlobalObject>(Src)) {
111  setAlignment(GV->getAlignment());
112  setSection(GV->getSection());
113  }
114 }
115 
118  StringRef FileName) {
119 
120  // Value names may be prefixed with a binary '1' to indicate
121  // that the backend should not modify the symbols due to any platform
122  // naming convention. Do not include that '1' in the PGO profile name.
123  if (Name[0] == '\1')
124  Name = Name.substr(1);
125 
126  std::string NewName = Name;
127  if (llvm::GlobalValue::isLocalLinkage(Linkage)) {
128  // For local symbols, prepend the main file name to distinguish them.
129  // Do not include the full path in the file name since there's no guarantee
130  // that it will stay the same, e.g., if the files are checked out from
131  // version control in different locations.
132  if (FileName.empty())
133  NewName = NewName.insert(0, "<unknown>:");
134  else
135  NewName = NewName.insert(0, FileName.str() + ":");
136  }
137  return NewName;
138 }
139 
140 std::string GlobalValue::getGlobalIdentifier() const {
142  getParent()->getSourceFileName());
143 }
144 
146  if (auto *GA = dyn_cast<GlobalAlias>(this)) {
147  // In general we cannot compute this at the IR level, but we try.
148  if (const GlobalObject *GO = GA->getBaseObject())
149  return GO->getSection();
150  return "";
151  }
152  return cast<GlobalObject>(this)->getSection();
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 const_cast<GlobalObject *>(GO)->getComdat();
160  return nullptr;
161  }
162  // ifunc and its resolver are separate things so don't use resolver comdat.
163  if (isa<GlobalIFunc>(this))
164  return nullptr;
165  return cast<GlobalObject>(this)->getComdat();
166 }
167 
168 StringRef GlobalObject::getSectionImpl() const {
169  assert(hasSection());
170  return getContext().pImpl->GlobalObjectSections[this];
171 }
172 
174  // Do nothing if we're clearing the section and it is already empty.
175  if (!hasSection() && S.empty())
176  return;
177 
178  // Get or create a stable section name string and put it in the table in the
179  // context.
180  S = getContext().pImpl->SectionStrings.insert(S).first->first();
182 
183  // Update the HasSectionHashEntryBit. Setting the section to the empty string
184  // means this global no longer has a section.
185  setGlobalObjectFlag(HasSectionHashEntryBit, !S.empty());
186 }
187 
189  // Globals are definitions if they have an initializer.
190  if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(this))
191  return GV->getNumOperands() == 0;
192 
193  // Functions are definitions if they have a body.
194  if (const Function *F = dyn_cast<Function>(this))
195  return F->empty() && !F->isMaterializable();
196 
197  // Aliases and ifuncs are always definitions.
198  assert(isa<GlobalIndirectSymbol>(this));
199  return false;
200 }
201 
203  // Firstly, can only increase the alignment of a global if it
204  // is a strong definition.
206  return false;
207 
208  // It also has to either not have a section defined, or, not have
209  // alignment specified. (If it is assigned a section, the global
210  // could be densely packed with other objects in the section, and
211  // increasing the alignment could cause padding issues.)
212  if (hasSection() && getAlignment() > 0)
213  return false;
214 
215  // On ELF platforms, we're further restricted in that we can't
216  // increase the alignment of any variable which might be emitted
217  // into a shared library, and which is exported. If the main
218  // executable accesses a variable found in a shared-lib, the main
219  // exe actually allocates memory for and exports the symbol ITSELF,
220  // overriding the symbol found in the library. That is, at link
221  // time, the observed alignment of the variable is copied into the
222  // executable binary. (A COPY relocation is also generated, to copy
223  // the initial data from the shadowed variable in the shared-lib
224  // into the location in the main binary, before running code.)
225  //
226  // And thus, even though you might think you are defining the
227  // global, and allocating the memory for the global in your object
228  // file, and thus should be able to set the alignment arbitrarily,
229  // that's not actually true. Doing so can cause an ABI breakage; an
230  // executable might have already been built with the previous
231  // alignment of the variable, and then assuming an increased
232  // alignment will be incorrect.
233 
234  // Conservatively assume ELF if there's no parent pointer.
235  bool isELF =
236  (!Parent || Triple(Parent->getTargetTriple()).isOSBinFormatELF());
237  if (isELF && hasDefaultVisibility() && !hasLocalLinkage())
238  return false;
239 
240  return true;
241 }
242 
244  if (auto *GO = dyn_cast<GlobalObject>(this))
245  return GO;
246  if (auto *GA = dyn_cast<GlobalAlias>(this))
247  return GA->getBaseObject();
248  return nullptr;
249 }
250 
252  auto *GO = dyn_cast<GlobalObject>(this);
253  if (!GO)
254  return false;
255 
257 }
258 
260  auto *GO = dyn_cast<GlobalObject>(this);
261  if (!GO)
262  return None;
263 
264  MDNode *MD = GO->getMetadata(LLVMContext::MD_absolute_symbol);
265  if (!MD)
266  return None;
267 
268  return getConstantRangeFromMetadata(*MD);
269 }
270 
271 //===----------------------------------------------------------------------===//
272 // GlobalVariable Implementation
273 //===----------------------------------------------------------------------===//
274 
276  Constant *InitVal, const Twine &Name,
277  ThreadLocalMode TLMode, unsigned AddressSpace,
278  bool isExternallyInitialized)
279  : GlobalObject(Ty, Value::GlobalVariableVal,
280  OperandTraits<GlobalVariable>::op_begin(this),
281  InitVal != nullptr, Link, Name, AddressSpace),
282  isConstantGlobal(constant),
283  isExternallyInitializedConstant(isExternallyInitialized) {
284  setThreadLocalMode(TLMode);
285  if (InitVal) {
286  assert(InitVal->getType() == Ty &&
287  "Initializer should be the same type as the GlobalVariable!");
288  Op<0>() = InitVal;
289  }
290 }
291 
293  LinkageTypes Link, Constant *InitVal,
294  const Twine &Name, GlobalVariable *Before,
295  ThreadLocalMode TLMode, unsigned AddressSpace,
296  bool isExternallyInitialized)
297  : GlobalObject(Ty, Value::GlobalVariableVal,
298  OperandTraits<GlobalVariable>::op_begin(this),
299  InitVal != nullptr, Link, Name, AddressSpace),
300  isConstantGlobal(constant),
301  isExternallyInitializedConstant(isExternallyInitialized) {
302  setThreadLocalMode(TLMode);
303  if (InitVal) {
304  assert(InitVal->getType() == Ty &&
305  "Initializer should be the same type as the GlobalVariable!");
306  Op<0>() = InitVal;
307  }
308 
309  if (Before)
310  Before->getParent()->getGlobalList().insert(Before->getIterator(), this);
311  else
312  M.getGlobalList().push_back(this);
313 }
314 
317 }
318 
321 }
322 
324  if (!InitVal) {
325  if (hasInitializer()) {
326  // Note, the num operands is used to compute the offset of the operand, so
327  // the order here matters. Clearing the operand then clearing the num
328  // operands ensures we have the correct offset to the operand.
329  Op<0>().set(nullptr);
331  }
332  } else {
333  assert(InitVal->getType() == getValueType() &&
334  "Initializer type must match GlobalVariable type");
335  // Note, the num operands is used to compute the offset of the operand, so
336  // the order here matters. We need to set num operands to 1 first so that
337  // we get the correct offset to the first operand when we set it.
338  if (!hasInitializer())
340  Op<0>().set(InitVal);
341  }
342 }
343 
344 /// Copy all additional attributes (those not needed to create a GlobalVariable)
345 /// from the GlobalVariable Src to this one.
348  if (const GlobalVariable *SrcVar = dyn_cast<GlobalVariable>(Src)) {
349  setThreadLocalMode(SrcVar->getThreadLocalMode());
350  setExternallyInitialized(SrcVar->isExternallyInitialized());
351  }
352 }
353 
356  clearMetadata();
357 }
358 
359 //===----------------------------------------------------------------------===//
360 // GlobalIndirectSymbol Implementation
361 //===----------------------------------------------------------------------===//
362 
364  unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name,
365  Constant *Symbol)
366  : GlobalValue(Ty, VTy, &Op<0>(), 1, Linkage, Name, AddressSpace) {
367  Op<0>() = Symbol;
368 }
369 
370 
371 //===----------------------------------------------------------------------===//
372 // GlobalAlias Implementation
373 //===----------------------------------------------------------------------===//
374 
375 GlobalAlias::GlobalAlias(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
376  const Twine &Name, Constant *Aliasee,
377  Module *ParentModule)
378  : GlobalIndirectSymbol(Ty, Value::GlobalAliasVal, AddressSpace, Link, Name,
379  Aliasee) {
380  if (ParentModule)
381  ParentModule->getAliasList().push_back(this);
382 }
383 
384 GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
385  LinkageTypes Link, const Twine &Name,
386  Constant *Aliasee, Module *ParentModule) {
387  return new GlobalAlias(Ty, AddressSpace, Link, Name, Aliasee, ParentModule);
388 }
389 
390 GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
391  LinkageTypes Linkage, const Twine &Name,
392  Module *Parent) {
393  return create(Ty, AddressSpace, Linkage, Name, nullptr, Parent);
394 }
395 
396 GlobalAlias *GlobalAlias::create(Type *Ty, unsigned AddressSpace,
397  LinkageTypes Linkage, const Twine &Name,
398  GlobalValue *Aliasee) {
399  return create(Ty, AddressSpace, Linkage, Name, Aliasee, Aliasee->getParent());
400 }
401 
403  GlobalValue *Aliasee) {
404  PointerType *PTy = Aliasee->getType();
405  return create(PTy->getElementType(), PTy->getAddressSpace(), Link, Name,
406  Aliasee);
407 }
408 
410  return create(Aliasee->getLinkage(), Name, Aliasee);
411 }
412 
415 }
416 
419 }
420 
422  assert((!Aliasee || Aliasee->getType() == getType()) &&
423  "Alias and aliasee types should match!");
424  setIndirectSymbol(Aliasee);
425 }
426 
427 //===----------------------------------------------------------------------===//
428 // GlobalIFunc Implementation
429 //===----------------------------------------------------------------------===//
430 
431 GlobalIFunc::GlobalIFunc(Type *Ty, unsigned AddressSpace, LinkageTypes Link,
432  const Twine &Name, Constant *Resolver,
433  Module *ParentModule)
434  : GlobalIndirectSymbol(Ty, Value::GlobalIFuncVal, AddressSpace, Link, Name,
435  Resolver) {
436  if (ParentModule)
437  ParentModule->getIFuncList().push_back(this);
438 }
439 
440 GlobalIFunc *GlobalIFunc::create(Type *Ty, unsigned AddressSpace,
441  LinkageTypes Link, const Twine &Name,
442  Constant *Resolver, Module *ParentModule) {
443  return new GlobalIFunc(Ty, AddressSpace, Link, Name, Resolver, ParentModule);
444 }
445 
448 }
449 
452 }
void setVisibility(VisibilityTypes V)
Definition: GlobalValue.h:225
const NoneType None
Definition: None.h:23
LinkageTypes getLinkage() const
Definition: GlobalValue.h:429
VisibilityTypes getVisibility() const
Definition: GlobalValue.h:219
virtual 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
void dropAllReferences()
Drop all references to operands.
Definition: User.h:269
iterator erase(iterator where)
Definition: ilist.h:280
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
const GlobalListType & getGlobalList() const
Get the Module's list of global variables (constant).
Definition: Module.h:471
UnnamedAddr getUnnamedAddr() const
Definition: GlobalValue.h:200
Type * getValueType() const
Definition: GlobalValue.h:261
Metadata node.
Definition: Metadata.h:830
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:471
Type * getElementType() const
Definition: DerivedTypes.h:462
void setAlignment(unsigned Align)
Definition: Globals.cpp:86
const AliasListType & getAliasList() const
Get the Module's list of aliases (constant).
Definition: Module.h:485
bool canIncreaseAlignment() const
Definition: Globals.cpp:202
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:218
const IFuncListType & getIFuncList() const
Get the Module's list of ifuncs (constant).
Definition: Module.h:492
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:300
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:191
unsigned getGlobalObjectSubClassData() const
Definition: Globals.cpp:96
void setIndirectSymbol(Constant *Symbol)
These methods set and retrieve indirect symbol.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
bool hasDefaultVisibility() const
Definition: GlobalValue.h:220
void setInitializer(Constant *InitVal)
setInitializer - Sets the initializer for this global variable, removing any existing initializer if ...
Definition: Globals.cpp:323
void removeFromParent() final
This method unlinks 'this' from the containing module, but does not delete it.
Definition: Globals.cpp:446
bool hasSection() const
Definition: GlobalValue.h:255
void setThreadLocalMode(ThreadLocalMode Val)
Definition: GlobalValue.h:236
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:440
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
Definition: GlobalValue.h:509
static const unsigned MaximumAlignment
Definition: Value.h:550
void eraseFromParent() override
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
Definition: Globals.cpp:319
void setDLLStorageClass(DLLStorageClassTypes C)
Definition: GlobalValue.h:253
#define F(x, y, z)
Definition: MD5.cpp:51
unsigned getAlignment() const
Definition: GlobalObject.h:59
bool isMaterializable() const
If this function's Module is being lazily streamed in functions from disk or some other source...
Definition: Globals.cpp:45
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:275
Class to represent pointers.
Definition: DerivedTypes.h:443
bool hasSection() const
Check if this global has a custom object file section.
Definition: GlobalObject.h:73
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:42
This file contains the declarations for the subclasses of Constant, which represent the different fla...
void setExternallyInitialized(bool Val)
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:587
void removeFromParent() override
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it...
Definition: Globals.cpp:413
self_iterator getIterator()
Definition: ilist_node.h:81
void setGlobalVariableNumOperands(unsigned NumOps)
Set the number of operands on a GlobalVariable.
Definition: User.h:183
Error materialize()
Make sure this GlobalValue is fully read.
Definition: Globals.cpp:50
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
Definition: StringRef.h:225
DenseMap< const GlobalObject *, StringRef > GlobalObjectSections
Collection of per-GlobalObject sections used in this context.
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:654
#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:32
LLVMContextImpl *const pImpl
Definition: LLVMContext.h:50
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
Comdat * getComdat()
Definition: Globals.cpp:155
Optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns None...
Definition: Globals.cpp:259
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:230
AddressSpace
Definition: NVPTXBaseInfo.h:22
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:140
void copyAttributesFrom(const GlobalValue *Src) override
Copy all additional attributes (those not needed to create a GlobalValue) from the GlobalValue Src to...
Definition: Globals.cpp:108
ValueTy
Concrete subclass of this.
Definition: Value.h:415
unsigned Log2_32(uint32_t Value)
Log2_32 - This function returns the floor log base 2 of the specified value, -1 if the value is zero...
Definition: MathExtras.h:513
bool hasInitializer() const
Definitions have initializers, declarations don't.
void eraseFromParent() override
eraseFromParent - This method unlinks 'this' from the containing module and deletes it...
Definition: Globals.cpp:417
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
const GlobalObject * getBaseObject() const
Definition: GlobalValue.h:517
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:130
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
Definition: Metadata.cpp:1391
void dropAllReferences()
Drop all references in preparation to destroy the GlobalVariable.
Definition: Globals.cpp:354
unsigned getGlobalValueSubClassData() const
Definition: GlobalValue.h:149
pointer remove(iterator &IT)
Definition: ilist.h:264
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:259
iterator insert(iterator where, pointer New)
Definition: ilist.h:241
void setUnnamedAddr(UnnamedAddr Val)
Definition: GlobalValue.h:203
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition: Globals.cpp:188
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:409
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:287
void eraseFromParent() final
This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:450
bool hasLocalLinkage() const
Definition: GlobalValue.h:415
void copyAttributesFrom(const GlobalValue *Src) override
copyAttributesFrom - copy all additional attributes (those not needed to create a GlobalVariable) fro...
Definition: Globals.cpp:346
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
unsigned getAlignment() const
Definition: Globals.cpp:72
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:537
LLVM Value Representation.
Definition: Value.h:71
Lightweight error class with error context and mandatory checking.
GlobalIndirectSymbol(Type *Ty, ValueTy VTy, unsigned AddressSpace, LinkageTypes Linkage, const Twine &Name, Constant *Symbol)
Definition: Globals.cpp:363
DLLStorageClassTypes getDLLStorageClass() const
Definition: GlobalValue.h:244
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
void setSection(StringRef S)
Change the section for this global.
Definition: Globals.cpp:173
void setGlobalObjectSubClassData(unsigned Val)
Definition: Globals.cpp:101
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:384
void setAliasee(Constant *Aliasee)
These methods retrieve and set alias target.
Definition: Globals.cpp:421
StringSet SectionStrings
Stable collection of section strings.
bool isAbsoluteSymbolRef() const
Returns whether this is a reference to an absolute symbol.
Definition: Globals.cpp:251
void removeFromParent() override
removeFromParent - This method unlinks 'this' from the containing module, but does not delete it...
Definition: Globals.cpp:315
StringRef getSection() const
Definition: Globals.cpp:145