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