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