LLVM 23.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
168 /// Returns true if the global is a function definition with the noipa
169 /// attribute.
170 LLVM_ABI bool isNoipaFnDef() const;
171
172protected:
173 /// The intrinsic ID for this subclass (which must be a Function).
174 ///
175 /// This member is defined by this class, but not used for anything.
176 /// Subclasses can use it to store their intrinsic ID, if they have one.
177 ///
178 /// This is stored here to save space in Function on 64-bit hosts.
180
181 unsigned getGlobalValueSubClassData() const {
182 return SubClassData;
183 }
184 void setGlobalValueSubClassData(unsigned V) {
185 assert(V < (1 << GlobalValueSubClassDataBits) && "It will not fit");
186 SubClassData = V;
187 }
188
189 Module *Parent = nullptr; // The containing module.
190
191 // Used by SymbolTableListTraits.
192 void setParent(Module *parent) {
193 Parent = parent;
194 }
195
197 removeDeadConstantUsers(); // remove any dead constants using this.
198 }
199
200public:
208
209 GlobalValue(const GlobalValue &) = delete;
210
211 unsigned getAddressSpace() const {
212 return getType()->getAddressSpace();
213 }
214
215 enum class UnnamedAddr {
219 };
220
221 bool hasGlobalUnnamedAddr() const {
223 }
224
225 /// Returns true if this value's address is not significant in this module.
226 /// This attribute is intended to be used only by the code generator and LTO
227 /// to allow the linker to decide whether the global needs to be in the symbol
228 /// table. It should probably not be used in optimizations, as the value may
229 /// have uses outside the module; use hasGlobalUnnamedAddr() instead.
232 }
233
238
246
247 bool hasComdat() const { return getComdat() != nullptr; }
248 LLVM_ABI const Comdat *getComdat() const;
250 return const_cast<Comdat *>(
251 static_cast<const GlobalValue *>(this)->getComdat());
252 }
253
259 }
262 "local linkage requires default visibility");
263 Visibility = V;
264 if (isImplicitDSOLocal())
265 setDSOLocal(true);
266 }
267
268 /// If the value is "Thread Local", its value isn't shared by the threads.
269 bool isThreadLocal() const { return getThreadLocalMode() != NotThreadLocal; }
274 assert(Val == NotThreadLocal || getValueID() != Value::FunctionVal);
275 ThreadLocal = Val;
276 }
278 return static_cast<ThreadLocalMode>(ThreadLocal);
279 }
280
292 "local linkage requires DefaultStorageClass");
294 }
295
296 bool hasSection() const { return !getSection().empty(); }
298
299 /// Global values are always pointers.
301
302 Type *getValueType() const { return ValueType; }
303
304 bool isImplicitDSOLocal() const {
305 return hasLocalLinkage() ||
307 }
308
310
311 bool isDSOLocal() const {
312 return IsDSOLocal;
313 }
314
315 bool hasPartition() const {
316 return HasPartition;
317 }
320
321 // ASan, HWASan and Memtag sanitizers have some instrumentation that applies
322 // specifically to global variables.
327 // For ASan and HWASan, this instrumentation is implicitly applied to all
328 // global variables when built with -fsanitize=*. What we need is a way to
329 // persist the information that a certain global variable should *not* have
330 // sanitizers applied, which occurs if:
331 // 1. The global variable is in the sanitizer ignore list, or
332 // 2. The global variable is created by the sanitizers itself for internal
333 // usage, or
334 // 3. The global variable has __attribute__((no_sanitize("..."))) or
335 // __attribute__((disable_sanitizer_instrumentation)).
336 //
337 // This is important, a some IR passes like GlobalMerge can delete global
338 // variables and replace them with new ones. If the old variables were
339 // marked to be unsanitized, then the new ones should also be.
340 unsigned NoAddress : 1;
341 unsigned NoHWAddress : 1;
342
343 // Memtag sanitization works differently: sanitization is requested by clang
344 // when `-fsanitize=memtag-globals` is provided, and the request can be
345 // denied (and the attribute removed) by the AArch64 global tagging pass if
346 // it can't be fulfilled (e.g. the global variable is a TLS variable).
347 // Memtag sanitization has to interact with other parts of LLVM (like
348 // supressing certain optimisations, emitting assembly directives, or
349 // creating special relocation sections).
350 //
351 // Use `GlobalValue::isTagged()` to check whether tagging should be enabled
352 // for a global variable.
353 unsigned Memtag : 1;
354
355 // ASan-specific metadata. Is this global variable dynamically initialized
356 // (from a C++ language perspective), and should therefore be checked for
357 // ODR violations.
358 unsigned IsDynInit : 1;
359 };
360
363 // Note: Not byref as it's a POD and otherwise it's too easy to call
364 // G.setSanitizerMetadata(G2.getSanitizerMetadata()), and the argument becomes
365 // dangling when the backing storage allocates the metadata for `G`, as the
366 // storage is shared between `G1` and `G2`.
370
371 bool isTagged() const {
373 }
374
377 }
378 static LinkageTypes getWeakLinkage(bool ODR) {
379 return ODR ? WeakODRLinkage : WeakAnyLinkage;
380 }
381
383 return Linkage == ExternalLinkage;
384 }
398 return Linkage == WeakAnyLinkage;
399 }
401 return Linkage == WeakODRLinkage;
402 }
410 return Linkage == InternalLinkage;
411 }
413 return Linkage == PrivateLinkage;
414 }
422 return Linkage == CommonLinkage;
423 }
427
428 /// Whether the definition of this global may be replaced by something
429 /// non-equivalent at link time. For example, if a function has weak linkage
430 /// then the code defining it may be replaced by different code.
432 switch (Linkage) {
433 case WeakAnyLinkage:
435 case CommonLinkage:
437 return true;
438
441 case WeakODRLinkage:
442 // The above three cannot be overridden but can be de-refined.
443
444 case ExternalLinkage:
445 case AppendingLinkage:
446 case InternalLinkage:
447 case PrivateLinkage:
448 return false;
449 }
450 llvm_unreachable("Fully covered switch above!");
451 }
452
453 /// Whether the definition of this global may be discarded if it is not used
454 /// in its compilation unit.
459
460 /// Whether the definition of this global may be replaced at link time. NB:
461 /// Using this method outside of the code generators is almost always a
462 /// mistake: when working at the IR level use isInterposable instead as it
463 /// knows about ODR semantics.
469
470 /// Return true if the currently visible definition of this global (if any) is
471 /// exactly the definition we will see at runtime.
472 ///
473 /// Non-exact linkage types inhibits most non-inlining IPO, since a
474 /// differently optimized variant of the same function can have different
475 /// observable or undefined behavior than in the variant currently visible.
476 /// For instance, we could have started with
477 ///
478 /// void foo(int *v) {
479 /// int t = 5 / v[0];
480 /// (void) t;
481 /// }
482 ///
483 /// and "refined" it to
484 ///
485 /// void foo(int *v) { }
486 ///
487 /// However, we cannot infer readnone for `foo`, since that would justify
488 /// DSE'ing a store to `v[0]` across a call to `foo`, which can cause
489 /// undefined behavior if the linker replaces the actual call destination with
490 /// the unoptimized `foo`.
491 ///
492 /// Inlining is okay across non-exact linkage types as long as they're not
493 /// interposable (see \c isInterposable), since in such cases the currently
494 /// visible variant is *a* correct implementation of the original source
495 /// function; it just isn't the *only* correct implementation.
496 bool isDefinitionExact() const {
497 return !mayBeDerefined();
498 }
499
500 /// Return true if this global has an exact defintion.
501 bool hasExactDefinition() const {
502 // While this computes exactly the same thing as
503 // isStrongDefinitionForLinker, the intended uses are different. This
504 // function is intended to help decide if specific inter-procedural
505 // transforms are correct, while isStrongDefinitionForLinker's intended use
506 // is in low level code generation.
507 return !isDeclaration() && isDefinitionExact();
508 }
509
510 /// Return true if this global's definition can be substituted with an
511 /// *arbitrary* definition at link time or load time. We cannot do any IPO or
512 /// inlining across interposable call edges, since the callee can be
513 /// replaced with something arbitrary. For most IPO passes, the `noipa`
514 /// attribute on a function definition is also treated as if it were
515 /// interposable (and thus blocking interprocedural analysis). Passes
516 /// which already have their own distinct control attributes (e.g. inlining)
517 /// may set `CheckNoIPA = false` when calling this.
518 LLVM_ABI bool isInterposable(bool CheckNoIPA = true) const;
520
528 }
531 }
532 bool hasWeakLinkage() const { return isWeakLinkage(getLinkage()); }
538 bool hasLocalLinkage() const { return isLocalLinkage(getLinkage()); }
541 }
542 bool hasCommonLinkage() const { return isCommonLinkage(getLinkage()); }
546
548 if (isLocalLinkage(LT)) {
551 }
552 Linkage = LT;
553 if (isImplicitDSOLocal())
554 setDSOLocal(true);
555 }
557
560 }
561
562 bool isWeakForLinker() const { return isWeakForLinker(getLinkage()); }
563
564protected:
565 /// Copy all additional attributes (those not needed to create a GlobalValue)
566 /// from the GlobalValue Src to this one.
567 LLVM_ABI void copyAttributesFrom(const GlobalValue *Src);
568
569public:
570 /// If the given string begins with the GlobalValue name mangling escape
571 /// character '\1', drop it.
572 ///
573 /// This function applies a specific mangling that is used in PGO profiles,
574 /// among other things. If you're trying to get a symbol name for an
575 /// arbitrary GlobalValue, this is not the function you're looking for; see
576 /// Mangler.h.
578 Name.consume_front("\1");
579 return Name;
580 }
581
582 /// Declare a type to represent a global unique identifier for a global value.
583 /// This is a 64 bits hash that is used by PGO and ThinLTO to have a compact
584 /// unique way to identify a symbol.
585 using GUID = uint64_t;
586
587 /// Return the modified name for a global value suitable to be
588 /// used as the key for a global lookup (e.g. profile or ThinLTO).
589 /// The value's original name is \c Name and has linkage of type
590 /// \c Linkage. The value is defined in module \c FileName.
591 LLVM_ABI static std::string
593 StringRef FileName);
594
595private:
596 /// Return the modified name for this global value suitable to be
597 /// used as the key for a global lookup (e.g. profile or ThinLTO).
598 LLVM_ABI std::string getGlobalIdentifier() const;
599
600public:
601 /// Return a 64-bit global unique ID constructed from the name of a global
602 /// symbol. Since this call doesn't supply the linkage or defining filename,
603 /// the GUID computation will assume that the global has external linkage.
605
606 /// Return a 64-bit global unique ID constructed from global value name
607 /// (i.e. returned by getGlobalIdentifier()).
611
612 /// @name Materialization
613 /// Materialization is used to construct functions only as they're needed.
614 /// This
615 /// is useful to reduce memory usage in LLVM or parsing work done by the
616 /// BitcodeReader to load the Module.
617 /// @{
618
619 /// If this function's Module is being lazily streamed in functions from disk
620 /// or some other source, this method can be used to check to see if the
621 /// function has been read in yet or not.
622 LLVM_ABI bool isMaterializable() const;
623
624 /// Make sure this GlobalValue is fully read.
626
627 /// @}
628
629 /// Return true if the primary definition of this global value is outside of
630 /// the current translation unit.
631 LLVM_ABI bool isDeclaration() const;
632
635 return true;
636
637 return isDeclaration();
638 }
639
640 /// Returns true if this global's definition will be the one chosen by the
641 /// linker.
642 ///
643 /// NB! Ideally this should not be used at the IR level at all. If you're
644 /// interested in optimization constraints implied by the linker's ability to
645 /// choose an implementation, prefer using \c hasExactDefinition.
648 }
649
652 return const_cast<GlobalObject *>(
653 static_cast<const GlobalValue *>(this)->getAliaseeObject());
654 }
655
656 /// Returns whether this is a reference to an absolute symbol.
657 LLVM_ABI bool isAbsoluteSymbolRef() const;
658
659 /// If this is an absolute symbol reference, returns the range of the symbol,
660 /// otherwise returns std::nullopt.
661 LLVM_ABI std::optional<ConstantRange> getAbsoluteSymbolRange() const;
662
663 /// This method unlinks 'this' from the containing module, but does not delete
664 /// it.
666
667 /// This method unlinks 'this' from the containing module and deletes it.
669
670 /// Get the module that this global value is contained inside of...
671 Module *getParent() { return Parent; }
672 const Module *getParent() const { return Parent; }
673
674 /// Get the data layout of the module this global belongs to.
675 ///
676 /// Requires the global to have a parent module.
677 LLVM_ABI const DataLayout &getDataLayout() const;
678
679 // Methods for support type inquiry through isa, cast, and dyn_cast:
680 static bool classof(const Value *V) {
681 return V->getValueID() == Value::FunctionVal ||
682 V->getValueID() == Value::GlobalVariableVal ||
683 V->getValueID() == Value::GlobalAliasVal ||
684 V->getValueID() == Value::GlobalIFuncVal;
685 }
686
687 /// True if GV can be left out of the object symbol table. This is the case
688 /// for linkonce_odr values whose address is not significant. While legal, it
689 /// is not normally profitable to omit them from the .o symbol table. Using
690 /// this analysis makes sense when the information can be passed down to the
691 /// linker or we are in LTO.
693};
694
695} // end namespace llvm
696
697#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:215
GlobalValue::SanitizerMetadata SanitizerMetadata
Definition Globals.cpp:255
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:64
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:80
LLVM_ABI const SanitizerMetadata & getSanitizerMetadata() const
Definition Globals.cpp:256
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:267
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:346
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:464
bool isTagged() const
void setDLLStorageClass(DLLStorageClassTypes C)
LLVM_ABI const Comdat * getComdat() const
Definition Globals.cpp:212
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:202
LLVM_ABI StringRef getPartition() const
Definition Globals.cpp:233
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:459
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:472
bool hasInternalLinkage() const
LLVM_ABI void eraseFromParent()
This method unlinks 'this' from the containing module and deletes it.
Definition Globals.cpp:96
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:66
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:172
LLVM_ABI void setNoSanitizeMetadata()
Definition Globals.cpp:274
bool hasSection() const
void setVisibility(VisibilityTypes V)
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this global belongs to.
Definition Globals.cpp:143
LLVM_ABI bool canBenefitFromLocalAlias() const
Definition Globals.cpp:125
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:47
bool isWeakForLinker() const
bool hasCommonLinkage() const
bool hasGlobalUnnamedAddr() const
LLVM_ABI Error materialize()
Make sure this GlobalValue is fully read.
Definition Globals.cpp:52
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:262
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:484
LLVM_ABI void removeFromParent()
This method unlinks 'this' from the containing module, but does not delete it.
Definition Globals.cpp:84
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
LLVM_ABI bool isInterposable(bool CheckNoIPA=true) const
Return true if this global's definition can be substituted with an arbitrary definition at link time ...
Definition Globals.cpp:116
unsigned DllStorageClass
unsigned UnnamedAddrVal
LLVM_ABI void setPartition(StringRef Part)
Definition Globals.cpp:239
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.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
constexpr bool empty() const
Check if the string is empty.
Definition StringRef.h:141
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:46
LLVM Value Representation.
Definition Value.h:75
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:255
LLVM_ABI void setName(const Twine &Name)
Change the name of the value.
Definition Value.cpp:394
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:258
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition Value.h:543
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:559
Information about how a User object was allocated, to be passed into the User constructor.
Definition User.h:79