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