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