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:
82 const Twine &Name, unsigned AddressSpace)
84 AllocInfo),
92 }
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:
203 };
204
205 GlobalValue(const GlobalValue &) = delete;
206
207 unsigned getAddressSpace() const {
208 return getType()->getAddressSpace();
209 }
210
211 enum class UnnamedAddr {
212 None,
213 Local,
214 Global,
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
232 }
234
237 return UnnamedAddr::None;
239 return UnnamedAddr::Local;
240 return UnnamedAddr::Global;
241 }
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; }
266 void setThreadLocal(bool Val) {
268 }
270 assert(Val == NotThreadLocal || getValueID() != Value::FunctionVal);
271 ThreadLocal = Val;
272 }
274 return static_cast<ThreadLocalMode>(ThreadLocal);
275 }
276
279 }
282 }
285 }
288 "local linkage requires DefaultStorageClass");
290 }
291
292 bool hasSection() const { return !getSection().empty(); }
294
295 /// Global values are always pointers.
296 PointerType *getType() const { return cast<PointerType>(User::getType()); }
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 }
383 }
385 return Linkage == LinkOnceAnyLinkage;
386 }
388 return Linkage == LinkOnceODRLinkage;
389 }
392 }
394 return Linkage == WeakAnyLinkage;
395 }
397 return Linkage == WeakODRLinkage;
398 }
401 }
403 return Linkage == AppendingLinkage;
404 }
406 return Linkage == InternalLinkage;
407 }
409 return Linkage == PrivateLinkage;
410 }
413 }
416 }
418 return Linkage == CommonLinkage;
419 }
422 }
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.
454 }
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.
464 }
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
516 }
520 }
523 }
524 bool hasWeakLinkage() const { return isWeakLinkage(getLinkage()); }
530 bool hasLocalLinkage() const { return isLocalLinkage(getLinkage()); }
533 }
534 bool hasCommonLinkage() const { return isCommonLinkage(getLinkage()); }
537 }
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()).
600 GUID getGUID() const {
602 }
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!")
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define LLVM_ABI
Definition: Compiler.h:213
std::string Name
GlobalValue::SanitizerMetadata SanitizerMetadata
Definition: Globals.cpp:244
Machine Check Debug Module
This is an important base class in LLVM.
Definition: Constant.h:43
LLVM_ABI void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
Definition: Constants.cpp:739
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 ...
Definition: GlobalValue.h:492
unsigned HasSanitizerMetadata
True if this symbol has sanitizer metadata available.
Definition: GlobalValue.h:124
static bool isWeakAnyLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:393
bool hasLinkOnceLinkage() const
Definition: GlobalValue.h:517
const Module * getParent() const
Definition: GlobalValue.h:664
static bool isAppendingLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:402
bool hasPartition() const
Definition: GlobalValue.h:311
static bool isLinkOnceAnyLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:384
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
Definition: GlobalValue.h:513
bool isDSOLocal() const
Definition: GlobalValue.h:307
unsigned HasPartition
True if this symbol has a partition name assigned (see https://lld.llvm.org/Partitions....
Definition: GlobalValue.h:119
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.
Definition: GlobalValue.h:265
static bool isExternalWeakLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:414
VisibilityTypes getVisibility() const
Definition: GlobalValue.h:250
bool isImplicitDSOLocal() const
Definition: GlobalValue.h:300
static bool isLocalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:411
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
Definition: GlobalValue.h:535
LinkageTypes getLinkage() const
Definition: GlobalValue.h:548
void setUnnamedAddr(UnnamedAddr Val)
Definition: GlobalValue.h:233
static bool isWeakODRLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:396
bool hasLinkOnceAnyLinkage() const
Definition: GlobalValue.h:518
bool hasLocalLinkage() const
Definition: GlobalValue.h:530
bool hasDefaultVisibility() const
Definition: GlobalValue.h:251
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
Definition: GlobalValue.h:569
bool hasPrivateLinkage() const
Definition: GlobalValue.h:529
LLVM_ABI bool isAbsoluteSymbolRef() const
Returns whether this is a reference to an absolute symbol.
Definition: Globals.cpp:424
bool isTagged() const
Definition: GlobalValue.h:367
void setDLLStorageClass(DLLStorageClassTypes C)
Definition: GlobalValue.h:286
LLVM_ABI const Comdat * getComdat() const
Definition: Globals.cpp:201
void setThreadLocalMode(ThreadLocalMode Val)
Definition: GlobalValue.h:269
unsigned Visibility
Definition: GlobalValue.h:101
static bool isLinkOnceLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:390
Intrinsic::ID IntID
The intrinsic ID for this subclass (which must be a Function).
Definition: GlobalValue.h:175
bool hasHiddenVisibility() const
Definition: GlobalValue.h:252
bool hasExternalWeakLinkage() const
Definition: GlobalValue.h:531
ThreadLocalMode getThreadLocalMode() const
Definition: GlobalValue.h:273
bool hasExactDefinition() const
Return true if this global has an exact defintion.
Definition: GlobalValue.h:497
unsigned HasLLVMReservedName
True if the function's name starts with "llvm.".
Definition: GlobalValue.h:111
static bool isAvailableExternallyLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:381
bool hasWeakAnyLinkage() const
Definition: GlobalValue.h:525
void setParent(Module *parent)
Definition: GlobalValue.h:188
bool hasDLLImportStorageClass() const
Definition: GlobalValue.h:280
void setLinkage(LinkageTypes LT)
Definition: GlobalValue.h:539
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
Definition: GlobalValue.h:283
bool isDeclarationForLinker() const
Definition: GlobalValue.h:625
Comdat * getComdat()
Definition: GlobalValue.h:245
bool hasSanitizerMetadata() const
Definition: GlobalValue.h:357
static UnnamedAddr getMinUnnamedAddr(UnnamedAddr A, UnnamedAddr B)
Definition: GlobalValue.h:235
GlobalObject * getAliaseeObject()
Definition: GlobalValue.h:643
unsigned getAddressSpace() const
Definition: GlobalValue.h:207
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
Definition: GlobalValue.h:600
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...
Definition: GlobalValue.h:663
static bool isCommonLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:417
LLVM_ABI const GlobalObject * getAliaseeObject() const
Definition: Globals.cpp:419
void setDSOLocal(bool Local)
Definition: GlobalValue.h:305
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
Definition: GlobalValue.h:528
LLVM_ABI void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
Definition: Globals.cpp:93
static bool isPrivateLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:408
bool isDiscardableIfUnused() const
Definition: GlobalValue.h:550
static bool isExternalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:378
bool isStrongDefinitionForLinker() const
Returns true if this global's definition will be the one chosen by the linker.
Definition: GlobalValue.h:638
PointerType * getType() const
Global values are always pointers.
Definition: GlobalValue.h:296
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)
Definition: GlobalValue.h:420
static const unsigned GlobalValueSubClassDataBits
Definition: GlobalValue.h:96
static bool isInternalLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:405
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
Definition: GlobalValue.h:292
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)
Definition: GlobalValue.h:256
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
Definition: GlobalValue.h:243
static bool isInterposableLinkage(LinkageTypes Linkage)
Whether the definition of this global may be replaced by something non-equivalent at link time.
Definition: GlobalValue.h:427
bool hasWeakLinkage() const
Definition: GlobalValue.h:524
bool hasAtLeastLocalUnnamedAddr() const
Returns true if this value's address is not significant in this module.
Definition: GlobalValue.h:226
unsigned getGlobalValueSubClassData() const
Definition: GlobalValue.h:177
static LinkageTypes getWeakLinkage(bool ODR)
Definition: GlobalValue.h:374
bool hasWeakODRLinkage() const
Definition: GlobalValue.h:526
void setGlobalValueSubClassData(unsigned V)
Definition: GlobalValue.h:180
unsigned IsDSOLocal
If true then there is a definition within the same linkage unit and that definition cannot be runtime...
Definition: GlobalValue.h:115
static LinkageTypes getLinkOnceLinkage(bool ODR)
Definition: GlobalValue.h:371
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
Definition: GlobalValue.h:554
bool hasCommonLinkage() const
Definition: GlobalValue.h:534
bool hasGlobalUnnamedAddr() const
Definition: GlobalValue.h:217
LLVM_ABI Error materialize()
Make sure this GlobalValue is fully read.
Definition: Globals.cpp:49
UnnamedAddr getUnnamedAddr() const
Definition: GlobalValue.h:230
static bool isWeakForLinker(LinkageTypes Linkage)
Whether the definition of this global may be replaced at link time.
Definition: GlobalValue.h:460
GlobalValue(const GlobalValue &)=delete
bool hasAppendingLinkage() const
Definition: GlobalValue.h:527
unsigned ThreadLocal
Definition: GlobalValue.h:105
static bool isWeakLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:399
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:451
LLVM_ABI void setSanitizerMetadata(SanitizerMetadata Meta)
Definition: Globals.cpp:251
static bool classof(const Value *V)
Definition: GlobalValue.h:672
bool hasLinkOnceODRLinkage() const
Definition: GlobalValue.h:521
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
Definition: GlobalValue.h:514
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)
Definition: GlobalValue.h:266
DLLStorageClassTypes getDLLStorageClass() const
Definition: GlobalValue.h:277
Type * getValueType() const
Definition: GlobalValue.h:298
GlobalValue(Type *Ty, ValueTy VTy, AllocInfo AllocInfo, LinkageTypes Linkage, const Twine &Name, unsigned AddressSpace)
Definition: GlobalValue.h:81
static bool isLinkOnceODRLinkage(LinkageTypes Linkage)
Definition: GlobalValue.h:387
bool hasProtectedVisibility() const
Definition: GlobalValue.h:253
unsigned DllStorageClass
Definition: GlobalValue.h:103
unsigned UnnamedAddrVal
Definition: GlobalValue.h:102
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.
Definition: DerivedTypes.h:700
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Definition: DerivedTypes.h:740
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:1098
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 is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
constexpr char GlobalIdentifierDelimiter
Definition: GlobalValue.h:47
Information about how a User object was allocated, to be passed into the User constructor.
Definition: User.h:79