LLVM 24.0.0git
Value.h
Go to the documentation of this file.
1//===- llvm/Value.h - Definition of the Value class -------------*- 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 declares the Value class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_IR_VALUE_H
14#define LLVM_IR_VALUE_H
15
16#include "llvm-c/Types.h"
17#include "llvm/ADT/STLExtras.h"
18#include "llvm/ADT/StringRef.h"
20#include "llvm/IR/Type.h"
21#include "llvm/IR/Use.h"
26#include <cassert>
27#include <iterator>
28#include <memory>
29
30namespace llvm {
31
32class APInt;
33class Argument;
34class BasicBlock;
35class Constant;
36class ConstantData;
38class DataLayout;
39class Function;
40class GlobalAlias;
41class GlobalIFunc;
42class GlobalObject;
43class GlobalValue;
44class GlobalVariable;
45class InlineAsm;
46class Instruction;
47class LLVMContext;
48class MDNode;
49class Module;
51class raw_ostream;
52template<typename ValueTy> class StringMapEntry;
53class Twine;
54class User;
55
57
58//===----------------------------------------------------------------------===//
59// Value Class
60//===----------------------------------------------------------------------===//
61
62/// LLVM Value Representation
63///
64/// This is a very important LLVM class. It is the base class of all values
65/// computed by a program that may be used as operands to other values. Value is
66/// the super class of other important classes such as Instruction and Function.
67/// All Values have a Type. Type is not a subclass of Value. Some values can
68/// have a name and they belong to some Module. Setting the name on the Value
69/// automatically updates the module's symbol table.
70///
71/// Every value has a "use list" that keeps track of which other Values are
72/// using this Value. A Value can also have an arbitrary number of ValueHandle
73/// objects that watch it and listen to RAUW and Destroy events. See
74/// llvm/IR/ValueHandle.h for details.
75class Value {
76 const unsigned char SubclassID; // Subclass identifier (for isa/dyn_cast)
77 unsigned char HasValueHandle : 1; // Has a ValueHandle pointing to this?
78
79protected:
80 /// Hold arbitary subclass data.
81 ///
82 /// This member is similar to SubclassData, however it is often used for
83 /// holding information which may be used to aid optimization, but which may
84 /// be cleared to zero without affecting conservative interpretation.
85 unsigned char SubclassOptionalData : 7;
86
87private:
88 /// Hold arbitrary subclass data.
89 ///
90 /// This member is defined by this class, but is not used for anything.
91 /// Subclasses can use it to hold whatever state they find useful. This
92 /// field is initialized to zero by the ctor.
93 unsigned short SubclassData;
94
95protected:
96 /// The number of operands in the subclass.
97 ///
98 /// This member is defined by this class, but not used for anything.
99 /// Subclasses can use it to store their number of operands, if they have
100 /// any.
101 ///
102 /// This is stored here to save space in User on 64-bit hosts. Since most
103 /// instances of Value have operands, 32-bit hosts aren't significantly
104 /// affected.
105 ///
106 /// Note, this should *NOT* be used directly by any class other than User.
107 /// User uses this value to find the Use list.
108 enum : unsigned { NumUserOperandsBits = 28 };
110
111 // Use the same type as the bitfield above so that MSVC will pack them.
112 unsigned IsUsedByMD : 1;
113 unsigned HasName : 1;
114 unsigned HasHungOffUses : 1;
115 unsigned HasDescriptor : 1;
116
117private:
118 Type *VTy;
119
120protected:
121 Use *UseList = nullptr;
122
123private:
124 friend class ValueAsMetadata; // Allow access to IsUsedByMD.
125 friend class ValueHandleBase; // Allow access to HasValueHandle.
126
127 template <typename UseT> // UseT == 'Use' or 'const Use'
128 class use_iterator_impl {
129 friend class Value;
130
131 UseT *U;
132
133 explicit use_iterator_impl(UseT *u) : U(u) {}
134
135 public:
136 using iterator_category = std::forward_iterator_tag;
137 using value_type = UseT;
138 using difference_type = std::ptrdiff_t;
139 using pointer = value_type *;
140 using reference = value_type &;
141
142 use_iterator_impl() : U() {}
143
144 bool operator==(const use_iterator_impl &x) const { return U == x.U; }
145 bool operator!=(const use_iterator_impl &x) const { return !operator==(x); }
146
147 use_iterator_impl &operator++() { // Preincrement
148 assert(U && "Cannot increment end iterator!");
149 U = U->getNext();
150 return *this;
151 }
152
153 use_iterator_impl operator++(int) { // Postincrement
154 auto tmp = *this;
155 ++*this;
156 return tmp;
157 }
158
159 UseT &operator*() const {
160 assert(U && "Cannot dereference end iterator!");
161 return *U;
162 }
163
164 UseT *operator->() const { return &operator*(); }
165
166 operator use_iterator_impl<const UseT>() const {
167 return use_iterator_impl<const UseT>(U);
168 }
169 };
170
171protected:
172 template <typename UserTy> // UserTy == 'User' or 'const User'
173 class user_iterator_impl {
174 use_iterator_impl<Use> UI;
175 explicit user_iterator_impl(Use *U) : UI(U) {}
176 friend class Value;
177 friend class Instruction;
178
179 public:
180 using iterator_category = std::forward_iterator_tag;
181 using value_type = UserTy *;
182 using difference_type = std::ptrdiff_t;
185
187
188 bool operator==(const user_iterator_impl &x) const { return UI == x.UI; }
189 bool operator!=(const user_iterator_impl &x) const { return !operator==(x); }
190
191 /// Returns true if this iterator is equal to user_end() on the value.
192 bool atEnd() const { return *this == user_iterator_impl(); }
193
194 user_iterator_impl &operator++() { // Preincrement
195 ++UI;
196 return *this;
197 }
198
199 user_iterator_impl operator++(int) { // Postincrement
200 auto tmp = *this;
201 ++*this;
202 return tmp;
203 }
204
205 // Retrieve a pointer to the current User.
206 UserTy *operator*() const { return cast<UserTy>(UI->getUser()); }
207
208 UserTy *operator->() const { return operator*(); }
209
213
214 Use &getUse() const { return *UI; }
215 };
216
217 LLVM_ABI Value(Type *Ty, unsigned scid);
218
219 /// Value's destructor should be virtual by design, but that would require
220 /// that Value and all of its subclasses have a vtable that effectively
221 /// duplicates the information in the value ID. As a size optimization, the
222 /// destructor has been protected, and the caller should manually call
223 /// deleteValue.
224 LLVM_ABI ~Value(); // Use deleteValue() to delete a generic Value.
225
226public:
227 Value(const Value &) = delete;
228 Value &operator=(const Value &) = delete;
229
230 /// Delete a pointer to a generic Value.
231 LLVM_ABI void deleteValue();
232
233 /// Support for debugging, callable in GDB: V->dump()
234 LLVM_ABI void dump() const;
235
236 /// Implement operator<< on Value.
237 /// @{
238 LLVM_ABI void print(raw_ostream &O, bool IsForDebug = false) const;
240 bool IsForDebug = false) const;
241 /// @}
242
243 /// Print the name of this Value out to the specified raw_ostream.
244 ///
245 /// This is useful when you just want to print 'int %reg126', not the
246 /// instruction that generated it. If you specify a Module for context, then
247 /// even constants get pretty-printed; for example, the type of a null
248 /// pointer is printed symbolically.
249 /// @{
250 LLVM_ABI void printAsOperand(raw_ostream &O, bool PrintType = true,
251 const Module *M = nullptr) const;
252 LLVM_ABI void printAsOperand(raw_ostream &O, bool PrintType,
253 ModuleSlotTracker &MST) const;
254 /// @}
255
256 /// All values are typed, get the type of this value.
257 Type *getType() const { return VTy; }
258
259 /// All values hold a context through their type.
260 LLVMContext &getContext() const { return VTy->getContext(); }
261
262 // All values can potentially be named.
263 bool hasName() const { return HasName; }
266
267private:
268 void destroyValueName();
269 enum class ReplaceMetadataUses { No, Yes };
270 void doRAUW(Value *New, ReplaceMetadataUses);
271 void setNameImpl(const Twine &Name);
272
273public:
274 /// Return a constant reference to the value's name.
275 ///
276 /// This guaranteed to return the same reference as long as the value is not
277 /// modified. If the value has a name, this does a hashtable lookup, so it's
278 /// not free.
279 LLVM_ABI StringRef getName() const;
280
281 /// Change the name of the value.
282 ///
283 /// Choose a new unique name if the provided name is taken.
284 ///
285 /// \param Name The new name; or "" if the value's name should be removed.
286 LLVM_ABI void setName(const Twine &Name);
287
288 /// Transfer the name from V to this value.
289 ///
290 /// After taking V's name, sets V's name to empty.
291 ///
292 /// \note It is an error to call V->takeName(V).
293 LLVM_ABI void takeName(Value *V);
294
295 LLVM_ABI std::string getNameOrAsOperand() const;
296
297 /// Change all uses of this to point to a new Value.
298 ///
299 /// Go through the uses list for this definition and make each use point to
300 /// "V" instead of "this". After this completes, 'this's use list is
301 /// guaranteed to be empty.
302 LLVM_ABI void replaceAllUsesWith(Value *V);
303
304 /// Change non-metadata uses of this to point to a new Value.
305 ///
306 /// Go through the uses list for this definition and make each use point to
307 /// "V" instead of "this". This function skips metadata entries in the list.
309
310 /// Go through the uses list for this definition and make each use point
311 /// to "V" if the callback ShouldReplace returns true for the given Use.
312 /// Unlike replaceAllUsesWith() this function does not support basic block
313 /// values.
314 /// Returns whether any uses have been replaced.
315 LLVM_ABI bool
316 replaceUsesWithIf(Value *New, llvm::function_ref<bool(Use &U)> ShouldReplace);
317
318 /// replaceUsesOutsideBlock - Go through the uses list for this definition and
319 /// make each use point to "V" instead of "this" when the use is outside the
320 /// block. 'This's use list is expected to have at least one element.
321 /// Unlike replaceAllUsesWith() this function does not support basic block
322 /// values.
323 LLVM_ABI void replaceUsesOutsideBlock(Value *V, BasicBlock *BB);
324
325 //----------------------------------------------------------------------
326 // Methods for handling the chain of uses of this Value.
327 //
328 // Materializing a function can introduce new uses, so these methods come in
329 // two variants:
330 // The methods that start with materialized_ check the uses that are
331 // currently known given which functions are materialized. Be very careful
332 // when using them since you might not get all uses.
333 // The methods that don't start with materialized_ assert that modules is
334 // fully materialized.
336 // This indirection exists so we can keep assertModuleIsMaterializedImpl()
337 // around in release builds of Value.cpp to be linked with other code built
338 // in debug mode. But this avoids calling it in any of the release built code.
340#ifndef NDEBUG
342#endif
343 }
344
345 /// Check if this Value has a use-list.
346 bool hasUseList() const { return !isa<ConstantData>(this); }
347
348 bool use_empty() const {
350 return UseList == nullptr;
351 }
352
353 bool materialized_use_empty() const { return UseList == nullptr; }
354
355 using use_iterator = use_iterator_impl<Use>;
356 using const_use_iterator = use_iterator_impl<const Use>;
357
390
391 bool user_empty() const { return use_empty(); }
392
395
418 const User *user_back() const {
420 return *materialized_user_begin();
421 }
436
437 /// Return true if there is exactly one use of this value.
438 ///
439 /// This is specialized because it is a common request and does not require
440 /// traversing the whole use list.
441 bool hasOneUse() const { return UseList && hasSingleElement(uses()); }
442
443 /// Return true if this Value has exactly N uses.
444 LLVM_ABI bool hasNUses(unsigned N) const;
445
446 /// Return true if this value has N uses or more.
447 ///
448 /// This is logically equivalent to getNumUses() >= N.
449 LLVM_ABI bool hasNUsesOrMore(unsigned N) const;
450
451 /// Return true if there is exactly one user of this value.
452 ///
453 /// Note that this is not the same as "has one use". If a value has one use,
454 /// then there certainly is a single user. But if value has several uses,
455 /// it is possible that all uses are in a single user, or not.
456 ///
457 /// This check is potentially costly, since it requires traversing,
458 /// in the worst case, the whole use list of a value.
459 LLVM_ABI bool hasOneUser() const;
460
461 /// Return true if there is exactly one use of this value that cannot be
462 /// dropped.
465 return const_cast<Value *>(this)->getSingleUndroppableUse();
466 }
467
468 /// Return true if there is exactly one unique user of this value that cannot be
469 /// dropped (that user can have multiple uses of this value).
472 return const_cast<Value *>(this)->getUniqueUndroppableUser();
473 }
474
475 /// Return true if there this value.
476 ///
477 /// This is specialized because it is a common request and does not require
478 /// traversing the whole use list.
479 LLVM_ABI bool hasNUndroppableUses(unsigned N) const;
480
481 /// Return true if this value has N uses or more.
482 ///
483 /// This is logically equivalent to getNumUses() >= N.
484 LLVM_ABI bool hasNUndroppableUsesOrMore(unsigned N) const;
485
486 /// Remove every uses that can safely be removed.
487 ///
488 /// This will remove for example uses in llvm.assume.
489 /// This should be used when performing want to perform a transformation but
490 /// some Droppable uses prevent it.
491 /// This function optionally takes a filter to only remove some droppable
492 /// uses.
493 LLVM_ABI void
494 dropDroppableUses(llvm::function_ref<bool(const Use *)> ShouldDrop =
495 [](const Use *) { return true; });
496
497 /// Remove every use of this value in \p User that can safely be removed.
498 LLVM_ABI void dropDroppableUsesIn(User &Usr);
499
500 /// Remove the droppable use \p U.
501 LLVM_ABI static void dropDroppableUse(Use &U);
502
503 /// Check if this value is used in the specified basic block.
504 ///
505 /// Not supported for ConstantData.
506 LLVM_ABI bool isUsedInBasicBlock(const BasicBlock *BB) const;
507
508 /// This method computes the number of uses of this Value.
509 ///
510 /// This is a linear time operation. Use hasOneUse, hasNUses, or
511 /// hasNUsesOrMore to check for specific values.
512 LLVM_ABI unsigned getNumUses() const;
513
514 /// This method should only be used by the Use class.
515 void addUse(Use &U) {
516 if (hasUseList())
517 U.addToList(&UseList);
518 }
519
520 /// Concrete subclass of this.
521 ///
522 /// An enumeration for keeping track of the concrete subclass of Value that
523 /// is actually instantiated. Values of this enumeration are kept in the
524 /// Value classes SubclassID field. They are used for concrete type
525 /// identification.
526 enum ValueTy {
527#define HANDLE_VALUE(Name) Name##Val,
528#include "llvm/IR/Value.def"
529
530 // Markers:
531#define HANDLE_CONSTANT_MARKER(Marker, Constant) Marker = Constant##Val,
532#include "llvm/IR/Value.def"
533 };
534
535 /// Return an ID for the concrete type of this object.
536 ///
537 /// This is used to implement the classof checks. This should not be used
538 /// for any other purpose, as the values may change as LLVM evolves. Also,
539 /// note that for instructions, the Instruction's opcode is added to
540 /// InstructionVal. So this means three things:
541 /// # there is no value with code InstructionVal (no opcode==0).
542 /// # there are more possible values for the value type than in ValueTy enum.
543 /// # the InstructionVal enumerator must be the highest valued enumerator in
544 /// the ValueTy enum.
545 unsigned getValueID() const {
546 return SubclassID;
547 }
548
549 /// Return the raw optional flags value contained in this value.
550 ///
551 /// This should only be used when testing two Values for equivalence.
552 unsigned getRawSubclassOptionalData() const {
554 }
555
556 /// Return true if there is a value handle associated with this value.
557 bool hasValueHandle() const { return HasValueHandle; }
558
559 /// Return true if there is metadata referencing this value.
560 bool isUsedByMetadata() const { return IsUsedByMD; }
561
562protected:
563 /// Get the current metadata attachments for the given kind, if any.
564 ///
565 /// These functions require that the value have at most a single attachment
566 /// of the given kind, and return \c nullptr if such an attachment is missing.
567 /// @{
569 /// @}
570
571private:
572 LLVM_ABI unsigned getMetadataIndex() const;
573 LLVM_ABI unsigned &getMetadataIndex();
574
575protected:
576 /// Appends all metadata attached to this value to \c MDs, sorting by
577 /// KindID. The first element of each pair returned is the KindID, the second
578 /// element is the metadata value. Attachments with the same ID appear in
579 /// insertion order.
580 LLVM_ABI void
581 getAllMetadata(SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const;
582
583 /// Set a particular kind of metadata attachment.
584 ///
585 /// Sets the given attachment to \c MD, erasing it if \c MD is \c nullptr or
586 /// replacing it if it already exists.
587 /// @{
588 LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node);
590 /// @}
591
592 /// Add a metadata attachment.
593 /// @{
594 LLVM_ABI void addMetadata(unsigned KindID, MDNode &MD);
595 LLVM_ABI void addMetadata(StringRef Kind, MDNode &MD);
596 /// @}
597
598 /// Erase all metadata attachments with the given kind.
599 ///
600 /// \returns true if any metadata was removed.
601 LLVM_ABI bool eraseMetadata(unsigned KindID);
602
603 /// Erase all metadata attachments matching the given predicate.
604 LLVM_ABI void eraseMetadataIf(function_ref<bool(unsigned, MDNode *)> Pred);
605
606 /// Erase all metadata attached to this Value.
607 LLVM_ABI void clearMetadata();
608
609 /// Get metadata for the given kind, if any.
610 /// This is an internal function that must only be called after
611 /// checking that `hasMetadata()` returns true.
612 LLVM_ABI MDNode *getMetadataImpl(unsigned KindID) const LLVM_READONLY;
613
614public:
615 /// Return true if this value is a swifterror value.
616 ///
617 /// swifterror values can be either a function argument or an alloca with a
618 /// swifterror attribute.
619 LLVM_ABI bool isSwiftError() const;
620
621 /// Strip off pointer casts, all-zero GEPs and address space casts.
622 ///
623 /// Returns the original uncasted value. If this is called on a non-pointer
624 /// value, it returns 'this'.
625 LLVM_ABI const Value *stripPointerCasts() const;
627 return const_cast<Value *>(
628 static_cast<const Value *>(this)->stripPointerCasts());
629 }
630
631 /// Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
632 ///
633 /// Returns the original uncasted value. If this is called on a non-pointer
634 /// value, it returns 'this'.
637 return const_cast<Value *>(
638 static_cast<const Value *>(this)->stripPointerCastsAndAliases());
639 }
640
641 /// Strip off pointer casts, all-zero GEPs and address space casts
642 /// but ensures the representation of the result stays the same.
643 ///
644 /// Returns the original uncasted value with the same representation. If this
645 /// is called on a non-pointer value, it returns 'this'.
648 return const_cast<Value *>(static_cast<const Value *>(this)
649 ->stripPointerCastsSameRepresentation());
650 }
651
652 /// Strip off pointer casts, all-zero GEPs, single-argument phi nodes and
653 /// invariant group info.
654 ///
655 /// Returns the original uncasted value. If this is called on a non-pointer
656 /// value, it returns 'this'. This function should be used only in
657 /// Alias analysis.
660 return const_cast<Value *>(static_cast<const Value *>(this)
661 ->stripPointerCastsForAliasAnalysis());
662 }
663
664 /// Strip off pointer casts and all-constant inbounds GEPs.
665 ///
666 /// Returns the original pointer value. If this is called on a non-pointer
667 /// value, it returns 'this'.
670 return const_cast<Value *>(
671 static_cast<const Value *>(this)->stripInBoundsConstantOffsets());
672 }
673
674 /// Accumulate the constant offset this value has compared to a base pointer.
675 /// Only 'getelementptr' instructions (GEPs) are accumulated but other
676 /// instructions, e.g., casts, are stripped away as well.
677 /// The accumulated constant offset is added to \p Offset and the base
678 /// pointer is returned.
679 ///
680 /// The APInt \p Offset has to have a bit-width equal to the IntPtr type for
681 /// the address space of 'this' pointer value, e.g., use
682 /// DataLayout::getIndexTypeSizeInBits(Ty).
683 ///
684 /// If \p AllowNonInbounds is true, offsets in GEPs are stripped and
685 /// accumulated even if the GEP is not "inbounds".
686 ///
687 /// If \p AllowInvariantGroup is true then this method also looks through
688 /// strip.invariant.group and launder.invariant.group intrinsics.
689 ///
690 /// If \p ExternalAnalysis is provided it will be used to calculate a offset
691 /// when a operand of GEP is not constant.
692 /// For example, for a value \p ExternalAnalysis might try to calculate a
693 /// lower bound. If \p ExternalAnalysis is successful, it should return true.
694 ///
695 /// If \p LookThroughIntToPtr is true then this method also looks through
696 /// IntToPtr and PtrToInt constant expressions. The returned pointer may not
697 /// have the same provenance as this value.
698 ///
699 /// If this is called on a non-pointer value, it returns 'this' and the
700 /// \p Offset is not modified.
701 ///
702 /// Note that this function will never return a nullptr. It will also never
703 /// manipulate the \p Offset in a way that would not match the difference
704 /// between the underlying value and the returned one. Thus, if a variable
705 /// offset is encountered during traversal, the returned value is the first
706 /// traversed Value that introduces a non-constant offset and \p Offset is the
707 /// accumulated constant offset up to that point.
709 const DataLayout &DL, APInt &Offset, bool AllowNonInbounds,
710 bool AllowInvariantGroup = false,
711 function_ref<bool(Value &Value, APInt &Offset)> ExternalAnalysis =
712 nullptr,
713 bool LookThroughIntToPtr = false) const;
714
716 const DataLayout &DL, APInt &Offset, bool AllowNonInbounds,
717 bool AllowInvariantGroup = false,
718 function_ref<bool(Value &Value, APInt &Offset)> ExternalAnalysis =
719 nullptr,
720 bool LookThroughIntToPtr = false) {
721 return const_cast<Value *>(
722 static_cast<const Value *>(this)->stripAndAccumulateConstantOffsets(
723 DL, Offset, AllowNonInbounds, AllowInvariantGroup, ExternalAnalysis,
724 LookThroughIntToPtr));
725 }
726
727 /// This is a wrapper around stripAndAccumulateConstantOffsets with the
728 /// in-bounds requirement set to false.
730 APInt &Offset) const {
732 /* AllowNonInbounds */ false);
733 }
735 APInt &Offset) {
737 /* AllowNonInbounds */ false);
738 }
739
740 /// Strip off pointer casts and inbounds GEPs.
741 ///
742 /// Returns the original pointer value. If this is called on a non-pointer
743 /// value, it returns 'this'.
745 function_ref<void(const Value *)> Func = [](const Value *) {}) const;
746 inline Value *stripInBoundsOffsets(function_ref<void(const Value *)> Func =
747 [](const Value *) {}) {
748 return const_cast<Value *>(
749 static_cast<const Value *>(this)->stripInBoundsOffsets(Func));
750 }
751
752 /// If this ptr is provably equal to \p Other plus a constant offset, return
753 /// that offset in bytes. Essentially `ptr this` subtract `ptr Other`.
754 LLVM_ABI std::optional<int64_t>
755 getPointerOffsetFrom(const Value *Other, const DataLayout &DL) const;
756
757 /// Return true if the memory object referred to by V can by freed in the
758 /// scope for which the SSA value defining the allocation is statically
759 /// defined. E.g. deallocation after the static scope of a value does not
760 /// count, but a deallocation before that does.
761 LLVM_ABI bool canBeFreed() const;
762
763 /// Returns the number of bytes known to be dereferenceable for the
764 /// pointer value.
765 ///
766 /// If CanBeNull is set by this function the pointer can either be null or be
767 /// dereferenceable up to the returned number of bytes.
768 ///
769 /// If CanBeFreed is non-null, it will be populated with information on
770 /// whether the pointer might be freed, i.e. is only known dereferenceable
771 /// at the point of definition. By passing null the caller indicates that it
772 /// does not care.
774 bool &CanBeNull,
775 bool *CanBeFreed) const;
776
777 /// Returns an alignment of the pointer value.
778 ///
779 /// Returns an alignment which is either specified explicitly, e.g. via
780 /// align attribute of a function argument, or guaranteed by DataLayout.
781 LLVM_ABI Align getPointerAlignment(const DataLayout &DL) const;
782
783 /// Translate PHI node to its predecessor from the given basic block.
784 ///
785 /// If this value is a PHI node with CurBB as its parent, return the value in
786 /// the PHI node corresponding to PredBB. If not, return ourself. This is
787 /// useful if you want to know the value something has in a predecessor
788 /// block.
789 LLVM_ABI const Value *DoPHITranslation(const BasicBlock *CurBB,
790 const BasicBlock *PredBB) const;
791 Value *DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB) {
792 return const_cast<Value *>(
793 static_cast<const Value *>(this)->DoPHITranslation(CurBB, PredBB));
794 }
795
796 /// The maximum alignment for instructions.
797 ///
798 /// This is the greatest alignment value supported by load, store, and alloca
799 /// instructions, and global values.
800 static constexpr unsigned MaxAlignmentExponent = 32;
802
803 /// Mutate the type of this Value to be of the specified type.
804 ///
805 /// Note that this is an extremely dangerous operation which can create
806 /// completely invalid IR very easily. It is strongly recommended that you
807 /// recreate IR objects with the right types instead of mutating them in
808 /// place.
809 void mutateType(Type *Ty) {
810 VTy = Ty;
811 }
812
813 /// Sort the use-list.
814 ///
815 /// Sorts the Value's use-list by Cmp using a stable mergesort. Cmp is
816 /// expected to compare two \a Use references.
817 template <class Compare> void sortUseList(Compare Cmp);
818
819 /// Reverse the use-list.
821
822private:
823 /// Merge two lists together.
824 ///
825 /// Merges \c L and \c R using \c Cmp. To enable stable sorts, always pushes
826 /// "equal" items from L before items from R.
827 ///
828 /// \return the first element in the list.
829 ///
830 /// \note Completely ignores \a Use::Prev (doesn't read, doesn't update).
831 template <class Compare>
832 static Use *mergeUseLists(Use *L, Use *R, Compare Cmp) {
833 Use *Merged;
834 Use **Next = &Merged;
835
836 while (true) {
837 if (!L) {
838 *Next = R;
839 break;
840 }
841 if (!R) {
842 *Next = L;
843 break;
844 }
845 if (Cmp(*R, *L)) {
846 *Next = R;
847 Next = &R->Next;
848 R = R->Next;
849 } else {
850 *Next = L;
851 Next = &L->Next;
852 L = L->Next;
853 }
854 }
855
856 return Merged;
857 }
858
859protected:
860 unsigned short getSubclassDataFromValue() const { return SubclassData; }
861 void setValueSubclassData(unsigned short D) { SubclassData = D; }
862};
863
864struct ValueDeleter { void operator()(Value *V) { V->deleteValue(); } };
865
866/// Use this instead of std::unique_ptr<Value> or std::unique_ptr<Instruction>.
867/// Those don't work because Value and Instruction's destructors are protected,
868/// aren't virtual, and won't destroy the complete object.
869using unique_value = std::unique_ptr<Value, ValueDeleter>;
870
871inline raw_ostream &operator<<(raw_ostream &OS, const Value &V) {
872 V.print(OS);
873 return OS;
874}
875
876void Use::set(Value *V) {
877 removeFromList();
878 Val = V;
879 if (V)
880 V->addUse(*this);
881}
882
884 set(RHS);
885 return RHS;
886}
887
888const Use &Use::operator=(const Use &RHS) {
889 set(RHS.Val);
890 return *this;
891}
892
893template <class Compare> void Value::sortUseList(Compare Cmp) {
894 if (!UseList || !UseList->Next)
895 // No need to sort 0 or 1 uses.
896 return;
897
898 // Note: this function completely ignores Prev pointers until the end when
899 // they're fixed en masse.
900
901 // Create a binomial vector of sorted lists, visiting uses one at a time and
902 // merging lists as necessary.
903 const unsigned MaxSlots = 32;
904 Use *Slots[MaxSlots];
905
906 // Collect the first use, turning it into a single-item list.
907 Use *Next = UseList->Next;
908 UseList->Next = nullptr;
909 unsigned NumSlots = 1;
910 Slots[0] = UseList;
911
912 // Collect all but the last use.
913 while (Next->Next) {
914 Use *Current = Next;
915 Next = Current->Next;
916
917 // Turn Current into a single-item list.
918 Current->Next = nullptr;
919
920 // Save Current in the first available slot, merging on collisions.
921 unsigned I;
922 for (I = 0; I < NumSlots; ++I) {
923 if (!Slots[I])
924 break;
925
926 // Merge two lists, doubling the size of Current and emptying slot I.
927 //
928 // Since the uses in Slots[I] originally preceded those in Current, send
929 // Slots[I] in as the left parameter to maintain a stable sort.
930 Current = mergeUseLists(Slots[I], Current, Cmp);
931 Slots[I] = nullptr;
932 }
933 // Check if this is a new slot.
934 if (I == NumSlots) {
935 ++NumSlots;
936 assert(NumSlots <= MaxSlots && "Use list bigger than 2^32");
937 }
938
939 // Found an open slot.
940 Slots[I] = Current;
941 }
942
943 // Merge all the lists together.
944 assert(Next && "Expected one more Use");
945 assert(!Next->Next && "Expected only one Use");
946 UseList = Next;
947 for (unsigned I = 0; I < NumSlots; ++I)
948 if (Slots[I])
949 // Since the uses in Slots[I] originally preceded those in UseList, send
950 // Slots[I] in as the left parameter to maintain a stable sort.
951 UseList = mergeUseLists(Slots[I], UseList, Cmp);
952
953 // Fix the Prev pointers.
954 for (Use *I = UseList, **Prev = &UseList; I; I = I->Next) {
955 I->Prev = Prev;
956 Prev = &I->Next;
957 }
958}
959
960// isa - Provide some specializations of isa so that we don't have to include
961// the subtype header files to test to see if the value is a subclass...
962//
963template <> struct isa_impl<Constant, Value> {
964 static inline bool doit(const Value &Val) {
965 static_assert(Value::ConstantFirstVal == 0,
966 "Val.getValueID() >= Value::ConstantFirstVal");
967 return Val.getValueID() <= Value::ConstantLastVal;
968 }
969};
970
971template <> struct isa_impl<ConstantData, Value> {
972 static inline bool doit(const Value &Val) {
973 static_assert(Value::ConstantDataFirstVal == 0,
974 "Val.getValueID() >= Value::ConstantDataFirstVal");
975 return Val.getValueID() <= Value::ConstantDataLastVal;
976 }
977};
978
979template <> struct isa_impl<ConstantAggregate, Value> {
980 static inline bool doit(const Value &Val) {
981 return Val.getValueID() >= Value::ConstantAggregateFirstVal &&
982 Val.getValueID() <= Value::ConstantAggregateLastVal;
983 }
984};
985
986template <> struct isa_impl<Argument, Value> {
987 static inline bool doit (const Value &Val) {
988 return Val.getValueID() == Value::ArgumentVal;
989 }
990};
991
992template <> struct isa_impl<InlineAsm, Value> {
993 static inline bool doit(const Value &Val) {
994 return Val.getValueID() == Value::InlineAsmVal;
995 }
996};
997
998template <> struct isa_impl<Instruction, Value> {
999 static inline bool doit(const Value &Val) {
1000 return Val.getValueID() >= Value::InstructionVal;
1001 }
1002};
1003
1004template <> struct isa_impl<BasicBlock, Value> {
1005 static inline bool doit(const Value &Val) {
1006 return Val.getValueID() == Value::BasicBlockVal;
1007 }
1008};
1009
1010template <> struct isa_impl<Function, Value> {
1011 static inline bool doit(const Value &Val) {
1012 return Val.getValueID() == Value::FunctionVal;
1013 }
1014};
1015
1016template <> struct isa_impl<GlobalVariable, Value> {
1017 static inline bool doit(const Value &Val) {
1018 return Val.getValueID() == Value::GlobalVariableVal;
1019 }
1020};
1021
1022template <> struct isa_impl<GlobalAlias, Value> {
1023 static inline bool doit(const Value &Val) {
1024 return Val.getValueID() == Value::GlobalAliasVal;
1025 }
1026};
1027
1028template <> struct isa_impl<GlobalIFunc, Value> {
1029 static inline bool doit(const Value &Val) {
1030 return Val.getValueID() == Value::GlobalIFuncVal;
1031 }
1032};
1033
1034template <> struct isa_impl<GlobalValue, Value> {
1035 static inline bool doit(const Value &Val) {
1036 return isa<GlobalObject>(Val) || isa<GlobalAlias>(Val);
1037 }
1038};
1039
1040template <> struct isa_impl<GlobalObject, Value> {
1041 static inline bool doit(const Value &Val) {
1042 return isa<GlobalVariable>(Val) || isa<Function>(Val) ||
1043 isa<GlobalIFunc>(Val);
1044 }
1045};
1046
1047// Create wrappers for C Binding types (see CBindingWrapping.h).
1049
1050// Specialized opaque value conversions.
1052 return reinterpret_cast<Value**>(Vals);
1053}
1054
1055template<typename T>
1056inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
1057#ifndef NDEBUG
1058 for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I)
1059 unwrap<T>(*I); // For side effect of calling assert on invalid usage.
1060#endif
1061 (void)Length;
1062 return reinterpret_cast<T**>(Vals);
1063}
1064
1065inline LLVMValueRef *wrap(const Value **Vals) {
1066 return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
1067}
1068
1069} // end namespace llvm
1070
1071#endif // LLVM_IR_VALUE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
always inline
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref)
#define LLVM_ABI
Definition Compiler.h:215
#define LLVM_READONLY
Definition Compiler.h:330
This defines the Use class.
#define I(x, y, z)
Definition MD5.cpp:57
bool operator==(const MergedFunctionsInfo &LHS, const MergedFunctionsInfo &RHS)
#define T
This file contains some templates that are useful if you are working with the STL at all.
Value * RHS
Class for arbitrary precision integers.
Definition APInt.h:78
This class represents an incoming formal argument to a Function.
Definition Argument.h:32
LLVM Basic Block Representation.
Definition BasicBlock.h:62
Base class for aggregate constants (with operands).
Definition Constants.h:565
Base class for constants with no operands.
Definition Constants.h:56
This is an important base class in LLVM.
Definition Constant.h:43
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Metadata node.
Definition Metadata.h:1079
Manage lifetime of a slot tracker for printing IR.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
LLVM_ABI void set(Value *Val)
Definition Value.h:876
Use(const Use &U)=delete
LLVM_ABI Value * operator=(Value *RHS)
Definition Value.h:883
friend class Value
Definition Use.h:51
std::ptrdiff_t difference_type
Definition Value.h:182
bool operator==(const user_iterator_impl &x) const
Definition Value.h:188
bool atEnd() const
Returns true if this iterator is equal to user_end() on the value.
Definition Value.h:192
UserTy * operator->() const
Definition Value.h:208
std::forward_iterator_tag iterator_category
Definition Value.h:180
UserTy * operator*() const
Definition Value.h:206
user_iterator_impl & operator++()
Definition Value.h:194
user_iterator_impl operator++(int)
Definition Value.h:199
bool operator!=(const user_iterator_impl &x) const
Definition Value.h:189
LLVM Value Representation.
Definition Value.h:75
iterator_range< user_iterator > materialized_users()
Definition Value.h:422
Type * getType() const
All values are typed, get the type of this value.
Definition Value.h:257
Value * stripInBoundsOffsets(function_ref< void(const Value *)> Func=[](const Value *) {})
Definition Value.h:746
unsigned short getSubclassDataFromValue() const
Definition Value.h:860
const_use_iterator materialized_use_begin() const
Definition Value.h:362
static constexpr uint64_t MaximumAlignment
Definition Value.h:801
Value * stripPointerCasts()
Definition Value.h:626
unsigned IsUsedByMD
Definition Value.h:112
user_iterator_impl< const User > const_user_iterator
Definition Value.h:394
const Value * stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL, APInt &Offset) const
This is a wrapper around stripAndAccumulateConstantOffsets with the in-bounds requirement set to fals...
Definition Value.h:729
user_iterator user_begin()
Definition Value.h:404
LLVM_ABI const Value * DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB) const
Translate PHI node to its predecessor from the given basic block.
Definition Value.cpp:1137
unsigned HasName
Definition Value.h:113
LLVM_ABI Value(Type *Ty, unsigned scid)
Definition Value.cpp:54
@ NumUserOperandsBits
Definition Value.h:108
iterator_range< use_iterator > materialized_uses()
Definition Value.h:376
LLVM_ABI void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
use_iterator_impl< const Use > const_use_iterator
Definition Value.h:356
unsigned char SubclassOptionalData
Hold arbitary subclass data.
Definition Value.h:85
iterator_range< const_use_iterator > uses() const
Definition Value.h:386
const_use_iterator use_begin() const
Definition Value.h:370
iterator_range< const_user_iterator > materialized_users() const
Definition Value.h:425
LLVM_ABI void reverseUseList()
Reverse the use-list.
Definition Value.cpp:1145
const User * getUniqueUndroppableUser() const
Definition Value.h:471
LLVM_ABI void assertModuleIsMaterializedImpl() const
Definition Value.cpp:471
LLVM_ABI bool hasNUndroppableUsesOrMore(unsigned N) const
Return true if this value has N uses or more.
Definition Value.cpp:201
LLVM_ABI bool hasOneUser() const
Return true if there is exactly one user of this value.
Definition Value.cpp:163
LLVM_ABI const Value * stripPointerCastsAndAliases() const
Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
Definition Value.cpp:717
Use * UseList
Definition Value.h:121
void assertModuleIsMaterialized() const
Definition Value.h:339
friend class ValueHandleBase
Definition Value.h:125
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
unsigned getRawSubclassOptionalData() const
Return the raw optional flags value contained in this value.
Definition Value.h:552
LLVM_ABI void setName(const Twine &Name)
Change the name of the value.
Definition Value.cpp:394
LLVM_ABI const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
Definition Value.cpp:725
LLVM_ABI std::string getNameOrAsOperand() const
Definition Value.cpp:461
bool hasOneUse() const
Return true if there is exactly one use of this value.
Definition Value.h:441
LLVM_ABI ~Value()
Value's destructor should be virtual by design, but that would require that Value and all of its subc...
Definition Value.cpp:77
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition Value.cpp:553
LLVMContext & getContext() const
All values hold a context through their type.
Definition Value.h:260
friend class ValueAsMetadata
Definition Value.h:124
LLVM_ABI void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
Appends all metadata attached to this value to MDs, sorting by KindID.
LLVM_ABI const Value * stripInBoundsOffsets(function_ref< void(const Value *)> Func=[](const Value *) {}) const
Strip off pointer casts and inbounds GEPs.
Definition Value.cpp:828
iterator_range< user_iterator > users()
Definition Value.h:428
use_iterator use_begin()
Definition Value.h:366
static LLVM_ABI void dropDroppableUse(Use &U)
Remove the droppable use U.
Definition Value.cpp:223
void sortUseList(Compare Cmp)
Sort the use-list.
Definition Value.h:893
User * user_back()
Definition Value.h:414
iterator_range< const_user_iterator > users() const
Definition Value.h:432
LLVM_ABI Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
Definition Value.cpp:1002
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition Value.h:545
Value * stripPointerCastsAndAliases()
Definition Value.h:636
LLVM_ABI bool isUsedInBasicBlock(const BasicBlock *BB) const
Check if this value is used in the specified basic block.
Definition Value.cpp:239
Value * stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL, APInt &Offset)
Definition Value.h:734
const User * user_back() const
Definition Value.h:418
bool materialized_use_empty() const
Definition Value.h:353
LLVM_ABI void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
bool hasUseList() const
Check if this Value has a use-list.
Definition Value.h:346
Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr, bool LookThroughIntToPtr=false)
Definition Value.h:715
bool isUsedByMetadata() const
Return true if there is metadata referencing this value.
Definition Value.h:560
LLVM_ABI bool hasNUsesOrMore(unsigned N) const
Return true if this value has N uses or more.
Definition Value.cpp:155
LLVM_ABI void dropDroppableUsesIn(User &Usr)
Remove every use of this value in User that can safely be removed.
Definition Value.cpp:215
use_iterator materialized_use_begin()
Definition Value.h:358
LLVM_ABI Use * getSingleUndroppableUse()
Return true if there is exactly one use of this value that cannot be dropped.
Definition Value.cpp:173
LLVM_ABI bool canBeFreed() const
Return true if the memory object referred to by V can by freed in the scope for which the SSA value d...
Definition Value.cpp:832
LLVM_ABI bool hasNUses(unsigned N) const
Return true if this Value has exactly N uses.
Definition Value.cpp:147
LLVM_ABI MDNode * getMetadataImpl(unsigned KindID) const LLVM_READONLY
Get metadata for the given kind, if any.
Value(const Value &)=delete
iterator_range< const_use_iterator > materialized_uses() const
Definition Value.h:379
use_iterator_impl< Use > use_iterator
Definition Value.h:355
LLVM_ABI void setValueName(ValueName *VN)
Definition Value.cpp:302
LLVM_ABI User * getUniqueUndroppableUser()
Return true if there is exactly one unique user of this value that cannot be dropped (that user can h...
Definition Value.cpp:185
LLVM_ABI const Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr, bool LookThroughIntToPtr=false) const
Accumulate the constant offset this value has compared to a base pointer.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition Value.cpp:713
LLVM_ABI bool isSwiftError() const
Return true if this value is a swifterror value.
Definition Value.cpp:1164
LLVM_ABI void deleteValue()
Delete a pointer to a generic Value.
Definition Value.cpp:108
LLVM_ABI ValueName * getValueName() const
Definition Value.cpp:291
LLVM_ABI const Value * stripPointerCastsSameRepresentation() const
Strip off pointer casts, all-zero GEPs and address space casts but ensures the representation of the ...
Definition Value.cpp:721
bool use_empty() const
Definition Value.h:348
LLVM_ABI bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
LLVM_ABI void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
LLVM_ABI void dropDroppableUses(llvm::function_ref< bool(const Use *)> ShouldDrop=[](const Use *) { return true;})
Remove every uses that can safely be removed.
Definition Value.cpp:205
user_iterator user_end()
Definition Value.h:412
LLVM_ABI void replaceUsesOutsideBlock(Value *V, BasicBlock *BB)
replaceUsesOutsideBlock - Go through the uses list for this definition and make each use point to "V"...
Definition Value.cpp:611
void addUse(Use &U)
This method should only be used by the Use class.
Definition Value.h:515
void setValueSubclassData(unsigned short D)
Definition Value.h:861
LLVM_ABI MDNode * getMetadata(StringRef Kind) const LLVM_READONLY
Get the current metadata attachments for the given kind, if any.
LLVM_ABI void eraseMetadataIf(function_ref< bool(unsigned, MDNode *)> Pred)
Erase all metadata attachments matching the given predicate.
Value * DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB)
Definition Value.h:791
static constexpr unsigned MaxAlignmentExponent
The maximum alignment for instructions.
Definition Value.h:800
bool hasValueHandle() const
Return true if there is a value handle associated with this value.
Definition Value.h:557
unsigned NumUserOperands
Definition Value.h:109
LLVM_ABI unsigned getNumUses() const
This method computes the number of uses of this Value.
Definition Value.cpp:262
LLVM_ABI bool replaceUsesWithIf(Value *New, llvm::function_ref< bool(Use &U)> ShouldReplace)
Go through the uses list for this definition and make each use point to "V" if the callback ShouldRep...
Definition Value.cpp:561
Value & operator=(const Value &)=delete
unsigned HasHungOffUses
Definition Value.h:114
iterator_range< use_iterator > uses()
Definition Value.h:382
void mutateType(Type *Ty)
Mutate the type of this Value to be of the specified type.
Definition Value.h:809
const_use_iterator use_end() const
Definition Value.h:375
Value * stripPointerCastsForAliasAnalysis()
Definition Value.h:659
LLVM_ABI std::optional< int64_t > getPointerOffsetFrom(const Value *Other, const DataLayout &DL) const
If this ptr is provably equal to Other plus a constant offset, return that offset in bytes.
Definition Value.cpp:1098
Value * stripInBoundsConstantOffsets()
Definition Value.h:669
const Use * getSingleUndroppableUse() const
Definition Value.h:464
user_iterator_impl< User > user_iterator
Definition Value.h:393
user_iterator materialized_user_begin()
Definition Value.h:396
LLVM_ABI void clearMetadata()
Erase all metadata attached to this Value.
use_iterator use_end()
Definition Value.h:374
bool hasName() const
Definition Value.h:263
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
Definition Value.cpp:319
LLVM_ABI void replaceNonMetadataUsesWith(Value *V)
Change non-metadata uses of this to point to a new Value.
Definition Value.cpp:557
Value * stripPointerCastsSameRepresentation()
Definition Value.h:647
unsigned HasDescriptor
Definition Value.h:115
const_user_iterator materialized_user_begin() const
Definition Value.h:400
LLVM_ABI void takeName(Value *V)
Transfer the name from V to this value.
Definition Value.cpp:400
LLVM_ABI uint64_t getPointerDereferenceableBytes(const DataLayout &DL, bool &CanBeNull, bool *CanBeFreed) const
Returns the number of bytes known to be dereferenceable for the pointer value.
Definition Value.cpp:918
const_user_iterator user_end() const
Definition Value.h:413
bool user_empty() const
Definition Value.h:391
LLVM_ABI bool hasNUndroppableUses(unsigned N) const
Return true if there this value.
Definition Value.cpp:197
ValueTy
Concrete subclass of this.
Definition Value.h:526
LLVM_ABI const Value * stripPointerCastsForAliasAnalysis() const
Strip off pointer casts, all-zero GEPs, single-argument phi nodes and invariant group info.
Definition Value.cpp:729
LLVM_ABI void dump() const
Support for debugging, callable in GDB: V->dump()
const_user_iterator user_begin() const
Definition Value.h:408
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition Types.h:75
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
@ Length
Definition DWP.cpp:577
StringMapEntry< Value * > ValueName
Definition Value.h:56
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
Definition InstrProf.h:143
bool hasSingleElement(ContainerTy &&C)
Returns true if the given container only contains a single element.
Definition STLExtras.h:299
std::unique_ptr< Value, ValueDeleter > unique_value
Use this instead of std::unique_ptr<Value> or std::unique_ptr<Instruction>.
Definition Value.h:869
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
Definition Casting.h:547
@ Other
Any other memory.
Definition ModRef.h:68
Attribute unwrap(LLVMAttributeRef Attr)
Definition Attributes.h:400
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:559
LLVMAttributeRef wrap(Attribute Attr)
Definition Attributes.h:395
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
Definition InstrProf.h:147
#define N
void operator()(Value *V)
Definition Value.h:864
static bool doit(const Value &Val)
Definition Value.h:987
static bool doit(const Value &Val)
Definition Value.h:1005
static bool doit(const Value &Val)
Definition Value.h:980
static bool doit(const Value &Val)
Definition Value.h:972
static bool doit(const Value &Val)
Definition Value.h:964
static bool doit(const Value &Val)
Definition Value.h:1011
static bool doit(const Value &Val)
Definition Value.h:1023
static bool doit(const Value &Val)
Definition Value.h:1029
static bool doit(const Value &Val)
Definition Value.h:1041
static bool doit(const Value &Val)
Definition Value.h:1035
static bool doit(const Value &Val)
Definition Value.h:1017
static bool doit(const Value &Val)
Definition Value.h:993
static bool doit(const Value &Val)
Definition Value.h:999