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