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