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