LLVM 22.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"
24#include "llvm/IR/Value.h"
28#include <cassert>
29#include <cstdint>
30#include <string>
31
32namespace llvm {
33
34class Comdat;
35class ConstantRange;
36class DataLayout;
37class Error;
38class GlobalObject;
39class Module;
40
41namespace Intrinsic {
42typedef unsigned ID;
43} // end namespace Intrinsic
44
45// Choose ';' as the delimiter. ':' was used once but it doesn't work well for
46// Objective-C functions which commonly have :'s in their names.
47inline constexpr char GlobalIdentifierDelimiter = ';';
48
49class GlobalValue : public Constant {
50public:
51 /// An enumeration for the kinds of linkage for global values.
53 ExternalLinkage = 0,///< Externally visible function
54 AvailableExternallyLinkage, ///< Available for inspection, not emission.
55 LinkOnceAnyLinkage, ///< Keep one copy of function when linking (inline)
56 LinkOnceODRLinkage, ///< Same, but only replaced by something equivalent.
57 WeakAnyLinkage, ///< Keep one copy of named function when linking (weak)
58 WeakODRLinkage, ///< Same, but only replaced by something equivalent.
59 AppendingLinkage, ///< Special purpose, only applies to global arrays
60 InternalLinkage, ///< Rename collisions when linking (static functions).
61 PrivateLinkage, ///< Like Internal, but omit from symbol table.
62 ExternalWeakLinkage,///< ExternalWeak linkage description.
63 CommonLinkage ///< Tentative definitions.
64 };
65
66 /// An enumeration for the kinds of visibility of global values.
68 DefaultVisibility = 0, ///< The GV is visible
69 HiddenVisibility, ///< The GV is hidden
70 ProtectedVisibility ///< The GV is protected
71 };
72
73 /// Storage classes of global values for PE targets.
76 DLLImportStorageClass = 1, ///< Function to be imported from DLL
77 DLLExportStorageClass = 2 ///< Function to be accessible from DLL.
78 };
79
80protected:
93
95
96 static const unsigned GlobalValueSubClassDataBits = 15;
97
98 // All bitfields use unsigned as the underlying type so that MSVC will pack
99 // them.
100 unsigned Linkage : 4; // The linkage of this global
101 unsigned Visibility : 2; // The visibility style of this global
102 unsigned UnnamedAddrVal : 2; // This value's address is not significant
103 unsigned DllStorageClass : 2; // DLL storage class
104
105 unsigned ThreadLocal : 3; // Is this symbol "Thread Local", if so, what is
106 // the desired model?
107
108 /// True if the function's name starts with "llvm.". This corresponds to the
109 /// value of Function::isIntrinsic(), which may be true even if
110 /// Function::intrinsicID() returns Intrinsic::not_intrinsic.
112
113 /// If true then there is a definition within the same linkage unit and that
114 /// definition cannot be runtime preempted.
115 unsigned IsDSOLocal : 1;
116
117 /// True if this symbol has a partition name assigned (see
118 /// https://lld.llvm.org/Partitions.html).
119 unsigned HasPartition : 1;
120
121 /// True if this symbol has sanitizer metadata available. Should only happen
122 /// if sanitizers were enabled when building the translation unit which
123 /// contains this GV.
125
126private:
127 // Give subclasses access to what otherwise would be wasted padding.
128 // (15 + 4 + 2 + 2 + 2 + 3 + 1 + 1 + 1 + 1) == 32.
129 unsigned SubClassData : GlobalValueSubClassDataBits;
130
131 friend class Constant;
132
133 void destroyConstantImpl();
134 Value *handleOperandChangeImpl(Value *From, Value *To);
135
136 /// Returns true if the definition of this global may be replaced by a
137 /// differently optimized variant of the same source level function at link
138 /// time.
139 bool mayBeDerefined() const {
140 switch (getLinkage()) {
141 case WeakODRLinkage:
144 return true;
145
146 case WeakAnyLinkage:
148 case CommonLinkage:
150 case ExternalLinkage:
151 case AppendingLinkage:
152 case InternalLinkage:
153 case PrivateLinkage:
154 // Optimizations may assume builtin semantics for functions defined as
155 // nobuiltin due to attributes at call-sites. To avoid applying IPO based
156 // on nobuiltin semantics, treat such function definitions as maybe
157 // derefined.
158 return isInterposable() || isNobuiltinFnDef();
159 }
160
161 llvm_unreachable("Fully covered switch above!");
162 }
163
164 /// Returns true if the global is a function definition with the nobuiltin
165 /// attribute.
166 LLVM_ABI bool isNobuiltinFnDef() const;
167
168protected:
169 /// The intrinsic ID for this subclass (which must be a Function).
170 ///
171 /// This member is defined by this class, but not used for anything.
172 /// Subclasses can use it to store their intrinsic ID, if they have one.
173 ///
174 /// This is stored here to save space in Function on 64-bit hosts.
176
177 unsigned getGlobalValueSubClassData() const {
178 return SubClassData;
179 }
180 void setGlobalValueSubClassData(unsigned V) {
181 assert(V < (1 << GlobalValueSubClassDataBits) && "It will not fit");
182 SubClassData = V;
183 }
184
185 Module *Parent = nullptr; // The containing module.
186
187 // Used by SymbolTableListTraits.
188 void setParent(Module *parent) {
189 Parent = parent;
190 }
191
193 removeDeadConstantUsers(); // remove any dead constants using this.
194 }
195
196public:
204
205 GlobalValue(const GlobalValue &) = delete;
206
207 unsigned getAddressSpace() const {
208 return getType()->getAddressSpace();
209 }
210
211 enum class UnnamedAddr {
215 };
216
217 bool hasGlobalUnnamedAddr() const {
219 }
220
221 /// Returns true if this value's address is not significant in this module.
222 /// This attribute is intended to be used only by the code generator and LTO
223 /// to allow the linker to decide whether the global needs to be in the symbol
224 /// table. It should probably not be used in optimizations, as the value may
225 /// have uses outside the module; use hasGlobalUnnamedAddr() instead.
228 }
229
234
242
243 bool hasComdat() const { return getComdat() != nullptr; }
244 LLVM_ABI const Comdat *getComdat() const;
246 return const_cast<Comdat *>(
247 static_cast<const GlobalValue *>(this)->getComdat());
248 }
249
255 }
258 "local linkage requires default visibility");
259 Visibility = V;
260 if (isImplicitDSOLocal())
261 setDSOLocal(true);
262 }
263
264 /// If the value is "Thread Local", its value isn't shared by the threads.
265 bool isThreadLocal() const { return getThreadLocalMode() != NotThreadLocal; }
270 assert(Val == NotThreadLocal || getValueID() != Value::FunctionVal);
271 ThreadLocal = Val;
272 }
274 return static_cast<ThreadLocalMode>(ThreadLocal);
275 }
276
288 "local linkage requires DefaultStorageClass");
290 }
291
292 bool hasSection() const { return !getSection().empty(); }
294
295 /// Global values are always pointers.
297
298 Type *getValueType() const { return ValueType; }
299
300 bool isImplicitDSOLocal() const {
301 return hasLocalLinkage() ||
303 }
304
306
307 bool isDSOLocal() const {
308 return IsDSOLocal;
309 }
310
311 bool hasPartition() const {
312 return HasPartition;
313 }
316
317 // ASan, HWASan and Memtag sanitizers have some instrumentation that applies
318 // specifically to global variables.
323 // For ASan and HWASan, this instrumentation is implicitly applied to all
324 // global variables when built with -fsanitize=*. What we need is a way to
325 // persist the information that a certain global variable should *not* have
326 // sanitizers applied, which occurs if:
327 // 1. The global variable is in the sanitizer ignore list, or
328 // 2. The global variable is created by the sanitizers itself for internal
329 // usage, or
330 // 3. The global variable has __attribute__((no_sanitize("..."))) or
331 // __attribute__((disable_sanitizer_instrumentation)).
332 //
333 // This is important, a some IR passes like GlobalMerge can delete global
334 // variables and replace them with new ones. If the old variables were
335 // marked to be unsanitized, then the new ones should also be.
336 unsigned NoAddress : 1;
337 unsigned NoHWAddress : 1;
338
339 // Memtag sanitization works differently: sanitization is requested by clang
340 // when `-fsanitize=memtag-globals` is provided, and the request can be
341 // denied (and the attribute removed) by the AArch64 global tagging pass if
342 // it can't be fulfilled (e.g. the global variable is a TLS variable).
343 // Memtag sanitization has to interact with other parts of LLVM (like
344 // supressing certain optimisations, emitting assembly directives, or
345 // creating special relocation sections).
346 //
347 // Use `GlobalValue::isTagged()` to check whether tagging should be enabled
348 // for a global variable.
349 unsigned Memtag : 1;
350
351 // ASan-specific metadata. Is this global variable dynamically initialized
352 // (from a C++ language perspective), and should therefore be checked for
353 // ODR violations.
354 unsigned IsDynInit : 1;
355 };
356
359 // Note: Not byref as it's a POD and otherwise it's too easy to call
360 // G.setSanitizerMetadata(G2.getSanitizerMetadata()), and the argument becomes
361 // dangling when the backing storage allocates the metadata for `G`, as the
362 // storage is shared between `G1` and `G2`.
366
367 bool isTagged() const {
369 }
370
373 }
374 static LinkageTypes getWeakLinkage(bool ODR) {
375 return ODR ? WeakODRLinkage : WeakAnyLinkage;
376 }
377
379 return Linkage == ExternalLinkage;
380 }
394 return Linkage == WeakAnyLinkage;
395 }
397 return Linkage == WeakODRLinkage;
398 }
406 return Linkage == InternalLinkage;
407 }
409 return Linkage == PrivateLinkage;
410 }
418 return Linkage == CommonLinkage;
419 }
423
424 /// Whether the definition of this global may be replaced by something
425 /// non-equivalent at link time. For example, if a function has weak linkage
426 /// then the code defining it may be replaced by different code.
428 switch (Linkage) {
429 case WeakAnyLinkage:
431 case CommonLinkage:
433 return true;
434
437 case WeakODRLinkage:
438 // The above three cannot be overridden but can be de-refined.
439
440 case ExternalLinkage:
441 case AppendingLinkage:
442 case InternalLinkage:
443 case PrivateLinkage:
444 return false;
445 }
446 llvm_unreachable("Fully covered switch above!");
447 }
448
449 /// Whether the definition of this global may be discarded if it is not used
450 /// in its compilation unit.
455
456 /// Whether the definition of this global may be replaced at link time. NB:
457 /// Using this method outside of the code generators is almost always a
458 /// mistake: when working at the IR level use isInterposable instead as it
459 /// knows about ODR semantics.
465
466 /// Return true if the currently visible definition of this global (if any) is
467 /// exactly the definition we will see at runtime.
468 ///
469 /// Non-exact linkage types inhibits most non-inlining IPO, since a
470 /// differently optimized variant of the same function can have different
471 /// observable or undefined behavior than in the variant currently visible.
472 /// For instance, we could have started with
473 ///
474 /// void foo(int *v) {
475 /// int t = 5 / v[0];
476 /// (void) t;
477 /// }
478 ///
479 /// and "refined" it to
480 ///
481 /// void foo(int *v) { }
482 ///
483 /// However, we cannot infer readnone for `foo`, since that would justify
484 /// DSE'ing a store to `v[0]` across a call to `foo`, which can cause
485 /// undefined behavior if the linker replaces the actual call destination with
486 /// the unoptimized `foo`.
487 ///
488 /// Inlining is okay across non-exact linkage types as long as they're not
489 /// interposable (see \c isInterposable), since in such cases the currently
490 /// visible variant is *a* correct implementation of the original source
491 /// function; it just isn't the *only* correct implementation.
492 bool isDefinitionExact() const {
493 return !mayBeDerefined();
494 }
495
496 /// Return true if this global has an exact defintion.
497 bool hasExactDefinition() const {
498 // While this computes exactly the same thing as
499 // isStrongDefinitionForLinker, the intended uses are different. This
500 // function is intended to help decide if specific inter-procedural
501 // transforms are correct, while isStrongDefinitionForLinker's intended use
502 // is in low level code generation.
503 return !isDeclaration() && isDefinitionExact();
504 }
505
506 /// Return true if this global's definition can be substituted with an
507 /// *arbitrary* definition at link time or load time. We cannot do any IPO or
508 /// inlining across interposable call edges, since the callee can be
509 /// replaced with something arbitrary.
510 LLVM_ABI bool isInterposable() const;
512
520 }
523 }
524 bool hasWeakLinkage() const { return isWeakLinkage(getLinkage()); }
530 bool hasLocalLinkage() const { return isLocalLinkage(getLinkage()); }
533 }
534 bool hasCommonLinkage() const { return isCommonLinkage(getLinkage()); }
538
540 if (isLocalLinkage(LT)) {
543 }
544 Linkage = LT;
545 if (isImplicitDSOLocal())
546 setDSOLocal(true);
547 }
549
552 }
553
554 bool isWeakForLinker() const { return isWeakForLinker(getLinkage()); }
555
556protected:
557 /// Copy all additional attributes (those not needed to create a GlobalValue)
558 /// from the GlobalValue Src to this one.
559 LLVM_ABI void copyAttributesFrom(const GlobalValue *Src);
560
561public:
562 /// If the given string begins with the GlobalValue name mangling escape
563 /// character '\1', drop it.
564 ///
565 /// This function applies a specific mangling that is used in PGO profiles,
566 /// among other things. If you're trying to get a symbol name for an
567 /// arbitrary GlobalValue, this is not the function you're looking for; see
568 /// Mangler.h.
570 Name.consume_front("\1");
571 return Name;
572 }
573
574 /// Declare a type to represent a global unique identifier for a global value.
575 /// This is a 64 bits hash that is used by PGO and ThinLTO to have a compact
576 /// unique way to identify a symbol.
577 using GUID = uint64_t;
578
579 /// Return the modified name for a global value suitable to be
580 /// used as the key for a global lookup (e.g. profile or ThinLTO).
581 /// The value's original name is \c Name and has linkage of type
582 /// \c Linkage. The value is defined in module \c FileName.
583 LLVM_ABI static std::string
585 StringRef FileName);
586
587private:
588 /// Return the modified name for this global value suitable to be
589 /// used as the key for a global lookup (e.g. profile or ThinLTO).
590 LLVM_ABI std::string getGlobalIdentifier() const;
591
592public:
593 /// Return a 64-bit global unique ID constructed from the name of a global
594 /// symbol. Since this call doesn't supply the linkage or defining filename,
595 /// the GUID computation will assume that the global has external linkage.
597
598 /// Return a 64-bit global unique ID constructed from global value name
599 /// (i.e. returned by getGlobalIdentifier()).
603
604 /// @name Materialization
605 /// Materialization is used to construct functions only as they're needed.
606 /// This
607 /// is useful to reduce memory usage in LLVM or parsing work done by the
608 /// BitcodeReader to load the Module.
609 /// @{
610
611 /// If this function's Module is being lazily streamed in functions from disk
612 /// or some other source, this method can be used to check to see if the
613 /// function has been read in yet or not.
614 LLVM_ABI bool isMaterializable() const;
615
616 /// Make sure this GlobalValue is fully read.
618
619 /// @}
620
621 /// Return true if the primary definition of this global value is outside of
622 /// the current translation unit.
623 LLVM_ABI bool isDeclaration() const;
624
627 return true;
628
629 return isDeclaration();
630 }
631
632 /// Returns true if this global's definition will be the one chosen by the
633 /// linker.
634 ///
635 /// NB! Ideally this should not be used at the IR level at all. If you're
636 /// interested in optimization constraints implied by the linker's ability to
637 /// choose an implementation, prefer using \c hasExactDefinition.
640 }
641
644 return const_cast<GlobalObject *>(
645 static_cast<const GlobalValue *>(this)->getAliaseeObject());
646 }
647
648 /// Returns whether this is a reference to an absolute symbol.
649 LLVM_ABI bool isAbsoluteSymbolRef() const;
650
651 /// If this is an absolute symbol reference, returns the range of the symbol,
652 /// otherwise returns std::nullopt.
653 LLVM_ABI std::optional<ConstantRange> getAbsoluteSymbolRange() const;
654
655 /// This method unlinks 'this' from the containing module, but does not delete
656 /// it.
658
659 /// This method unlinks 'this' from the containing module and deletes it.
661
662 /// Get the module that this global value is contained inside of...
663 Module *getParent() { return Parent; }
664 const Module *getParent() const { return Parent; }
665
666 /// Get the data layout of the module this global belongs to.
667 ///
668 /// Requires the global to have a parent module.
669 LLVM_ABI const DataLayout &getDataLayout() const;
670
671 // Methods for support type inquiry through isa, cast, and dyn_cast:
672 static bool classof(const Value *V) {
673 return V->getValueID() == Value::FunctionVal ||
674 V->getValueID() == Value::GlobalVariableVal ||
675 V->getValueID() == Value::GlobalAliasVal ||
676 V->getValueID() == Value::GlobalIFuncVal;
677 }
678
679 /// True if GV can be left out of the object symbol table. This is the case
680 /// for linkonce_odr values whose address is not significant. While legal, it
681 /// is not normally profitable to omit them from the .o symbol table. Using
682 /// this analysis makes sense when the information can be passed down to the
683 /// linker or we are in LTO.
685};
686
687} // end namespace llvm
688
689#endif // LLVM_IR_GLOBALVALUE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:213
GlobalValue::SanitizerMetadata SanitizerMetadata
Definition Globals.cpp:244
This class represents a range of values.
LLVM_ABI void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:63
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
bool isDefinitionExact() const
Return true if the currently visible definition of this global (if any) is exactly the definition we ...
unsigned HasSanitizerMetadata
True if this symbol has sanitizer metadata available.
static bool isWeakAnyLinkage(LinkageTypes Linkage)
bool hasLinkOnceLinkage() const
const Module * getParent() const
static bool isAppendingLinkage(LinkageTypes Linkage)
bool hasPartition() const
static bool isLinkOnceAnyLinkage(LinkageTypes Linkage)
static LLVM_ABI GUID getGUIDAssumingExternalLinkage(StringRef GlobalName)
Return a 64-bit global unique ID constructed from the name of a global symbol.
Definition Globals.cpp:77
LLVM_ABI const SanitizerMetadata & getSanitizerMetadata() const
Definition Globals.cpp:245
bool hasExternalLinkage() const
bool isDSOLocal() const
unsigned HasPartition
True if this symbol has a partition name assigned (see https://lld.llvm.org/Partitions....
LLVM_ABI void removeSanitizerMetadata()
Definition Globals.cpp:256
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
static bool isExternalWeakLinkage(LinkageTypes Linkage)
VisibilityTypes getVisibility() const
bool isImplicitDSOLocal() const
static bool isLocalLinkage(LinkageTypes Linkage)
LLVM_ABI bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
Definition Globals.cpp:316
bool hasValidDeclarationLinkage() const
LinkageTypes getLinkage() const
void setUnnamedAddr(UnnamedAddr Val)
static bool isWeakODRLinkage(LinkageTypes Linkage)
bool hasLinkOnceAnyLinkage() const
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
bool hasLocalLinkage() const
bool hasDefaultVisibility() const
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
bool hasPrivateLinkage() const
LLVM_ABI bool isAbsoluteSymbolRef() const
Returns whether this is a reference to an absolute symbol.
Definition Globals.cpp:424
bool isTagged() const
void setDLLStorageClass(DLLStorageClassTypes C)
LLVM_ABI const Comdat * getComdat() const
Definition Globals.cpp:201
void setThreadLocalMode(ThreadLocalMode Val)
static bool isLinkOnceLinkage(LinkageTypes Linkage)
Intrinsic::ID IntID
The intrinsic ID for this subclass (which must be a Function).
bool hasHiddenVisibility() const
bool hasExternalWeakLinkage() const
ThreadLocalMode getThreadLocalMode() const
bool hasExactDefinition() const
Return true if this global has an exact defintion.
unsigned HasLLVMReservedName
True if the function's name starts with "llvm.".
static bool isAvailableExternallyLinkage(LinkageTypes Linkage)
friend class Constant
bool hasWeakAnyLinkage() const
void setParent(Module *parent)
bool hasDLLImportStorageClass() const
void setLinkage(LinkageTypes LT)
DLLStorageClassTypes
Storage classes of global values for PE targets.
Definition GlobalValue.h:74
@ DLLExportStorageClass
Function to be accessible from DLL.
Definition GlobalValue.h:77
@ DLLImportStorageClass
Function to be imported from DLL.
Definition GlobalValue.h:76
bool hasDLLExportStorageClass() const
bool isDeclarationForLinker() const
Comdat * getComdat()
bool hasSanitizerMetadata() const
static UnnamedAddr getMinUnnamedAddr(UnnamedAddr A, UnnamedAddr B)
GlobalObject * getAliaseeObject()
unsigned getAddressSpace() const
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
LLVM_ABI StringRef getSection() const
Definition Globals.cpp:191
LLVM_ABI StringRef getPartition() const
Definition Globals.cpp:222
Module * getParent()
Get the module that this global value is contained inside of...
static bool isCommonLinkage(LinkageTypes Linkage)
LLVM_ABI const GlobalObject * getAliaseeObject() const
Definition Globals.cpp:419
void setDSOLocal(bool Local)
LLVM_ABI std::optional< ConstantRange > getAbsoluteSymbolRange() const
If this is an absolute symbol reference, returns the range of the symbol, otherwise returns std::null...
Definition Globals.cpp:432
bool hasInternalLinkage() const
LLVM_ABI void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
Definition Globals.cpp:93
static bool isPrivateLinkage(LinkageTypes Linkage)
bool isDiscardableIfUnused() const
static bool isExternalLinkage(LinkageTypes Linkage)
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
PointerType * getType() const
Global values are always pointers.
VisibilityTypes
An enumeration for the kinds of visibility of global values.
Definition GlobalValue.h:67
@ DefaultVisibility
The GV is visible.
Definition GlobalValue.h:68
@ HiddenVisibility
The GV is hidden.
Definition GlobalValue.h:69
@ ProtectedVisibility
The GV is protected.
Definition GlobalValue.h:70
LLVM_ABI 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
static bool isValidDeclarationLinkage(LinkageTypes Linkage)
static const unsigned GlobalValueSubClassDataBits
Definition GlobalValue.h:96
static bool isInternalLinkage(LinkageTypes Linkage)
static LLVM_ABI std::string getGlobalIdentifier(StringRef Name, GlobalValue::LinkageTypes Linkage, StringRef FileName)
Return the modified name for a global value suitable to be used as the key for a global lookup (e....
Definition Globals.cpp:161
LLVM_ABI void setNoSanitizeMetadata()
Definition Globals.cpp:263
bool hasSection() const
LLVM_ABI bool isInterposable() const
Return true if this global's definition can be substituted with an arbitrary definition at link time ...
Definition Globals.cpp:107
void setVisibility(VisibilityTypes V)
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
Definition Globals.cpp:132
LLVM_ABI bool canBenefitFromLocalAlias() const
Definition Globals.cpp:114
bool hasComdat() const
static bool isInterposableLinkage(LinkageTypes Linkage)
Whether the definition of this global may be replaced by something non-equivalent at link time.
bool hasWeakLinkage() const
bool hasAtLeastLocalUnnamedAddr() const
Returns true if this value's address is not significant in this module.
unsigned getGlobalValueSubClassData() const
static LinkageTypes getWeakLinkage(bool ODR)
bool hasWeakODRLinkage() const
void setGlobalValueSubClassData(unsigned V)
unsigned IsDSOLocal
If true then there is a definition within the same linkage unit and that definition cannot be runtime...
static LinkageTypes getLinkOnceLinkage(bool ODR)
LLVM_ABI bool isMaterializable() const
If this function's Module is being lazily streamed in functions from disk or some other source,...
Definition Globals.cpp:44
bool isWeakForLinker() const
bool hasCommonLinkage() const
bool hasGlobalUnnamedAddr() const
LLVM_ABI Error materialize()
Make sure this GlobalValue is fully read.
Definition Globals.cpp:49
UnnamedAddr getUnnamedAddr() const
static bool isWeakForLinker(LinkageTypes Linkage)
Whether the definition of this global may be replaced at link time.
GlobalValue(const GlobalValue &)=delete
bool hasAppendingLinkage() const
static bool isWeakLinkage(LinkageTypes Linkage)
static bool isDiscardableIfUnused(LinkageTypes Linkage)
Whether the definition of this global may be discarded if it is not used in its compilation unit.
LLVM_ABI void setSanitizerMetadata(SanitizerMetadata Meta)
Definition Globals.cpp:251
static bool classof(const Value *V)
bool hasLinkOnceODRLinkage() const
LLVM_ABI bool canBeOmittedFromSymbolTable() const
True if GV can be left out of the object symbol table.
Definition Globals.cpp:444
LLVM_ABI void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
Definition Globals.cpp:81
bool hasAvailableExternallyLinkage() const
LinkageTypes
An enumeration for the kinds of linkage for global values.
Definition GlobalValue.h:52
@ PrivateLinkage
Like Internal, but omit from symbol table.
Definition GlobalValue.h:61
@ CommonLinkage
Tentative definitions.
Definition GlobalValue.h:63
@ InternalLinkage
Rename collisions when linking (static functions).
Definition GlobalValue.h:60
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
Definition GlobalValue.h:55
@ WeakODRLinkage
Same, but only replaced by something equivalent.
Definition GlobalValue.h:58
@ ExternalLinkage
Externally visible function.
Definition GlobalValue.h:53
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
Definition GlobalValue.h:57
@ AppendingLinkage
Special purpose, only applies to global arrays.
Definition GlobalValue.h:59
@ AvailableExternallyLinkage
Available for inspection, not emission.
Definition GlobalValue.h:54
@ ExternalWeakLinkage
ExternalWeak linkage description.
Definition GlobalValue.h:62
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
Definition GlobalValue.h:56
void setThreadLocal(bool Val)
DLLStorageClassTypes getDLLStorageClass() const
Type * getValueType() const
GlobalValue(Type *Ty, ValueTy VTy, AllocInfo AllocInfo, LinkageTypes Linkage, const Twine &Name, unsigned AddressSpace)
Definition GlobalValue.h:81
static bool isLinkOnceODRLinkage(LinkageTypes Linkage)
bool hasProtectedVisibility() const
unsigned DllStorageClass
unsigned UnnamedAddrVal
LLVM_ABI void setPartition(StringRef Part)
Definition Globals.cpp:228
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
Class to represent pointers.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
constexpr bool empty() const
empty - Check if the string is empty.
Definition StringRef.h:151
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:256
LLVM_ABI void setName(const Twine &Name)
Change the name of the value.
Definition Value.cpp:390
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition Value.h:543
LLVM_ABI LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.cpp:1101
ValueTy
Concrete subclass of this.
Definition Value.h:524
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
constexpr char GlobalIdentifierDelimiter
Definition GlobalValue.h:47
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:565
Information about how a User object was allocated, to be passed into the User constructor.
Definition User.h:79