LLVM  7.0.0svn
GlobalValue.h
Go to the documentation of this file.
1 //===-- llvm/GlobalValue.h - Class to represent a global value --*- C++ -*-===//
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 is a common base class of all globally definable objects. As such,
11 // it is subclassed by GlobalVariable, GlobalAlias and by Function. This is
12 // used because you can do certain things with these global objects that you
13 // can't do to anything else. For example, use the address of one as a
14 // constant.
15 //
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef LLVM_IR_GLOBALVALUE_H
19 #define LLVM_IR_GLOBALVALUE_H
20 
21 #include "llvm/ADT/StringRef.h"
22 #include "llvm/ADT/Twine.h"
23 #include "llvm/IR/Constant.h"
24 #include "llvm/IR/DerivedTypes.h"
25 #include "llvm/IR/Value.h"
26 #include "llvm/Support/Casting.h"
28 #include "llvm/Support/MD5.h"
29 #include <cassert>
30 #include <cstdint>
31 #include <string>
32 
33 namespace llvm {
34 
35 class Comdat;
36 class ConstantRange;
37 class Error;
38 class GlobalObject;
39 class Module;
40 
41 namespace Intrinsic {
42  enum ID : unsigned;
43 } // end namespace Intrinsic
44 
45 class GlobalValue : public Constant {
46 public:
47  /// @brief An enumeration for the kinds of linkage for global values.
48  enum LinkageTypes {
49  ExternalLinkage = 0,///< Externally visible function
50  AvailableExternallyLinkage, ///< Available for inspection, not emission.
51  LinkOnceAnyLinkage, ///< Keep one copy of function when linking (inline)
52  LinkOnceODRLinkage, ///< Same, but only replaced by something equivalent.
53  WeakAnyLinkage, ///< Keep one copy of named function when linking (weak)
54  WeakODRLinkage, ///< Same, but only replaced by something equivalent.
55  AppendingLinkage, ///< Special purpose, only applies to global arrays
56  InternalLinkage, ///< Rename collisions when linking (static functions).
57  PrivateLinkage, ///< Like Internal, but omit from symbol table.
58  ExternalWeakLinkage,///< ExternalWeak linkage description.
59  CommonLinkage ///< Tentative definitions.
60  };
61 
62  /// @brief An enumeration for the kinds of visibility of global values.
64  DefaultVisibility = 0, ///< The GV is visible
65  HiddenVisibility, ///< The GV is hidden
66  ProtectedVisibility ///< The GV is protected
67  };
68 
69  /// @brief Storage classes of global values for PE targets.
71  DefaultStorageClass = 0,
72  DLLImportStorageClass = 1, ///< Function to be imported from DLL
73  DLLExportStorageClass = 2 ///< Function to be accessible from DLL.
74  };
75 
76 protected:
77  GlobalValue(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps,
78  LinkageTypes Linkage, const Twine &Name, unsigned AddressSpace)
79  : Constant(PointerType::get(Ty, AddressSpace), VTy, Ops, NumOps),
80  ValueType(Ty), Visibility(DefaultVisibility),
81  UnnamedAddrVal(unsigned(UnnamedAddr::None)),
82  DllStorageClass(DefaultStorageClass), ThreadLocal(NotThreadLocal),
83  HasLLVMReservedName(false), IsDSOLocal(false), IntID((Intrinsic::ID)0U),
84  Parent(nullptr) {
85  setLinkage(Linkage);
86  setName(Name);
87  }
88 
90 
91  static const unsigned GlobalValueSubClassDataBits = 17;
92 
93  // All bitfields use unsigned as the underlying type so that MSVC will pack
94  // them.
95  unsigned Linkage : 4; // The linkage of this global
96  unsigned Visibility : 2; // The visibility style of this global
97  unsigned UnnamedAddrVal : 2; // This value's address is not significant
98  unsigned DllStorageClass : 2; // DLL storage class
99 
100  unsigned ThreadLocal : 3; // Is this symbol "Thread Local", if so, what is
101  // the desired model?
102 
103  /// True if the function's name starts with "llvm.". This corresponds to the
104  /// value of Function::isIntrinsic(), which may be true even if
105  /// Function::intrinsicID() returns Intrinsic::not_intrinsic.
106  unsigned HasLLVMReservedName : 1;
107 
108  /// If true then there is a definition within the same linkage unit and that
109  /// definition cannot be runtime preempted.
110  unsigned IsDSOLocal : 1;
111 
112 private:
113  friend class Constant;
114 
115  void maybeSetDsoLocal() {
116  if (hasLocalLinkage() ||
117  (!hasDefaultVisibility() && !hasExternalWeakLinkage()))
118  setDSOLocal(true);
119  }
120 
121  // Give subclasses access to what otherwise would be wasted padding.
122  // (17 + 4 + 2 + 2 + 2 + 3 + 1 + 1) == 32.
123  unsigned SubClassData : GlobalValueSubClassDataBits;
124 
125  void destroyConstantImpl();
126  Value *handleOperandChangeImpl(Value *From, Value *To);
127 
128  /// Returns true if the definition of this global may be replaced by a
129  /// differently optimized variant of the same source level function at link
130  /// time.
131  bool mayBeDerefined() const {
132  switch (getLinkage()) {
133  case WeakODRLinkage:
134  case LinkOnceODRLinkage:
135  case AvailableExternallyLinkage:
136  return true;
137 
138  case WeakAnyLinkage:
139  case LinkOnceAnyLinkage:
140  case CommonLinkage:
141  case ExternalWeakLinkage:
142  case ExternalLinkage:
143  case AppendingLinkage:
144  case InternalLinkage:
145  case PrivateLinkage:
146  return isInterposable();
147  }
148 
149  llvm_unreachable("Fully covered switch above!");
150  }
151 
152 protected:
153  /// \brief The intrinsic ID for this subclass (which must be a Function).
154  ///
155  /// This member is defined by this class, but not used for anything.
156  /// Subclasses can use it to store their intrinsic ID, if they have one.
157  ///
158  /// This is stored here to save space in Function on 64-bit hosts.
160 
161  unsigned getGlobalValueSubClassData() const {
162  return SubClassData;
163  }
164  void setGlobalValueSubClassData(unsigned V) {
165  assert(V < (1 << GlobalValueSubClassDataBits) && "It will not fit");
166  SubClassData = V;
167  }
168 
169  Module *Parent; // The containing module.
170 
171  // Used by SymbolTableListTraits.
172  void setParent(Module *parent) {
173  Parent = parent;
174  }
175 
177  removeDeadConstantUsers(); // remove any dead constants using this.
178  }
179 
180 public:
182  NotThreadLocal = 0,
186  LocalExecTLSModel
187  };
188 
189  GlobalValue(const GlobalValue &) = delete;
190 
191  unsigned getAlignment() const;
192 
193  enum class UnnamedAddr {
194  None,
195  Local,
196  Global,
197  };
198 
199  bool hasGlobalUnnamedAddr() const {
200  return getUnnamedAddr() == UnnamedAddr::Global;
201  }
202 
203  /// Returns true if this value's address is not significant in this module.
204  /// This attribute is intended to be used only by the code generator and LTO
205  /// to allow the linker to decide whether the global needs to be in the symbol
206  /// table. It should probably not be used in optimizations, as the value may
207  /// have uses outside the module; use hasGlobalUnnamedAddr() instead.
209  return getUnnamedAddr() != UnnamedAddr::None;
210  }
211 
213  return UnnamedAddr(UnnamedAddrVal);
214  }
215  void setUnnamedAddr(UnnamedAddr Val) { UnnamedAddrVal = unsigned(Val); }
216 
218  if (A == UnnamedAddr::None || B == UnnamedAddr::None)
219  return UnnamedAddr::None;
220  if (A == UnnamedAddr::Local || B == UnnamedAddr::Local)
221  return UnnamedAddr::Local;
222  return UnnamedAddr::Global;
223  }
224 
225  bool hasComdat() const { return getComdat() != nullptr; }
226  const Comdat *getComdat() const;
228  return const_cast<Comdat *>(
229  static_cast<const GlobalValue *>(this)->getComdat());
230  }
231 
233  bool hasDefaultVisibility() const { return Visibility == DefaultVisibility; }
234  bool hasHiddenVisibility() const { return Visibility == HiddenVisibility; }
235  bool hasProtectedVisibility() const {
236  return Visibility == ProtectedVisibility;
237  }
239  assert((!hasLocalLinkage() || V == DefaultVisibility) &&
240  "local linkage requires default visibility");
241  Visibility = V;
242  maybeSetDsoLocal();
243  }
244 
245  /// If the value is "Thread Local", its value isn't shared by the threads.
246  bool isThreadLocal() const { return getThreadLocalMode() != NotThreadLocal; }
247  void setThreadLocal(bool Val) {
248  setThreadLocalMode(Val ? GeneralDynamicTLSModel : NotThreadLocal);
249  }
251  assert(Val == NotThreadLocal || getValueID() != Value::FunctionVal);
252  ThreadLocal = Val;
253  }
255  return static_cast<ThreadLocalMode>(ThreadLocal);
256  }
257 
259  return DLLStorageClassTypes(DllStorageClass);
260  }
262  return DllStorageClass == DLLImportStorageClass;
263  }
265  return DllStorageClass == DLLExportStorageClass;
266  }
267  void setDLLStorageClass(DLLStorageClassTypes C) { DllStorageClass = C; }
268 
269  bool hasSection() const { return !getSection().empty(); }
270  StringRef getSection() const;
271 
272  /// Global values are always pointers.
273  PointerType *getType() const { return cast<PointerType>(User::getType()); }
274 
275  Type *getValueType() const { return ValueType; }
276 
277  void setDSOLocal(bool Local) { IsDSOLocal = Local; }
278 
279  bool isDSOLocal() const {
280  return IsDSOLocal;
281  }
282 
283  static LinkageTypes getLinkOnceLinkage(bool ODR) {
284  return ODR ? LinkOnceODRLinkage : LinkOnceAnyLinkage;
285  }
286  static LinkageTypes getWeakLinkage(bool ODR) {
287  return ODR ? WeakODRLinkage : WeakAnyLinkage;
288  }
289 
290  static bool isExternalLinkage(LinkageTypes Linkage) {
291  return Linkage == ExternalLinkage;
292  }
294  return Linkage == AvailableExternallyLinkage;
295  }
296  static bool isLinkOnceODRLinkage(LinkageTypes Linkage) {
297  return Linkage == LinkOnceODRLinkage;
298  }
299  static bool isLinkOnceLinkage(LinkageTypes Linkage) {
300  return Linkage == LinkOnceAnyLinkage || Linkage == LinkOnceODRLinkage;
301  }
302  static bool isWeakAnyLinkage(LinkageTypes Linkage) {
303  return Linkage == WeakAnyLinkage;
304  }
305  static bool isWeakODRLinkage(LinkageTypes Linkage) {
306  return Linkage == WeakODRLinkage;
307  }
308  static bool isWeakLinkage(LinkageTypes Linkage) {
309  return isWeakAnyLinkage(Linkage) || isWeakODRLinkage(Linkage);
310  }
311  static bool isAppendingLinkage(LinkageTypes Linkage) {
312  return Linkage == AppendingLinkage;
313  }
314  static bool isInternalLinkage(LinkageTypes Linkage) {
315  return Linkage == InternalLinkage;
316  }
317  static bool isPrivateLinkage(LinkageTypes Linkage) {
318  return Linkage == PrivateLinkage;
319  }
320  static bool isLocalLinkage(LinkageTypes Linkage) {
321  return isInternalLinkage(Linkage) || isPrivateLinkage(Linkage);
322  }
323  static bool isExternalWeakLinkage(LinkageTypes Linkage) {
324  return Linkage == ExternalWeakLinkage;
325  }
326  static bool isCommonLinkage(LinkageTypes Linkage) {
327  return Linkage == CommonLinkage;
328  }
330  return isExternalWeakLinkage(Linkage) || isExternalLinkage(Linkage);
331  }
332 
333  /// Whether the definition of this global may be replaced by something
334  /// non-equivalent at link time. For example, if a function has weak linkage
335  /// then the code defining it may be replaced by different code.
336  static bool isInterposableLinkage(LinkageTypes Linkage) {
337  switch (Linkage) {
338  case WeakAnyLinkage:
339  case LinkOnceAnyLinkage:
340  case CommonLinkage:
341  case ExternalWeakLinkage:
342  return true;
343 
344  case AvailableExternallyLinkage:
345  case LinkOnceODRLinkage:
346  case WeakODRLinkage:
347  // The above three cannot be overridden but can be de-refined.
348 
349  case ExternalLinkage:
350  case AppendingLinkage:
351  case InternalLinkage:
352  case PrivateLinkage:
353  return false;
354  }
355  llvm_unreachable("Fully covered switch above!");
356  }
357 
358  /// Whether the definition of this global may be discarded if it is not used
359  /// in its compilation unit.
360  static bool isDiscardableIfUnused(LinkageTypes Linkage) {
361  return isLinkOnceLinkage(Linkage) || isLocalLinkage(Linkage) ||
362  isAvailableExternallyLinkage(Linkage);
363  }
364 
365  /// Whether the definition of this global may be replaced at link time. NB:
366  /// Using this method outside of the code generators is almost always a
367  /// mistake: when working at the IR level use isInterposable instead as it
368  /// knows about ODR semantics.
369  static bool isWeakForLinker(LinkageTypes Linkage) {
370  return Linkage == WeakAnyLinkage || Linkage == WeakODRLinkage ||
371  Linkage == LinkOnceAnyLinkage || Linkage == LinkOnceODRLinkage ||
372  Linkage == CommonLinkage || Linkage == ExternalWeakLinkage;
373  }
374 
375  /// Return true if the currently visible definition of this global (if any) is
376  /// exactly the definition we will see at runtime.
377  ///
378  /// Non-exact linkage types inhibits most non-inlining IPO, since a
379  /// differently optimized variant of the same function can have different
380  /// observable or undefined behavior than in the variant currently visible.
381  /// For instance, we could have started with
382  ///
383  /// void foo(int *v) {
384  /// int t = 5 / v[0];
385  /// (void) t;
386  /// }
387  ///
388  /// and "refined" it to
389  ///
390  /// void foo(int *v) { }
391  ///
392  /// However, we cannot infer readnone for `foo`, since that would justify
393  /// DSE'ing a store to `v[0]` across a call to `foo`, which can cause
394  /// undefined behavior if the linker replaces the actual call destination with
395  /// the unoptimized `foo`.
396  ///
397  /// Inlining is okay across non-exact linkage types as long as they're not
398  /// interposable (see \c isInterposable), since in such cases the currently
399  /// visible variant is *a* correct implementation of the original source
400  /// function; it just isn't the *only* correct implementation.
401  bool isDefinitionExact() const {
402  return !mayBeDerefined();
403  }
404 
405  /// Return true if this global has an exact defintion.
406  bool hasExactDefinition() const {
407  // While this computes exactly the same thing as
408  // isStrongDefinitionForLinker, the intended uses are different. This
409  // function is intended to help decide if specific inter-procedural
410  // transforms are correct, while isStrongDefinitionForLinker's intended use
411  // is in low level code generation.
412  return !isDeclaration() && isDefinitionExact();
413  }
414 
415  /// Return true if this global's definition can be substituted with an
416  /// *arbitrary* definition at link time. We cannot do any IPO or inlinining
417  /// across interposable call edges, since the callee can be replaced with
418  /// something arbitrary at link time.
419  bool isInterposable() const { return isInterposableLinkage(getLinkage()); }
420 
421  bool hasExternalLinkage() const { return isExternalLinkage(getLinkage()); }
423  return isAvailableExternallyLinkage(getLinkage());
424  }
425  bool hasLinkOnceLinkage() const { return isLinkOnceLinkage(getLinkage()); }
426  bool hasLinkOnceODRLinkage() const {
427  return isLinkOnceODRLinkage(getLinkage());
428  }
429  bool hasWeakLinkage() const { return isWeakLinkage(getLinkage()); }
430  bool hasWeakAnyLinkage() const { return isWeakAnyLinkage(getLinkage()); }
431  bool hasWeakODRLinkage() const { return isWeakODRLinkage(getLinkage()); }
432  bool hasAppendingLinkage() const { return isAppendingLinkage(getLinkage()); }
433  bool hasInternalLinkage() const { return isInternalLinkage(getLinkage()); }
434  bool hasPrivateLinkage() const { return isPrivateLinkage(getLinkage()); }
435  bool hasLocalLinkage() const { return isLocalLinkage(getLinkage()); }
436  bool hasExternalWeakLinkage() const {
437  return isExternalWeakLinkage(getLinkage());
438  }
439  bool hasCommonLinkage() const { return isCommonLinkage(getLinkage()); }
441  return isValidDeclarationLinkage(getLinkage());
442  }
443 
445  if (isLocalLinkage(LT))
446  Visibility = DefaultVisibility;
447  Linkage = LT;
448  maybeSetDsoLocal();
449  }
450  LinkageTypes getLinkage() const { return LinkageTypes(Linkage); }
451 
452  bool isDiscardableIfUnused() const {
453  return isDiscardableIfUnused(getLinkage());
454  }
455 
456  bool isWeakForLinker() const { return isWeakForLinker(getLinkage()); }
457 
458 protected:
459  /// Copy all additional attributes (those not needed to create a GlobalValue)
460  /// from the GlobalValue Src to this one.
461  void copyAttributesFrom(const GlobalValue *Src);
462 
463 public:
464  /// If the given string begins with the GlobalValue name mangling escape
465  /// character '\1', drop it.
466  ///
467  /// This function applies a specific mangling that is used in PGO profiles,
468  /// among other things. If you're trying to get a symbol name for an
469  /// arbitrary GlobalValue, this is not the function you're looking for; see
470  /// Mangler.h.
472  if (!Name.empty() && Name[0] == '\1')
473  return Name.substr(1);
474  return Name;
475  }
476 
477  /// Return the modified name for a global value suitable to be
478  /// used as the key for a global lookup (e.g. profile or ThinLTO).
479  /// The value's original name is \c Name and has linkage of type
480  /// \c Linkage. The value is defined in module \c FileName.
481  static std::string getGlobalIdentifier(StringRef Name,
483  StringRef FileName);
484 
485  /// Return the modified name for this global value suitable to be
486  /// used as the key for a global lookup (e.g. profile or ThinLTO).
487  std::string getGlobalIdentifier() const;
488 
489  /// Declare a type to represent a global unique identifier for a global value.
490  /// This is a 64 bits hash that is used by PGO and ThinLTO to have a compact
491  /// unique way to identify a symbol.
492  using GUID = uint64_t;
493 
494  /// Return a 64-bit global unique ID constructed from global value name
495  /// (i.e. returned by getGlobalIdentifier()).
496  static GUID getGUID(StringRef GlobalName) { return MD5Hash(GlobalName); }
497 
498  /// Return a 64-bit global unique ID constructed from global value name
499  /// (i.e. returned by getGlobalIdentifier()).
500  GUID getGUID() const { return getGUID(getGlobalIdentifier()); }
501 
502  /// @name Materialization
503  /// Materialization is used to construct functions only as they're needed.
504  /// This
505  /// is useful to reduce memory usage in LLVM or parsing work done by the
506  /// BitcodeReader to load the Module.
507  /// @{
508 
509  /// If this function's Module is being lazily streamed in functions from disk
510  /// or some other source, this method can be used to check to see if the
511  /// function has been read in yet or not.
512  bool isMaterializable() const;
513 
514  /// Make sure this GlobalValue is fully read.
515  Error materialize();
516 
517 /// @}
518 
519  /// Return true if the primary definition of this global value is outside of
520  /// the current translation unit.
521  bool isDeclaration() const;
522 
523  bool isDeclarationForLinker() const {
524  if (hasAvailableExternallyLinkage())
525  return true;
526 
527  return isDeclaration();
528  }
529 
530  /// Returns true if this global's definition will be the one chosen by the
531  /// linker.
532  ///
533  /// NB! Ideally this should not be used at the IR level at all. If you're
534  /// interested in optimization constraints implied by the linker's ability to
535  /// choose an implementation, prefer using \c hasExactDefinition.
537  return !(isDeclarationForLinker() || isWeakForLinker());
538  }
539 
540  // Returns true if the alignment of the value can be unilaterally
541  // increased.
542  bool canIncreaseAlignment() const;
543 
544  const GlobalObject *getBaseObject() const;
546  return const_cast<GlobalObject *>(
547  static_cast<const GlobalValue *>(this)->getBaseObject());
548  }
549 
550  /// Returns whether this is a reference to an absolute symbol.
551  bool isAbsoluteSymbolRef() const;
552 
553  /// If this is an absolute symbol reference, returns the range of the symbol,
554  /// otherwise returns None.
555  Optional<ConstantRange> getAbsoluteSymbolRange() const;
556 
557  /// This method unlinks 'this' from the containing module, but does not delete
558  /// it.
559  void removeFromParent();
560 
561  /// This method unlinks 'this' from the containing module and deletes it.
562  void eraseFromParent();
563 
564  /// Get the module that this global value is contained inside of...
565  Module *getParent() { return Parent; }
566  const Module *getParent() const { return Parent; }
567 
568  // Methods for support type inquiry through isa, cast, and dyn_cast:
569  static bool classof(const Value *V) {
570  return V->getValueID() == Value::FunctionVal ||
571  V->getValueID() == Value::GlobalVariableVal ||
572  V->getValueID() == Value::GlobalAliasVal ||
573  V->getValueID() == Value::GlobalIFuncVal;
574  }
575 
576  /// True if GV can be left out of the object symbol table. This is the case
577  /// for linkonce_odr values whose address is not significant. While legal, it
578  /// is not normally profitable to omit them from the .o symbol table. Using
579  /// this analysis makes sense when the information can be passed down to the
580  /// linker or we are in LTO.
581  bool canBeOmittedFromSymbolTable() const;
582 };
583 
584 } // end namespace llvm
585 
586 #endif // LLVM_IR_GLOBALVALUE_H
void setVisibility(VisibilityTypes V)
Definition: GlobalValue.h:238
static bool isInterposableLinkage(LinkageTypes Linkage)
Whether the definition of this global may be replaced by something non-equivalent at link time...
Definition: GlobalValue.h:336
bool isDeclarationForLinker() const
Definition: GlobalValue.h:523
const NoneType None
Definition: None.h:24
uint64_t CallInst * C
ThreadLocalMode getThreadLocalMode() const
Definition: GlobalValue.h:254
bool hasDLLExportStorageClass() const
Definition: GlobalValue.h:264
bool hasLocalLinkage() const
Definition: GlobalValue.h:435
Special purpose, only applies to global arrays.
Definition: GlobalValue.h:55
PointerUnion< const Value *, const PseudoSourceValue * > ValueType
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:469
bool hasPrivateLinkage() const
Definition: GlobalValue.h:434
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Definition: GlobalValue.h:492
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
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:54
ThreadLocal - A class used to abstract thread-local storage.
Definition: ThreadLocal.h:46
static bool isExternalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:290
Available for inspection, not emission.
Definition: GlobalValue.h:50
unsigned UnnamedAddrVal
Definition: GlobalValue.h:97
bool hasAvailableExternallyLinkage() const
Definition: GlobalValue.h:422
uint64_t MD5Hash(StringRef Str)
Helper to compute and return lower 64 bits of the given string&#39;s MD5 hash.
Definition: MD5.h:109
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:57
static bool isWeakAnyLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:302
static bool isCommonLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:326
bool isInterposable() const
Return true if this global&#39;s definition can be substituted with an arbitrary definition at link time...
Definition: GlobalValue.h:419
bool hasDLLImportStorageClass() const
Definition: GlobalValue.h:261
ELFYAML::ELF_STV Visibility
Definition: ELFYAML.cpp:766
bool hasExternalWeakLinkage() const
Definition: GlobalValue.h:436
bool hasWeakAnyLinkage() const
Definition: GlobalValue.h:430
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:320
static bool isLinkOnceLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:299
void setParent(Module *parent)
Definition: GlobalValue.h:172
bool hasSection() const
Definition: GlobalValue.h:269
static uint32_t getAlignment(const MCSectionCOFF &Sec)
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
bool isDSOLocal() const
Definition: GlobalValue.h:279
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
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
unsigned IsDSOLocal
If true then there is a definition within the same linkage unit and that definition cannot be runtime...
Definition: GlobalValue.h:110
void setDLLStorageClass(DLLStorageClassTypes C)
Definition: GlobalValue.h:267
bool hasCommonLinkage() const
Definition: GlobalValue.h:439
Expected< const typename ELFT::Shdr * > getSection(typename ELFT::ShdrRange Sections, uint32_t Index)
Definition: ELF.h:257
static bool isLinkOnceODRLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:296
bool hasValidDeclarationLinkage() const
Definition: GlobalValue.h:440
bool hasExternalLinkage() const
Definition: GlobalValue.h:421
static bool isPrivateLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:317
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:245
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Definition: GlobalValue.h:63
unsigned DllStorageClass
Definition: GlobalValue.h:98
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:133
static bool isAppendingLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:311
LinkageTypes getLinkage() const
Definition: GlobalValue.h:450
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
bool hasLinkOnceLinkage() const
Definition: GlobalValue.h:425
Class to represent pointers.
Definition: DerivedTypes.h:467
bool hasAppendingLinkage() const
Definition: GlobalValue.h:432
static bool isWeakForLinker(LinkageTypes Linkage)
Whether the definition of this global may be replaced at link time.
Definition: GlobalValue.h:369
ExternalWeak linkage description.
Definition: GlobalValue.h:58
bool hasLinkOnceODRLinkage() const
Definition: GlobalValue.h:426
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:52
static bool isInternalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:314
bool hasProtectedVisibility() const
Definition: GlobalValue.h:235
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
DLLStorageClassTypes getDLLStorageClass() const
Definition: GlobalValue.h:258
VisibilityTypes getVisibility() const
Definition: GlobalValue.h:232
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
static bool isWeakODRLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:305
static bool classof(const Value *V)
Definition: GlobalValue.h:569
GlobalObject * getBaseObject()
Definition: GlobalValue.h:545
This is an important base class in LLVM.
Definition: Constant.h:42
bool isWeakForLinker() const
Definition: GlobalValue.h:456
bool hasInternalLinkage() const
Definition: GlobalValue.h:433
static bool isDiscardableIfUnused(LinkageTypes Linkage)
Whether the definition of this global may be discarded if it is not used in its compilation unit...
Definition: GlobalValue.h:360
Comdat * getComdat()
Definition: GlobalValue.h:227
DLLStorageClassTypes
Storage classes of global values for PE targets.
Definition: GlobalValue.h:70
GlobalValue(Type *Ty, ValueTy VTy, Use *Ops, unsigned NumOps, LinkageTypes Linkage, const Twine &Name, unsigned AddressSpace)
Definition: GlobalValue.h:77
Intrinsic::ID IntID
The intrinsic ID for this subclass (which must be a Function).
Definition: GlobalValue.h:159
unsigned getGlobalValueSubClassData() const
Definition: GlobalValue.h:161
static GUID getGUID(StringRef GlobalName)
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:496
bool hasWeakODRLinkage() const
Definition: GlobalValue.h:431
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static LinkageTypes getWeakLinkage(bool ODR)
Definition: GlobalValue.h:286
bool hasWeakLinkage() const
Definition: GlobalValue.h:429
bool isDefinitionExact() const
Return true if the currently visible definition of this global (if any) is exactly the definition we ...
Definition: GlobalValue.h:401
bool isDiscardableIfUnused() const
Definition: GlobalValue.h:452
static bool isWeakLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:308
bool hasComdat() const
Definition: GlobalValue.h:225
Keep one copy of function when linking (inline)
Definition: GlobalValue.h:51
AddressSpace
Definition: NVPTXBaseInfo.h:22
static bool isAvailableExternallyLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:293
unsigned Linkage
Definition: GlobalValue.h:95
bool hasGlobalUnnamedAddr() const
Definition: GlobalValue.h:199
ValueTy
Concrete subclass of this.
Definition: Value.h:450
void setLinkage(LinkageTypes LT)
Definition: GlobalValue.h:444
static bool isExternalWeakLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:323
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character &#39;\1&#39;, drop it.
Definition: GlobalValue.h:471
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition: GlobalValue.h:48
void setGlobalValueSubClassData(unsigned V)
Definition: GlobalValue.h:164
unsigned ThreadLocal
Definition: GlobalValue.h:100
unsigned HasLLVMReservedName
True if the function&#39;s name starts with "llvm.".
Definition: GlobalValue.h:106
bool hasHiddenVisibility() const
Definition: GlobalValue.h:234
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:500
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
bool hasExactDefinition() const
Return true if this global has an exact defintion.
Definition: GlobalValue.h:406
unsigned Visibility
Definition: GlobalValue.h:96
Type * getValueType() const
Definition: GlobalValue.h:275
Keep one copy of named function when linking (weak)
Definition: GlobalValue.h:53
Rename collisions when linking (static functions).
Definition: GlobalValue.h:56
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:73
static LinkageTypes getLinkOnceLinkage(bool ODR)
Definition: GlobalValue.h:283
void setThreadLocal(bool Val)
Definition: GlobalValue.h:247
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
bool hasDefaultVisibility() const
Definition: GlobalValue.h:233
bool isThreadLocal() const
If the value is "Thread Local", its value isn&#39;t shared by the threads.
Definition: GlobalValue.h:246
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
static UnnamedAddr getMinUnnamedAddr(UnnamedAddr A, UnnamedAddr B)
Definition: GlobalValue.h:217
static bool isValidDeclarationLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:329
void setDSOLocal(bool Local)
Definition: GlobalValue.h:277
const Module * getParent() const
Definition: GlobalValue.h:566
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:273
A discriminated union of two pointer types, with the discriminator in the low bit of the pointer...
Definition: PointerUnion.h:87