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