LLVM  15.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)),
85  setName(Name);
86  }
87 
89 
90  static const unsigned GlobalValueSubClassDataBits = 15;
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  /// True if this symbol has sanitizer metadata available. Should only happen
116  /// if sanitizers were enabled when building the translation unit which
117  /// contains this GV.
118  unsigned HasSanitizerMetadata : 1;
119 
120 private:
121  // Give subclasses access to what otherwise would be wasted padding.
122  // (15 + 4 + 2 + 2 + 2 + 3 + 1 + 1 + 1 + 1) == 32.
123  unsigned SubClassData : GlobalValueSubClassDataBits;
124 
125  friend class Constant;
126 
127  void destroyConstantImpl();
128  Value *handleOperandChangeImpl(Value *From, Value *To);
129 
130  /// Returns true if the definition of this global may be replaced by a
131  /// differently optimized variant of the same source level function at link
132  /// time.
133  bool mayBeDerefined() const {
134  switch (getLinkage()) {
135  case WeakODRLinkage:
136  case LinkOnceODRLinkage:
138  return true;
139 
140  case WeakAnyLinkage:
141  case LinkOnceAnyLinkage:
142  case CommonLinkage:
143  case ExternalWeakLinkage:
144  case ExternalLinkage:
145  case AppendingLinkage:
146  case InternalLinkage:
147  case PrivateLinkage:
148  return isInterposable();
149  }
150 
151  llvm_unreachable("Fully covered switch above!");
152  }
153 
154 protected:
155  /// The intrinsic ID for this subclass (which must be a Function).
156  ///
157  /// This member is defined by this class, but not used for anything.
158  /// Subclasses can use it to store their intrinsic ID, if they have one.
159  ///
160  /// This is stored here to save space in Function on 64-bit hosts.
162 
163  unsigned getGlobalValueSubClassData() const {
164  return SubClassData;
165  }
166  void setGlobalValueSubClassData(unsigned V) {
167  assert(V < (1 << GlobalValueSubClassDataBits) && "It will not fit");
168  SubClassData = V;
169  }
170 
171  Module *Parent = nullptr; // The containing module.
172 
173  // Used by SymbolTableListTraits.
174  void setParent(Module *parent) {
175  Parent = parent;
176  }
177 
179  removeDeadConstantUsers(); // remove any dead constants using this.
180  }
181 
182 public:
189  };
190 
191  GlobalValue(const GlobalValue &) = delete;
192 
193  unsigned getAddressSpace() const;
194 
195  enum class UnnamedAddr {
196  None,
197  Local,
198  Global,
199  };
200 
201  bool hasGlobalUnnamedAddr() const {
203  }
204 
205  /// Returns true if this value's address is not significant in this module.
206  /// This attribute is intended to be used only by the code generator and LTO
207  /// to allow the linker to decide whether the global needs to be in the symbol
208  /// table. It should probably not be used in optimizations, as the value may
209  /// have uses outside the module; use hasGlobalUnnamedAddr() instead.
211  return getUnnamedAddr() != UnnamedAddr::None;
212  }
213 
215  return UnnamedAddr(UnnamedAddrVal);
216  }
217  void setUnnamedAddr(UnnamedAddr Val) { UnnamedAddrVal = unsigned(Val); }
218 
220  if (A == UnnamedAddr::None || B == UnnamedAddr::None)
221  return UnnamedAddr::None;
222  if (A == UnnamedAddr::Local || B == UnnamedAddr::Local)
223  return UnnamedAddr::Local;
224  return UnnamedAddr::Global;
225  }
226 
227  bool hasComdat() const { return getComdat() != nullptr; }
228  const Comdat *getComdat() const;
230  return const_cast<Comdat *>(
231  static_cast<const GlobalValue *>(this)->getComdat());
232  }
233 
236  bool hasHiddenVisibility() const { return Visibility == HiddenVisibility; }
237  bool hasProtectedVisibility() const {
239  }
242  "local linkage requires default visibility");
243  Visibility = V;
244  if (isImplicitDSOLocal())
245  setDSOLocal(true);
246  }
247 
248  /// If the value is "Thread Local", its value isn't shared by the threads.
249  bool isThreadLocal() const { return getThreadLocalMode() != NotThreadLocal; }
250  void setThreadLocal(bool Val) {
252  }
254  assert(Val == NotThreadLocal || getValueID() != Value::FunctionVal);
255  ThreadLocal = Val;
256  }
258  return static_cast<ThreadLocalMode>(ThreadLocal);
259  }
260 
263  }
266  }
269  }
271 
272  bool hasSection() const { return !getSection().empty(); }
273  StringRef getSection() const;
274 
275  /// Global values are always pointers.
276  PointerType *getType() const { return cast<PointerType>(User::getType()); }
277 
278  Type *getValueType() const { return ValueType; }
279 
280  bool isImplicitDSOLocal() const {
281  return hasLocalLinkage() ||
283  }
284 
285  void setDSOLocal(bool Local) { IsDSOLocal = Local; }
286 
287  bool isDSOLocal() const {
288  return IsDSOLocal;
289  }
290 
291  bool hasPartition() const {
292  return HasPartition;
293  }
294  StringRef getPartition() const;
295  void setPartition(StringRef Part);
296 
297  // ASan, HWASan and Memtag sanitizers have some instrumentation that applies
298  // specifically to global variables. This instrumentation is implicitly
299  // applied to all global variables when built with -fsanitize=*. What we need
300  // is a way to persist the information that a certain global variable should
301  // *not* have sanitizers applied, which occurs if:
302  // 1. The global variable is in the sanitizer ignore list, or
303  // 2. The global variable is created by the sanitizers itself for internal
304  // usage, or
305  // 3. The global variable has __attribute__((no_sanitize("..."))) or
306  // __attribute__((disable_sanitizer_instrumentation)).
307  //
308  // This is important, a some IR passes like GlobalMerge can delete global
309  // variables and replace them with new ones. If the old variables were marked
310  // to be unsanitized, then the new ones should also be.
314  IsDynInit(false) {}
315  unsigned NoAddress : 1;
316  unsigned NoHWAddress : 1;
317  unsigned NoMemtag : 1;
318 
319  // ASan-specific metadata. Is this global variable dynamically initialized
320  // (from a C++ language perspective), and should therefore be checked for
321  // ODR violations.
322  unsigned IsDynInit : 1;
323  };
324 
327  // Note: Not byref as it's a POD and otherwise it's too easy to call
328  // G.setSanitizerMetadata(G2.getSanitizerMetadata()), and the argument becomes
329  // dangling when the backing storage allocates the metadata for `G`, as the
330  // storage is shared between `G1` and `G2`.
333 
334  static LinkageTypes getLinkOnceLinkage(bool ODR) {
335  return ODR ? LinkOnceODRLinkage : LinkOnceAnyLinkage;
336  }
337  static LinkageTypes getWeakLinkage(bool ODR) {
338  return ODR ? WeakODRLinkage : WeakAnyLinkage;
339  }
340 
342  return Linkage == ExternalLinkage;
343  }
346  }
348  return Linkage == LinkOnceAnyLinkage;
349  }
351  return Linkage == LinkOnceODRLinkage;
352  }
355  }
357  return Linkage == WeakAnyLinkage;
358  }
360  return Linkage == WeakODRLinkage;
361  }
364  }
366  return Linkage == AppendingLinkage;
367  }
369  return Linkage == InternalLinkage;
370  }
372  return Linkage == PrivateLinkage;
373  }
376  }
378  return Linkage == ExternalWeakLinkage;
379  }
381  return Linkage == CommonLinkage;
382  }
385  }
386 
387  /// Whether the definition of this global may be replaced by something
388  /// non-equivalent at link time. For example, if a function has weak linkage
389  /// then the code defining it may be replaced by different code.
391  switch (Linkage) {
392  case WeakAnyLinkage:
393  case LinkOnceAnyLinkage:
394  case CommonLinkage:
395  case ExternalWeakLinkage:
396  return true;
397 
399  case LinkOnceODRLinkage:
400  case WeakODRLinkage:
401  // The above three cannot be overridden but can be de-refined.
402 
403  case ExternalLinkage:
404  case AppendingLinkage:
405  case InternalLinkage:
406  case PrivateLinkage:
407  return false;
408  }
409  llvm_unreachable("Fully covered switch above!");
410  }
411 
412  /// Whether the definition of this global may be discarded if it is not used
413  /// in its compilation unit.
417  }
418 
419  /// Whether the definition of this global may be replaced at link time. NB:
420  /// Using this method outside of the code generators is almost always a
421  /// mistake: when working at the IR level use isInterposable instead as it
422  /// knows about ODR semantics.
424  return Linkage == WeakAnyLinkage || Linkage == WeakODRLinkage ||
427  }
428 
429  /// Return true if the currently visible definition of this global (if any) is
430  /// exactly the definition we will see at runtime.
431  ///
432  /// Non-exact linkage types inhibits most non-inlining IPO, since a
433  /// differently optimized variant of the same function can have different
434  /// observable or undefined behavior than in the variant currently visible.
435  /// For instance, we could have started with
436  ///
437  /// void foo(int *v) {
438  /// int t = 5 / v[0];
439  /// (void) t;
440  /// }
441  ///
442  /// and "refined" it to
443  ///
444  /// void foo(int *v) { }
445  ///
446  /// However, we cannot infer readnone for `foo`, since that would justify
447  /// DSE'ing a store to `v[0]` across a call to `foo`, which can cause
448  /// undefined behavior if the linker replaces the actual call destination with
449  /// the unoptimized `foo`.
450  ///
451  /// Inlining is okay across non-exact linkage types as long as they're not
452  /// interposable (see \c isInterposable), since in such cases the currently
453  /// visible variant is *a* correct implementation of the original source
454  /// function; it just isn't the *only* correct implementation.
455  bool isDefinitionExact() const {
456  return !mayBeDerefined();
457  }
458 
459  /// Return true if this global has an exact defintion.
460  bool hasExactDefinition() const {
461  // While this computes exactly the same thing as
462  // isStrongDefinitionForLinker, the intended uses are different. This
463  // function is intended to help decide if specific inter-procedural
464  // transforms are correct, while isStrongDefinitionForLinker's intended use
465  // is in low level code generation.
466  return !isDeclaration() && isDefinitionExact();
467  }
468 
469  /// Return true if this global's definition can be substituted with an
470  /// *arbitrary* definition at link time or load time. We cannot do any IPO or
471  /// inlining across interposable call edges, since the callee can be
472  /// replaced with something arbitrary.
473  bool isInterposable() const;
474  bool canBenefitFromLocalAlias() const;
475 
476  bool hasExternalLinkage() const { return isExternalLinkage(getLinkage()); }
479  }
480  bool hasLinkOnceLinkage() const { return isLinkOnceLinkage(getLinkage()); }
481  bool hasLinkOnceAnyLinkage() const {
483  }
484  bool hasLinkOnceODRLinkage() const {
486  }
487  bool hasWeakLinkage() const { return isWeakLinkage(getLinkage()); }
488  bool hasWeakAnyLinkage() const { return isWeakAnyLinkage(getLinkage()); }
489  bool hasWeakODRLinkage() const { return isWeakODRLinkage(getLinkage()); }
491  bool hasInternalLinkage() const { return isInternalLinkage(getLinkage()); }
492  bool hasPrivateLinkage() const { return isPrivateLinkage(getLinkage()); }
493  bool hasLocalLinkage() const { return isLocalLinkage(getLinkage()); }
494  bool hasExternalWeakLinkage() const {
496  }
497  bool hasCommonLinkage() const { return isCommonLinkage(getLinkage()); }
500  }
501 
503  if (isLocalLinkage(LT))
505  Linkage = LT;
506  if (isImplicitDSOLocal())
507  setDSOLocal(true);
508  }
510 
511  bool isDiscardableIfUnused() const {
513  }
514 
515  bool isWeakForLinker() const { return isWeakForLinker(getLinkage()); }
516 
517 protected:
518  /// Copy all additional attributes (those not needed to create a GlobalValue)
519  /// from the GlobalValue Src to this one.
520  void copyAttributesFrom(const GlobalValue *Src);
521 
522 public:
523  /// If the given string begins with the GlobalValue name mangling escape
524  /// character '\1', drop it.
525  ///
526  /// This function applies a specific mangling that is used in PGO profiles,
527  /// among other things. If you're trying to get a symbol name for an
528  /// arbitrary GlobalValue, this is not the function you're looking for; see
529  /// Mangler.h.
531  if (!Name.empty() && Name[0] == '\1')
532  return Name.substr(1);
533  return Name;
534  }
535 
536  /// Return the modified name for a global value suitable to be
537  /// used as the key for a global lookup (e.g. profile or ThinLTO).
538  /// The value's original name is \c Name and has linkage of type
539  /// \c Linkage. The value is defined in module \c FileName.
540  static std::string getGlobalIdentifier(StringRef Name,
542  StringRef FileName);
543 
544  /// Return the modified name for this global value suitable to be
545  /// used as the key for a global lookup (e.g. profile or ThinLTO).
546  std::string getGlobalIdentifier() const;
547 
548  /// Declare a type to represent a global unique identifier for a global value.
549  /// This is a 64 bits hash that is used by PGO and ThinLTO to have a compact
550  /// unique way to identify a symbol.
551  using GUID = uint64_t;
552 
553  /// Return a 64-bit global unique ID constructed from global value name
554  /// (i.e. returned by getGlobalIdentifier()).
555  static GUID getGUID(StringRef GlobalName) { return MD5Hash(GlobalName); }
556 
557  /// Return a 64-bit global unique ID constructed from global value name
558  /// (i.e. returned by getGlobalIdentifier()).
559  GUID getGUID() const { return getGUID(getGlobalIdentifier()); }
560 
561  /// @name Materialization
562  /// Materialization is used to construct functions only as they're needed.
563  /// This
564  /// is useful to reduce memory usage in LLVM or parsing work done by the
565  /// BitcodeReader to load the Module.
566  /// @{
567 
568  /// If this function's Module is being lazily streamed in functions from disk
569  /// or some other source, this method can be used to check to see if the
570  /// function has been read in yet or not.
571  bool isMaterializable() const;
572 
573  /// Make sure this GlobalValue is fully read.
574  Error materialize();
575 
576 /// @}
577 
578  /// Return true if the primary definition of this global value is outside of
579  /// the current translation unit.
580  bool isDeclaration() const;
581 
582  bool isDeclarationForLinker() const {
584  return true;
585 
586  return isDeclaration();
587  }
588 
589  /// Returns true if this global's definition will be the one chosen by the
590  /// linker.
591  ///
592  /// NB! Ideally this should not be used at the IR level at all. If you're
593  /// interested in optimization constraints implied by the linker's ability to
594  /// choose an implementation, prefer using \c hasExactDefinition.
596  return !(isDeclarationForLinker() || isWeakForLinker());
597  }
598 
599  const GlobalObject *getAliaseeObject() const;
601  return const_cast<GlobalObject *>(
602  static_cast<const GlobalValue *>(this)->getAliaseeObject());
603  }
604 
605  /// Returns whether this is a reference to an absolute symbol.
606  bool isAbsoluteSymbolRef() const;
607 
608  /// If this is an absolute symbol reference, returns the range of the symbol,
609  /// otherwise returns None.
611 
612  /// This method unlinks 'this' from the containing module, but does not delete
613  /// it.
614  void removeFromParent();
615 
616  /// This method unlinks 'this' from the containing module and deletes it.
617  void eraseFromParent();
618 
619  /// Get the module that this global value is contained inside of...
620  Module *getParent() { return Parent; }
621  const Module *getParent() const { return Parent; }
622 
623  // Methods for support type inquiry through isa, cast, and dyn_cast:
624  static bool classof(const Value *V) {
625  return V->getValueID() == Value::FunctionVal ||
626  V->getValueID() == Value::GlobalVariableVal ||
627  V->getValueID() == Value::GlobalAliasVal ||
628  V->getValueID() == Value::GlobalIFuncVal;
629  }
630 
631  /// True if GV can be left out of the object symbol table. This is the case
632  /// for linkonce_odr values whose address is not significant. While legal, it
633  /// is not normally profitable to omit them from the .o symbol table. Using
634  /// this analysis makes sense when the information can be passed down to the
635  /// linker or we are in LTO.
636  bool canBeOmittedFromSymbolTable() const;
637 };
638 
639 } // end namespace llvm
640 
641 #endif // LLVM_IR_GLOBALVALUE_H
llvm::GlobalValue::hasSanitizerMetadata
bool hasSanitizerMetadata() const
Definition: GlobalValue.h:325
llvm::GlobalValue::UnnamedAddr
UnnamedAddr
Definition: GlobalValue.h:195
llvm::GlobalValue::removeFromParent
void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
Definition: Globals.cpp:76
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::lltok::Error
@ Error
Definition: LLToken.h:21
llvm::GlobalValue::hasCommonLinkage
bool hasCommonLinkage() const
Definition: GlobalValue.h:497
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:166
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:476
llvm::GlobalValue::LocalDynamicTLSModel
@ LocalDynamicTLSModel
Definition: GlobalValue.h:186
llvm::GlobalValue::getLinkage
LinkageTypes getLinkage() const
Definition: GlobalValue.h:509
llvm::GlobalValue::dropLLVMManglingEscape
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
Definition: GlobalValue.h:530
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:237
llvm::GlobalValue::isImplicitDSOLocal
bool isImplicitDSOLocal() const
Definition: GlobalValue.h:280
llvm::GlobalValue::ValueType
Type * ValueType
Definition: GlobalValue.h:88
StringRef.h
llvm::GlobalValue::hasWeakLinkage
bool hasWeakLinkage() const
Definition: GlobalValue.h:487
llvm::GlobalValue::NotThreadLocal
@ NotThreadLocal
Definition: GlobalValue.h:184
llvm::GlobalValue::isLocalLinkage
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:374
llvm::GlobalValue::materialize
Error materialize()
Make sure this GlobalValue is fully read.
Definition: Globals.cpp:47
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:253
llvm::GlobalValue::hasHiddenVisibility
bool hasHiddenVisibility() const
Definition: GlobalValue.h:236
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::GlobalValue::hasSection
bool hasSection() const
Definition: GlobalValue.h:272
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::setSanitizerMetadata
void setSanitizerMetadata(SanitizerMetadata Meta)
Definition: Globals.cpp:231
llvm::GlobalValue::setUnnamedAddr
void setUnnamedAddr(UnnamedAddr Val)
Definition: GlobalValue.h:217
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:350
llvm::GlobalValue::DLLImportStorageClass
@ DLLImportStorageClass
Function to be imported from DLL.
Definition: GlobalValue.h:71
llvm::GlobalValue::isDiscardableIfUnused
bool isDiscardableIfUnused() const
Definition: GlobalValue.h:511
llvm::GlobalValue::setDSOLocal
void setDSOLocal(bool Local)
Definition: GlobalValue.h:285
llvm::GlobalValue::hasExternalWeakLinkage
bool hasExternalWeakLinkage() const
Definition: GlobalValue.h:494
llvm::GlobalValue::GlobalValueSubClassDataBits
static const unsigned GlobalValueSubClassDataBits
Definition: GlobalValue.h:90
llvm::GlobalValue::isValidDeclarationLinkage
static bool isValidDeclarationLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:383
llvm::GlobalValue::getSection
StringRef getSection() const
Definition: Globals.cpp:171
llvm::AArch64CC::LT
@ LT
Definition: AArch64BaseInfo.h:266
llvm::GlobalValue::isCommonLinkage
static bool isCommonLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:380
llvm::GlobalValue::UnnamedAddr::Local
@ Local
llvm::GlobalValue::hasExactDefinition
bool hasExactDefinition() const
Return true if this global has an exact defintion.
Definition: GlobalValue.h:460
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:264
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:490
llvm::GlobalValue::isLinkOnceAnyLinkage
static bool isLinkOnceAnyLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:347
llvm::GlobalValue::isAppendingLinkage
static bool isAppendingLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:365
MD5.h
llvm::GlobalValue::getSanitizerMetadata
const SanitizerMetadata & getSanitizerMetadata() const
Definition: Globals.cpp:225
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::GlobalValue::getThreadLocalMode
ThreadLocalMode getThreadLocalMode() const
Definition: GlobalValue.h:257
Twine.h
llvm::GlobalObject
Definition: GlobalObject.h:27
llvm::GlobalValue::HasSanitizerMetadata
unsigned HasSanitizerMetadata
True if this symbol has sanitizer metadata available.
Definition: GlobalValue.h:118
llvm::GlobalValue::isInternalLinkage
static bool isInternalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:368
llvm::GlobalValue::hasPrivateLinkage
bool hasPrivateLinkage() const
Definition: GlobalValue.h:492
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:63
false
Definition: StackSlotColoring.cpp:141
llvm::GlobalValue::hasAtLeastLocalUnnamedAddr
bool hasAtLeastLocalUnnamedAddr() const
Returns true if this value's address is not significant in this module.
Definition: GlobalValue.h:210
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::GlobalValue::isWeakODRLinkage
static bool isWeakODRLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:359
llvm::Value::getValueID
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:532
llvm::GlobalValue::hasLinkOnceAnyLinkage
bool hasLinkOnceAnyLinkage() const
Definition: GlobalValue.h:481
llvm::Value::setName
void setName(const Twine &Name)
Change the name of the value.
Definition: Value.cpp:372
llvm::GlobalValue::SanitizerMetadata
Definition: GlobalValue.h:311
llvm::GlobalValue::hasInternalLinkage
bool hasInternalLinkage() const
Definition: GlobalValue.h:491
llvm::GlobalValue::hasGlobalUnnamedAddr
bool hasGlobalUnnamedAddr() const
Definition: GlobalValue.h:201
llvm::GlobalValue::InternalLinkage
@ InternalLinkage
Rename collisions when linking (static functions).
Definition: GlobalValue.h:55
llvm::Comdat
Definition: Comdat.h:33
llvm::AddressSpace
AddressSpace
Definition: NVPTXBaseInfo.h:21
llvm::None
const NoneType None
Definition: None.h:24
llvm::GlobalValue::IntID
Intrinsic::ID IntID
The intrinsic ID for this subclass (which must be a Function).
Definition: GlobalValue.h:161
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:555
llvm::codeview::ClassOptions::Intrinsic
@ Intrinsic
llvm::GlobalValue::hasDefaultVisibility
bool hasDefaultVisibility() const
Definition: GlobalValue.h:235
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:515
llvm::GlobalValue::getParent
const Module * getParent() const
Definition: GlobalValue.h:621
llvm::GlobalValue::hasAvailableExternallyLinkage
bool hasAvailableExternallyLinkage() const
Definition: GlobalValue.h:477
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::GlobalValue::canBenefitFromLocalAlias
bool canBenefitFromLocalAlias() const
Definition: Globals.cpp:109
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::StringRef::empty
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:153
llvm::GlobalValue::isWeakForLinker
static bool isWeakForLinker(LinkageTypes Linkage)
Whether the definition of this global may be replaced at link time.
Definition: GlobalValue.h:423
uint64_t
llvm::GlobalValue::getVisibility
VisibilityTypes getVisibility() const
Definition: GlobalValue.h:234
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:620
llvm::GlobalValue::GeneralDynamicTLSModel
@ GeneralDynamicTLSModel
Definition: GlobalValue.h:185
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:261
llvm::GlobalValue::hasComdat
bool hasComdat() const
Definition: GlobalValue.h:227
llvm::GlobalValue::getPartition
StringRef getPartition() const
Definition: Globals.cpp:202
llvm::PointerType
Class to represent pointers.
Definition: DerivedTypes.h:632
llvm::GlobalValue::setLinkage
void setLinkage(LinkageTypes LT)
Definition: GlobalValue.h:502
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:414
llvm::GlobalValue::setThreadLocal
void setThreadLocal(bool Val)
Definition: GlobalValue.h:250
llvm::GlobalValue::classof
static bool classof(const Value *V)
Definition: GlobalValue.h:624
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::GlobalValue::isExternalLinkage
static bool isExternalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:341
llvm::GlobalValue::hasLocalLinkage
bool hasLocalLinkage() const
Definition: GlobalValue.h:493
llvm::GlobalValue::isThreadLocal
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
Definition: GlobalValue.h:249
llvm::GlobalValue::getAliaseeObject
GlobalObject * getAliaseeObject()
Definition: GlobalValue.h:600
llvm::GlobalValue::isWeakLinkage
static bool isWeakLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:362
llvm::GlobalValue::ThreadLocal
unsigned ThreadLocal
Definition: GlobalValue.h:99
llvm::GlobalValue::isAvailableExternallyLinkage
static bool isAvailableExternallyLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:344
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
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:513
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:42
llvm::GlobalValue::getWeakLinkage
static LinkageTypes getWeakLinkage(bool ODR)
Definition: GlobalValue.h:337
llvm::GlobalValue::canBeOmittedFromSymbolTable
bool canBeOmittedFromSymbolTable() const
True if GV can be left out of the object symbol table.
Definition: Globals.cpp:377
llvm::Constant::removeDeadConstantUsers
void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
Definition: Constants.cpp:751
llvm::GlobalValue::getGlobalValueSubClassData
unsigned getGlobalValueSubClassData() const
Definition: GlobalValue.h:163
llvm::GlobalValue::SanitizerMetadata::NoAddress
unsigned NoAddress
Definition: GlobalValue.h:315
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
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:455
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
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:270
llvm::GlobalValue::SanitizerMetadata::NoMemtag
unsigned NoMemtag
Definition: GlobalValue.h:317
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::GlobalValue::AvailableExternallyLinkage
@ AvailableExternallyLinkage
Available for inspection, not emission.
Definition: GlobalValue.h:49
llvm::GlobalValue::getAliaseeObject
const GlobalObject * getAliaseeObject() const
Definition: Globals.cpp:352
llvm::GlobalValue::~GlobalValue
~GlobalValue()
Definition: GlobalValue.h:178
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:88
llvm::GlobalValue::isStrongDefinitionForLinker
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
Definition: GlobalValue.h:595
llvm::GlobalValue::LocalExecTLSModel
@ LocalExecTLSModel
Definition: GlobalValue.h:188
llvm::PointerUnion< const Value *, const PseudoSourceValue * >
llvm::GlobalValue::isLinkOnceLinkage
static bool isLinkOnceLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:353
llvm::GlobalValue::getUnnamedAddr
UnnamedAddr getUnnamedAddr() const
Definition: GlobalValue.h:214
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:102
llvm::GlobalValue::setParent
void setParent(Module *parent)
Definition: GlobalValue.h:174
Constant.h
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::GlobalValue::hasLinkOnceODRLinkage
bool hasLinkOnceODRLinkage() const
Definition: GlobalValue.h:484
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
llvm::GlobalValue::ThreadLocalMode
ThreadLocalMode
Definition: GlobalValue.h:183
llvm::GlobalValue::hasDLLExportStorageClass
bool hasDLLExportStorageClass() const
Definition: GlobalValue.h:267
llvm::GlobalValue::SanitizerMetadata::SanitizerMetadata
SanitizerMetadata()
Definition: GlobalValue.h:312
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:390
get
Should compile to something r4 addze r3 instead we get
Definition: README.txt:24
llvm::GlobalValue::hasValidDeclarationLinkage
bool hasValidDeclarationLinkage() const
Definition: GlobalValue.h:498
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::GlobalValue::getComdat
const Comdat * getComdat() const
Definition: Globals.cpp:181
llvm::GlobalValue::getGUID
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:559
Casting.h
llvm::GlobalValue::isPrivateLinkage
static bool isPrivateLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:371
llvm::GlobalValue::ProtectedVisibility
@ ProtectedVisibility
The GV is protected.
Definition: GlobalValue.h:65
SanitizerMetadata
GlobalValue::SanitizerMetadata SanitizerMetadata
Definition: Globals.cpp:224
llvm::GlobalValue::getAddressSpace
unsigned getAddressSpace() const
Definition: Globals.cpp:121
llvm::GlobalValue::setGlobalValueSubClassData
void setGlobalValueSubClassData(unsigned V)
Definition: GlobalValue.h:166
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:357
llvm::GlobalValue::PrivateLinkage
@ PrivateLinkage
Like Internal, but omit from symbol table.
Definition: GlobalValue.h:56
llvm::GlobalValue::removeSanitizerMetadata
void removeSanitizerMetadata()
Definition: Globals.cpp:236
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:365
llvm::GlobalValue::getComdat
Comdat * getComdat()
Definition: GlobalValue.h:229
llvm::GlobalValue::hasWeakODRLinkage
bool hasWeakODRLinkage() const
Definition: GlobalValue.h:489
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:582
llvm::GlobalValue::hasDLLImportStorageClass
bool hasDLLImportStorageClass() const
Definition: GlobalValue.h:264
llvm::GlobalValue::setPartition
void setPartition(StringRef Part)
Definition: Globals.cpp:208
llvm::GlobalValue::hasWeakAnyLinkage
bool hasWeakAnyLinkage() const
Definition: GlobalValue.h:488
llvm::GlobalValue::isWeakAnyLinkage
static bool isWeakAnyLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:356
llvm::GlobalValue::hasLinkOnceLinkage
bool hasLinkOnceLinkage() const
Definition: GlobalValue.h:480
llvm::GlobalValue::getType
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:276
DerivedTypes.h
llvm::GlobalValue::getValueType
Type * getValueType() const
Definition: GlobalValue.h:278
llvm::GlobalValue::hasPartition
bool hasPartition() const
Definition: GlobalValue.h:291
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::InitialExecTLSModel
@ InitialExecTLSModel
Definition: GlobalValue.h:187
llvm::GlobalValue::isDSOLocal
bool isDSOLocal() const
Definition: GlobalValue.h:287
llvm::GlobalValue::LinkOnceODRLinkage
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
Definition: GlobalValue.h:51
Value.h
llvm::GlobalValue::SanitizerMetadata::NoHWAddress
unsigned NoHWAddress
Definition: GlobalValue.h:316
llvm::GlobalValue::setVisibility
void setVisibility(VisibilityTypes V)
Definition: GlobalValue.h:240
llvm::GlobalValue::Parent
Module * Parent
Definition: GlobalValue.h:171
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::GlobalValue::isExternalWeakLinkage
static bool isExternalWeakLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:377
llvm::GlobalValue::getMinUnnamedAddr
static UnnamedAddr getMinUnnamedAddr(UnnamedAddr A, UnnamedAddr B)
Definition: GlobalValue.h:219
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:43
llvm::GlobalValue::SanitizerMetadata::IsDynInit
unsigned IsDynInit
Definition: GlobalValue.h:322
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:334