LLVM  14.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 GlobalObject;
41 class GlobalValue;
42 class GlobalVariable;
43 class InlineAsm;
44 class Instruction;
45 class LLVMContext;
46 class MDNode;
47 class Module;
48 class ModuleSlotTracker;
49 class raw_ostream;
50 template<typename ValueTy> class StringMapEntry;
51 class Twine;
52 class Type;
53 class User;
54 
56 
57 //===----------------------------------------------------------------------===//
58 // Value Class
59 //===----------------------------------------------------------------------===//
60 
61 /// LLVM Value Representation
62 ///
63 /// This is a very important LLVM class. It is the base class of all values
64 /// computed by a program that may be used as operands to other values. Value is
65 /// the super class of other important classes such as Instruction and Function.
66 /// All Values have a Type. Type is not a subclass of Value. Some values can
67 /// have a name and they belong to some Module. Setting the name on the Value
68 /// automatically updates the module's symbol table.
69 ///
70 /// Every value has a "use list" that keeps track of which other Values are
71 /// using this Value. A Value can also have an arbitrary number of ValueHandle
72 /// objects that watch it and listen to RAUW and Destroy events. See
73 /// llvm/IR/ValueHandle.h for details.
74 class Value {
75  Type *VTy;
76  Use *UseList;
77 
78  friend class ValueAsMetadata; // Allow access to IsUsedByMD.
79  friend class ValueHandleBase;
80 
81  const unsigned char SubclassID; // Subclass identifier (for isa/dyn_cast)
82  unsigned char HasValueHandle : 1; // Has a ValueHandle pointing to this?
83 
84 protected:
85  /// Hold subclass data that can be dropped.
86  ///
87  /// This member is similar to SubclassData, however it is for holding
88  /// information which may be used to aid optimization, but which may be
89  /// cleared to zero without affecting conservative interpretation.
90  unsigned char SubclassOptionalData : 7;
91 
92 private:
93  /// Hold arbitrary subclass data.
94  ///
95  /// This member is defined by this class, but is not used for anything.
96  /// Subclasses can use it to hold whatever state they find useful. This
97  /// field is initialized to zero by the ctor.
98  unsigned short SubclassData;
99 
100 protected:
101  /// The number of operands in the subclass.
102  ///
103  /// This member is defined by this class, but not used for anything.
104  /// Subclasses can use it to store their number of operands, if they have
105  /// any.
106  ///
107  /// This is stored here to save space in User on 64-bit hosts. Since most
108  /// instances of Value have operands, 32-bit hosts aren't significantly
109  /// affected.
110  ///
111  /// Note, this should *NOT* be used directly by any class other than User.
112  /// User uses this value to find the Use list.
113  enum : unsigned { NumUserOperandsBits = 27 };
115 
116  // Use the same type as the bitfield above so that MSVC will pack them.
117  unsigned IsUsedByMD : 1;
118  unsigned HasName : 1;
119  unsigned HasMetadata : 1; // Has metadata attached to this?
120  unsigned HasHungOffUses : 1;
121  unsigned HasDescriptor : 1;
122 
123 private:
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 
214 protected:
215  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  ~Value(); // Use deleteValue() to delete a generic Value.
223 
224 public:
225  Value(const Value &) = delete;
226  Value &operator=(const Value &) = delete;
227 
228  /// Delete a pointer to a generic Value.
229  void deleteValue();
230 
231  /// Support for debugging, callable in GDB: V->dump()
232  void dump() const;
233 
234  /// Implement operator<< on Value.
235  /// @{
236  void print(raw_ostream &O, bool IsForDebug = false) const;
237  void print(raw_ostream &O, ModuleSlotTracker &MST,
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 constanst get pretty-printed; for example, the type of a null
246  /// pointer is printed symbolically.
247  /// @{
248  void printAsOperand(raw_ostream &O, bool PrintType = true,
249  const Module *M = nullptr) const;
250  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;
259 
260  // All values can potentially be named.
261  bool hasName() const { return HasName; }
262  ValueName *getValueName() const;
263  void setValueName(ValueName *VN);
264 
265 private:
266  void destroyValueName();
267  enum class ReplaceMetadataUses { No, Yes };
268  void doRAUW(Value *New, ReplaceMetadataUses);
269  void setNameImpl(const Twine &Name);
270 
271 public:
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  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  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  void takeName(Value *V);
292 
293 #ifndef NDEBUG
294  std::string getNameOrAsOperand() const;
295 #endif
296 
297  /// Change all uses of this to point to a new Value.
298  ///
299  /// Go through the uses list for this definition and make each use point to
300  /// "V" instead of "this". After this completes, 'this's use list is
301  /// guaranteed to be empty.
302  void replaceAllUsesWith(Value *V);
303 
304  /// Change non-metadata uses of this to point to a new Value.
305  ///
306  /// Go through the uses list for this definition and make each use point to
307  /// "V" instead of "this". This function skips metadata entries in the list.
309 
310  /// Go through the uses list for this definition and make each use point
311  /// to "V" if the callback ShouldReplace returns true for the given Use.
312  /// Unlike replaceAllUsesWith() this function does not support basic block
313  /// values.
314  void replaceUsesWithIf(Value *New,
315  llvm::function_ref<bool(Use &U)> ShouldReplace);
316 
317  /// replaceUsesOutsideBlock - Go through the uses list for this definition and
318  /// make each use point to "V" instead of "this" when the use is outside the
319  /// block. 'This's use list is expected to have at least one element.
320  /// Unlike replaceAllUsesWith() this function does not support basic block
321  /// values.
323 
324  //----------------------------------------------------------------------
325  // Methods for handling the chain of uses of this Value.
326  //
327  // Materializing a function can introduce new uses, so these methods come in
328  // two variants:
329  // The methods that start with materialized_ check the uses that are
330  // currently known given which functions are materialized. Be very careful
331  // when using them since you might not get all uses.
332  // The methods that don't start with materialized_ assert that modules is
333  // fully materialized.
334  void assertModuleIsMaterializedImpl() const;
335  // This indirection exists so we can keep assertModuleIsMaterializedImpl()
336  // around in release builds of Value.cpp to be linked with other code built
337  // in debug mode. But this avoids calling it in any of the release built code.
339 #ifndef NDEBUG
341 #endif
342  }
343 
344  bool use_empty() const {
346  return UseList == nullptr;
347  }
348 
349  bool materialized_use_empty() const {
350  return UseList == nullptr;
351  }
352 
353  using use_iterator = use_iterator_impl<Use>;
354  using const_use_iterator = use_iterator_impl<const Use>;
355 
358  return const_use_iterator(UseList);
359  }
362  return materialized_use_begin();
363  }
366  return materialized_use_begin();
367  }
372  }
375  }
378  return materialized_uses();
379  }
382  return materialized_uses();
383  }
384 
385  bool user_empty() const {
387  return UseList == nullptr;
388  }
389 
390  using user_iterator = user_iterator_impl<User>;
391  using const_user_iterator = user_iterator_impl<const User>;
392 
395  return const_user_iterator(UseList);
396  }
399  return materialized_user_begin();
400  }
403  return materialized_user_begin();
404  }
409  return *materialized_user_begin();
410  }
411  const User *user_back() const {
413  return *materialized_user_begin();
414  }
417  }
420  }
423  return materialized_users();
424  }
427  return materialized_users();
428  }
429 
430  /// Return true if there is exactly one use of this value.
431  ///
432  /// This is specialized because it is a common request and does not require
433  /// traversing the whole use list.
434  bool hasOneUse() const { return hasSingleElement(uses()); }
435 
436  /// Return true if this Value has exactly N uses.
437  bool hasNUses(unsigned N) const;
438 
439  /// Return true if this value has N uses or more.
440  ///
441  /// This is logically equivalent to getNumUses() >= N.
442  bool hasNUsesOrMore(unsigned N) const;
443 
444  /// Return true if there is exactly one user of this value.
445  ///
446  /// Note that this is not the same as "has one use". If a value has one use,
447  /// then there certainly is a single user. But if value has several uses,
448  /// it is possible that all uses are in a single user, or not.
449  ///
450  /// This check is potentially costly, since it requires traversing,
451  /// in the worst case, the whole use list of a value.
452  bool hasOneUser() const;
453 
454  /// Return true if there is exactly one use of this value that cannot be
455  /// dropped.
457  const Use *getSingleUndroppableUse() const {
458  return const_cast<Value *>(this)->getSingleUndroppableUse();
459  }
460 
461  /// Return true if there is exactly one unique user of this value that cannot be
462  /// dropped (that user can have multiple uses of this value).
465  return const_cast<Value *>(this)->getUniqueUndroppableUser();
466  }
467 
468  /// Return true if there this value.
469  ///
470  /// This is specialized because it is a common request and does not require
471  /// traversing the whole use list.
472  bool hasNUndroppableUses(unsigned N) const;
473 
474  /// Return true if this value has N uses or more.
475  ///
476  /// This is logically equivalent to getNumUses() >= N.
477  bool hasNUndroppableUsesOrMore(unsigned N) const;
478 
479  /// Remove every uses that can safely be removed.
480  ///
481  /// This will remove for example uses in llvm.assume.
482  /// This should be used when performing want to perform a tranformation but
483  /// some Droppable uses pervent it.
484  /// This function optionally takes a filter to only remove some droppable
485  /// uses.
486  void dropDroppableUses(llvm::function_ref<bool(const Use *)> ShouldDrop =
487  [](const Use *) { return true; });
488 
489  /// Remove every use of this value in \p User that can safely be removed.
490  void dropDroppableUsesIn(User &Usr);
491 
492  /// Remove the droppable use \p U.
493  static void dropDroppableUse(Use &U);
494 
495  /// Check if this value is used in the specified basic block.
496  bool isUsedInBasicBlock(const BasicBlock *BB) const;
497 
498  /// This method computes the number of uses of this Value.
499  ///
500  /// This is a linear time operation. Use hasOneUse, hasNUses, or
501  /// hasNUsesOrMore to check for specific values.
502  unsigned getNumUses() const;
503 
504  /// This method should only be used by the Use class.
505  void addUse(Use &U) { U.addToList(&UseList); }
506 
507  /// Concrete subclass of this.
508  ///
509  /// An enumeration for keeping track of the concrete subclass of Value that
510  /// is actually instantiated. Values of this enumeration are kept in the
511  /// Value classes SubclassID field. They are used for concrete type
512  /// identification.
513  enum ValueTy {
514 #define HANDLE_VALUE(Name) Name##Val,
515 #include "llvm/IR/Value.def"
516 
517  // Markers:
518 #define HANDLE_CONSTANT_MARKER(Marker, Constant) Marker = Constant##Val,
519 #include "llvm/IR/Value.def"
520  };
521 
522  /// Return an ID for the concrete type of this object.
523  ///
524  /// This is used to implement the classof checks. This should not be used
525  /// for any other purpose, as the values may change as LLVM evolves. Also,
526  /// note that for instructions, the Instruction's opcode is added to
527  /// InstructionVal. So this means three things:
528  /// # there is no value with code InstructionVal (no opcode==0).
529  /// # there are more possible values for the value type than in ValueTy enum.
530  /// # the InstructionVal enumerator must be the highest valued enumerator in
531  /// the ValueTy enum.
532  unsigned getValueID() const {
533  return SubclassID;
534  }
535 
536  /// Return the raw optional flags value contained in this value.
537  ///
538  /// This should only be used when testing two Values for equivalence.
539  unsigned getRawSubclassOptionalData() const {
540  return SubclassOptionalData;
541  }
542 
543  /// Clear the optional flags contained in this value.
546  }
547 
548  /// Check the optional flags for equality.
549  bool hasSameSubclassOptionalData(const Value *V) const {
551  }
552 
553  /// Return true if there is a value handle associated with this value.
554  bool hasValueHandle() const { return HasValueHandle; }
555 
556  /// Return true if there is metadata referencing this value.
557  bool isUsedByMetadata() const { return IsUsedByMD; }
558 
559  // Return true if this value is only transitively referenced by metadata.
560  bool isTransitiveUsedByMetadataOnly() const;
561 
562 protected:
563  /// Get the current metadata attachments for the given kind, if any.
564  ///
565  /// These functions require that the value have at most a single attachment
566  /// of the given kind, and return \c nullptr if such an attachment is missing.
567  /// @{
568  MDNode *getMetadata(unsigned KindID) const;
570  /// @}
571 
572  /// Appends all attachments with the given ID to \c MDs in insertion order.
573  /// If the Value has no attachments with the given ID, or if ID is invalid,
574  /// leaves MDs unchanged.
575  /// @{
576  void getMetadata(unsigned KindID, SmallVectorImpl<MDNode *> &MDs) const;
578  /// @}
579 
580  /// Appends all metadata attached to this value to \c MDs, sorting by
581  /// KindID. The first element of each pair returned is the KindID, the second
582  /// element is the metadata value. Attachments with the same ID appear in
583  /// insertion order.
584  void
585  getAllMetadata(SmallVectorImpl<std::pair<unsigned, MDNode *>> &MDs) const;
586 
587  /// Return true if this value has any metadata attached to it.
588  bool hasMetadata() const { return (bool)HasMetadata; }
589 
590  /// Return true if this value has the given type of metadata attached.
591  /// @{
592  bool hasMetadata(unsigned KindID) const {
593  return getMetadata(KindID) != nullptr;
594  }
595  bool hasMetadata(StringRef Kind) const {
596  return getMetadata(Kind) != nullptr;
597  }
598  /// @}
599 
600  /// Set a particular kind of metadata attachment.
601  ///
602  /// Sets the given attachment to \c MD, erasing it if \c MD is \c nullptr or
603  /// replacing it if it already exists.
604  /// @{
605  void setMetadata(unsigned KindID, MDNode *Node);
607  /// @}
608 
609  /// Add a metadata attachment.
610  /// @{
611  void addMetadata(unsigned KindID, MDNode &MD);
612  void addMetadata(StringRef Kind, MDNode &MD);
613  /// @}
614 
615  /// Erase all metadata attachments with the given kind.
616  ///
617  /// \returns true if any metadata was removed.
618  bool eraseMetadata(unsigned KindID);
619 
620  /// Erase all metadata attached to this Value.
621  void clearMetadata();
622 
623 public:
624  /// Return true if this value is a swifterror value.
625  ///
626  /// swifterror values can be either a function argument or an alloca with a
627  /// swifterror attribute.
628  bool isSwiftError() const;
629 
630  /// Strip off pointer casts, all-zero GEPs and address space casts.
631  ///
632  /// Returns the original uncasted value. If this is called on a non-pointer
633  /// value, it returns 'this'.
634  const Value *stripPointerCasts() const;
636  return const_cast<Value *>(
637  static_cast<const Value *>(this)->stripPointerCasts());
638  }
639 
640  /// Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
641  ///
642  /// Returns the original uncasted value. If this is called on a non-pointer
643  /// value, it returns 'this'.
644  const Value *stripPointerCastsAndAliases() const;
646  return const_cast<Value *>(
647  static_cast<const Value *>(this)->stripPointerCastsAndAliases());
648  }
649 
650  /// Strip off pointer casts, all-zero GEPs and address space casts
651  /// but ensures the representation of the result stays the same.
652  ///
653  /// Returns the original uncasted value with the same representation. If this
654  /// is called on a non-pointer value, it returns 'this'.
657  return const_cast<Value *>(static_cast<const Value *>(this)
659  }
660 
661  /// Strip off pointer casts, all-zero GEPs, single-argument phi nodes and
662  /// invariant group info.
663  ///
664  /// Returns the original uncasted value. If this is called on a non-pointer
665  /// value, it returns 'this'. This function should be used only in
666  /// Alias analysis.
669  return const_cast<Value *>(static_cast<const Value *>(this)
671  }
672 
673  /// Strip off pointer casts and all-constant inbounds GEPs.
674  ///
675  /// Returns the original pointer value. If this is called on a non-pointer
676  /// value, it returns 'this'.
677  const Value *stripInBoundsConstantOffsets() const;
679  return const_cast<Value *>(
680  static_cast<const Value *>(this)->stripInBoundsConstantOffsets());
681  }
682 
683  /// Accumulate the constant offset this value has compared to a base pointer.
684  /// Only 'getelementptr' instructions (GEPs) are accumulated but other
685  /// instructions, e.g., casts, are stripped away as well.
686  /// The accumulated constant offset is added to \p Offset and the base
687  /// pointer is returned.
688  ///
689  /// The APInt \p Offset has to have a bit-width equal to the IntPtr type for
690  /// the address space of 'this' pointer value, e.g., use
691  /// DataLayout::getIndexTypeSizeInBits(Ty).
692  ///
693  /// If \p AllowNonInbounds is true, offsets in GEPs are stripped and
694  /// accumulated even if the GEP is not "inbounds".
695  ///
696  /// If \p AllowInvariantGroup is true then this method also looks through
697  /// strip.invariant.group and launder.invariant.group intrinsics.
698  ///
699  /// If \p ExternalAnalysis is provided it will be used to calculate a offset
700  /// when a operand of GEP is not constant.
701  /// For example, for a value \p ExternalAnalysis might try to calculate a
702  /// lower bound. If \p ExternalAnalysis is successful, it should return true.
703  ///
704  /// If this is called on a non-pointer value, it returns 'this' and the
705  /// \p Offset is not modified.
706  ///
707  /// Note that this function will never return a nullptr. It will also never
708  /// manipulate the \p Offset in a way that would not match the difference
709  /// between the underlying value and the returned one. Thus, if no constant
710  /// offset was found, the returned value is the underlying one and \p Offset
711  /// is unchanged.
713  const DataLayout &DL, APInt &Offset, bool AllowNonInbounds,
714  bool AllowInvariantGroup = false,
715  function_ref<bool(Value &Value, APInt &Offset)> ExternalAnalysis =
716  nullptr) const;
718  bool AllowNonInbounds,
719  bool AllowInvariantGroup = false) {
720  return const_cast<Value *>(
721  static_cast<const Value *>(this)->stripAndAccumulateConstantOffsets(
722  DL, Offset, AllowNonInbounds, AllowInvariantGroup));
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'.
742  const Value *stripInBoundsOffsets(function_ref<void(const Value *)> Func =
743  [](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  /// Return true if the memory object referred to by V can by freed in the
751  /// scope for which the SSA value defining the allocation is statically
752  /// defined. E.g. deallocation after the static scope of a value does not
753  /// count, but a deallocation before that does.
754  bool canBeFreed() const;
755 
756  /// Returns the number of bytes known to be dereferenceable for the
757  /// pointer value.
758  ///
759  /// If CanBeNull is set by this function the pointer can either be null or be
760  /// dereferenceable up to the returned number of bytes.
761  ///
762  /// IF CanBeFreed is true, the pointer is known to be dereferenceable at
763  /// point of definition only. Caller must prove that allocation is not
764  /// deallocated between point of definition and use.
765  uint64_t getPointerDereferenceableBytes(const DataLayout &DL,
766  bool &CanBeNull,
767  bool &CanBeFreed) const;
768 
769  /// Returns an alignment of the pointer value.
770  ///
771  /// Returns an alignment which is either specified explicitly, e.g. via
772  /// align attribute of a function argument, or guaranteed by DataLayout.
773  Align getPointerAlignment(const DataLayout &DL) const;
774 
775  /// Translate PHI node to its predecessor from the given basic block.
776  ///
777  /// If this value is a PHI node with CurBB as its parent, return the value in
778  /// the PHI node corresponding to PredBB. If not, return ourself. This is
779  /// useful if you want to know the value something has in a predecessor
780  /// block.
781  const Value *DoPHITranslation(const BasicBlock *CurBB,
782  const BasicBlock *PredBB) const;
783  Value *DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB) {
784  return const_cast<Value *>(
785  static_cast<const Value *>(this)->DoPHITranslation(CurBB, PredBB));
786  }
787 
788  /// The maximum alignment for instructions.
789  ///
790  /// This is the greatest alignment value supported by load, store, and alloca
791  /// instructions, and global values.
792  static constexpr unsigned MaxAlignmentExponent = 32;
793  static constexpr uint64_t MaximumAlignment = 1ULL << MaxAlignmentExponent;
794 
795  /// Mutate the type of this Value to be of the specified type.
796  ///
797  /// Note that this is an extremely dangerous operation which can create
798  /// completely invalid IR very easily. It is strongly recommended that you
799  /// recreate IR objects with the right types instead of mutating them in
800  /// place.
801  void mutateType(Type *Ty) {
802  VTy = Ty;
803  }
804 
805  /// Sort the use-list.
806  ///
807  /// Sorts the Value's use-list by Cmp using a stable mergesort. Cmp is
808  /// expected to compare two \a Use references.
809  template <class Compare> void sortUseList(Compare Cmp);
810 
811  /// Reverse the use-list.
812  void reverseUseList();
813 
814 private:
815  /// Merge two lists together.
816  ///
817  /// Merges \c L and \c R using \c Cmp. To enable stable sorts, always pushes
818  /// "equal" items from L before items from R.
819  ///
820  /// \return the first element in the list.
821  ///
822  /// \note Completely ignores \a Use::Prev (doesn't read, doesn't update).
823  template <class Compare>
824  static Use *mergeUseLists(Use *L, Use *R, Compare Cmp) {
825  Use *Merged;
826  Use **Next = &Merged;
827 
828  while (true) {
829  if (!L) {
830  *Next = R;
831  break;
832  }
833  if (!R) {
834  *Next = L;
835  break;
836  }
837  if (Cmp(*R, *L)) {
838  *Next = R;
839  Next = &R->Next;
840  R = R->Next;
841  } else {
842  *Next = L;
843  Next = &L->Next;
844  L = L->Next;
845  }
846  }
847 
848  return Merged;
849  }
850 
851 protected:
852  unsigned short getSubclassDataFromValue() const { return SubclassData; }
853  void setValueSubclassData(unsigned short D) { SubclassData = D; }
854 };
855 
856 struct ValueDeleter { void operator()(Value *V) { V->deleteValue(); } };
857 
858 /// Use this instead of std::unique_ptr<Value> or std::unique_ptr<Instruction>.
859 /// Those don't work because Value and Instruction's destructors are protected,
860 /// aren't virtual, and won't destroy the complete object.
861 using unique_value = std::unique_ptr<Value, ValueDeleter>;
862 
863 inline raw_ostream &operator<<(raw_ostream &OS, const Value &V) {
864  V.print(OS);
865  return OS;
866 }
867 
868 void Use::set(Value *V) {
869  if (Val) removeFromList();
870  Val = V;
871  if (V) V->addUse(*this);
872 }
873 
875  set(RHS);
876  return RHS;
877 }
878 
879 const Use &Use::operator=(const Use &RHS) {
880  set(RHS.Val);
881  return *this;
882 }
883 
884 template <class Compare> void Value::sortUseList(Compare Cmp) {
885  if (!UseList || !UseList->Next)
886  // No need to sort 0 or 1 uses.
887  return;
888 
889  // Note: this function completely ignores Prev pointers until the end when
890  // they're fixed en masse.
891 
892  // Create a binomial vector of sorted lists, visiting uses one at a time and
893  // merging lists as necessary.
894  const unsigned MaxSlots = 32;
895  Use *Slots[MaxSlots];
896 
897  // Collect the first use, turning it into a single-item list.
898  Use *Next = UseList->Next;
899  UseList->Next = nullptr;
900  unsigned NumSlots = 1;
901  Slots[0] = UseList;
902 
903  // Collect all but the last use.
904  while (Next->Next) {
905  Use *Current = Next;
906  Next = Current->Next;
907 
908  // Turn Current into a single-item list.
909  Current->Next = nullptr;
910 
911  // Save Current in the first available slot, merging on collisions.
912  unsigned I;
913  for (I = 0; I < NumSlots; ++I) {
914  if (!Slots[I])
915  break;
916 
917  // Merge two lists, doubling the size of Current and emptying slot I.
918  //
919  // Since the uses in Slots[I] originally preceded those in Current, send
920  // Slots[I] in as the left parameter to maintain a stable sort.
921  Current = mergeUseLists(Slots[I], Current, Cmp);
922  Slots[I] = nullptr;
923  }
924  // Check if this is a new slot.
925  if (I == NumSlots) {
926  ++NumSlots;
927  assert(NumSlots <= MaxSlots && "Use list bigger than 2^32");
928  }
929 
930  // Found an open slot.
931  Slots[I] = Current;
932  }
933 
934  // Merge all the lists together.
935  assert(Next && "Expected one more Use");
936  assert(!Next->Next && "Expected only one Use");
937  UseList = Next;
938  for (unsigned I = 0; I < NumSlots; ++I)
939  if (Slots[I])
940  // Since the uses in Slots[I] originally preceded those in UseList, send
941  // Slots[I] in as the left parameter to maintain a stable sort.
942  UseList = mergeUseLists(Slots[I], UseList, Cmp);
943 
944  // Fix the Prev pointers.
945  for (Use *I = UseList, **Prev = &UseList; I; I = I->Next) {
946  I->Prev = Prev;
947  Prev = &I->Next;
948  }
949 }
950 
951 // isa - Provide some specializations of isa so that we don't have to include
952 // the subtype header files to test to see if the value is a subclass...
953 //
954 template <> struct isa_impl<Constant, Value> {
955  static inline bool doit(const Value &Val) {
956  static_assert(Value::ConstantFirstVal == 0, "Val.getValueID() >= Value::ConstantFirstVal");
957  return Val.getValueID() <= Value::ConstantLastVal;
958  }
959 };
960 
961 template <> struct isa_impl<ConstantData, Value> {
962  static inline bool doit(const Value &Val) {
963  return Val.getValueID() >= Value::ConstantDataFirstVal &&
964  Val.getValueID() <= Value::ConstantDataLastVal;
965  }
966 };
967 
968 template <> struct isa_impl<ConstantAggregate, Value> {
969  static inline bool doit(const Value &Val) {
970  return Val.getValueID() >= Value::ConstantAggregateFirstVal &&
971  Val.getValueID() <= Value::ConstantAggregateLastVal;
972  }
973 };
974 
975 template <> struct isa_impl<Argument, Value> {
976  static inline bool doit (const Value &Val) {
977  return Val.getValueID() == Value::ArgumentVal;
978  }
979 };
980 
981 template <> struct isa_impl<InlineAsm, Value> {
982  static inline bool doit(const Value &Val) {
983  return Val.getValueID() == Value::InlineAsmVal;
984  }
985 };
986 
987 template <> struct isa_impl<Instruction, Value> {
988  static inline bool doit(const Value &Val) {
989  return Val.getValueID() >= Value::InstructionVal;
990  }
991 };
992 
993 template <> struct isa_impl<BasicBlock, Value> {
994  static inline bool doit(const Value &Val) {
995  return Val.getValueID() == Value::BasicBlockVal;
996  }
997 };
998 
999 template <> struct isa_impl<Function, Value> {
1000  static inline bool doit(const Value &Val) {
1001  return Val.getValueID() == Value::FunctionVal;
1002  }
1003 };
1004 
1005 template <> struct isa_impl<GlobalVariable, Value> {
1006  static inline bool doit(const Value &Val) {
1007  return Val.getValueID() == Value::GlobalVariableVal;
1008  }
1009 };
1010 
1011 template <> struct isa_impl<GlobalAlias, Value> {
1012  static inline bool doit(const Value &Val) {
1013  return Val.getValueID() == Value::GlobalAliasVal;
1014  }
1015 };
1016 
1017 template <> struct isa_impl<GlobalIFunc, Value> {
1018  static inline bool doit(const Value &Val) {
1019  return Val.getValueID() == Value::GlobalIFuncVal;
1020  }
1021 };
1022 
1023 template <> struct isa_impl<GlobalValue, Value> {
1024  static inline bool doit(const Value &Val) {
1025  return isa<GlobalObject>(Val) || isa<GlobalAlias>(Val);
1026  }
1027 };
1028 
1029 template <> struct isa_impl<GlobalObject, Value> {
1030  static inline bool doit(const Value &Val) {
1031  return isa<GlobalVariable>(Val) || isa<Function>(Val) ||
1032  isa<GlobalIFunc>(Val);
1033  }
1034 };
1035 
1036 // Create wrappers for C Binding types (see CBindingWrapping.h).
1038 
1039 // Specialized opaque value conversions.
1041  return reinterpret_cast<Value**>(Vals);
1042 }
1043 
1044 template<typename T>
1045 inline T **unwrap(LLVMValueRef *Vals, unsigned Length) {
1046 #ifndef NDEBUG
1047  for (LLVMValueRef *I = Vals, *E = Vals + Length; I != E; ++I)
1048  unwrap<T>(*I); // For side effect of calling assert on invalid usage.
1049 #endif
1050  (void)Length;
1051  return reinterpret_cast<T**>(Vals);
1052 }
1053 
1054 inline LLVMValueRef *wrap(const Value **Vals) {
1055  return reinterpret_cast<LLVMValueRef*>(const_cast<Value**>(Vals));
1056 }
1057 
1058 } // end namespace llvm
1059 
1060 #endif // LLVM_IR_VALUE_H
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:391
llvm::Value::stripPointerCastsAndAliases
const Value * stripPointerCastsAndAliases() const
Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
Definition: Value.cpp:689
llvm
This is an optimization pass for GlobalISel generic memory operations.
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:234
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:217
llvm::Value::getPointerAlignment
Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
Definition: Value.cpp:918
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:113
llvm::Value::hasOneUse
bool hasOneUse() const
Return true if there is exactly one use of this value.
Definition: Value.h:434
llvm::Value::MaximumAlignment
static constexpr uint64_t MaximumAlignment
Definition: Value.h:793
llvm::Value::stripInBoundsConstantOffsets
Value * stripInBoundsConstantOffsets()
Definition: Value.h:678
llvm::Value::SubclassOptionalData
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
Definition: Value.h:90
llvm::Value::hasMetadata
bool hasMetadata(unsigned KindID) const
Return true if this value has the given type of metadata attached.
Definition: Value.h:592
llvm::ValueHandleBase
This is the common base class of value handles.
Definition: ValueHandle.h:29
llvm::Function
Definition: Function.h:62
llvm::Value::stripPointerCastsAndAliases
Value * stripPointerCastsAndAliases()
Definition: Value.h:645
llvm::Value::dump
void dump() const
Support for debugging, callable in GDB: V->dump()
Definition: AsmWriter.cpp:4813
StringRef.h
llvm::Value::getSubclassDataFromValue
unsigned short getSubclassDataFromValue() const
Definition: Value.h:852
pointer
Replace within non kernel function use of LDS with pointer
Definition: AMDGPUReplaceLDSUseWithPointer.cpp:441
llvm::isa_impl< GlobalIFunc, Value >::doit
static bool doit(const Value &Val)
Definition: Value.h:1018
llvm::Value::uses
iterator_range< const_use_iterator > uses() const
Definition: Value.h:380
Types.h
llvm::Value::hasName
bool hasName() const
Definition: Value.h:261
llvm::GlobalVariable
Definition: GlobalVariable.h:40
llvm::ConstantAggregate
Base class for aggregate constants (with operands).
Definition: Constants.h:385
llvm::GlobalAlias
Definition: GlobalAlias.h:28
llvm::Value::materialized_users
iterator_range< const_user_iterator > materialized_users() const
Definition: Value.h:418
llvm::Value::getUniqueUndroppableUser
const User * getUniqueUndroppableUser() const
Definition: Value.h:464
llvm::Value::materialized_user_begin
const_user_iterator materialized_user_begin() const
Definition: Value.h:394
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::isa_impl< GlobalVariable, Value >::doit
static bool doit(const Value &Val)
Definition: Value.h:1006
llvm::operator!=
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:1981
llvm::ValueDeleter
Definition: Value.h:856
llvm::Value::hasOneUser
bool hasOneUser() const
Return true if there is exactly one user of this value.
Definition: Value.cpp:157
llvm::Value::HasHungOffUses
unsigned HasHungOffUses
Definition: Value.h:120
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::Value::stripAndAccumulateConstantOffsets
const Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false, function_ref< bool(Value &Value, APInt &Offset)> ExternalAnalysis=nullptr) const
Accumulate the constant offset this value has compared to a base pointer.
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
CBindingWrapping.h
llvm::Value::user_begin
user_iterator user_begin()
Definition: Value.h:397
llvm::Value::NumUserOperands
unsigned NumUserOperands
Definition: Value.h:114
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:853
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:199
Use.h
llvm::Value::materialized_user_begin
user_iterator materialized_user_begin()
Definition: Value.h:393
llvm::RISCVFenceField::R
@ R
Definition: RISCVBaseInfo.h:207
llvm::isa_impl< BasicBlock, Value >::doit
static bool doit(const Value &Val)
Definition: Value.h:994
llvm::Use::operator=
Value * operator=(Value *RHS)
Definition: Value.h:874
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:1012
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:988
llvm::Value::reverseUseList
void reverseUseList()
Reverse the use-list.
Definition: Value.cpp:993
DEFINE_ISA_CONVERSION_FUNCTIONS
#define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref)
Definition: CBindingWrapping.h:28
llvm::Value::HasName
unsigned HasName
Definition: Value.h:118
llvm::Value::operator=
Value & operator=(const Value &)=delete
llvm::InlinerFunctionImportStatsOpts::No
@ No
llvm::ISD::Constant
@ Constant
Definition: ISDOpcodes.h:76
llvm::Value::NumUserOperandsBits
@ NumUserOperandsBits
Definition: Value.h:113
llvm::Value::use_iterator
use_iterator_impl< Use > use_iterator
Definition: Value.h:353
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:1000
llvm::User
Definition: User.h:44
llvm::Value::DoPHITranslation
Value * DoPHITranslation(const BasicBlock *CurBB, const BasicBlock *PredBB)
Definition: Value.h:783
llvm::Value::getSingleUndroppableUse
Use * getSingleUndroppableUse()
Return true if there is exactly one use of this value that cannot be dropped.
Definition: Value.cpp:167
llvm::GlobalObject
Definition: GlobalObject.h:28
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:861
llvm::Value::stripAndAccumulateInBoundsConstantOffsets
Value * stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL, APInt &Offset)
Definition: Value.h:732
llvm::Value::assertModuleIsMaterializedImpl
void assertModuleIsMaterializedImpl() const
Definition: Value.cpp:454
llvm::isa_impl< GlobalAlias, Value >::doit
static bool doit(const Value &Val)
Definition: Value.h:1012
llvm::Value::user_end
const_user_iterator user_end() const
Definition: Value.h:406
llvm::Value::uses
iterator_range< use_iterator > uses()
Definition: Value.h:376
llvm::Value::getValueID
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:532
llvm::Instruction
Definition: Instruction.h:45
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:256
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::Value::setName
void setName(const Twine &Name)
Change the name of the value.
Definition: Value.cpp:376
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::MaxAlignmentExponent
static constexpr unsigned MaxAlignmentExponent
The maximum alignment for instructions.
Definition: Value.h:792
llvm::Value::isTransitiveUsedByMetadataOnly
bool isTransitiveUsedByMetadataOnly() const
Definition: Value.cpp:1022
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
llvm::Value::use_empty
bool use_empty() const
Definition: Value.h:344
llvm::Value::dropDroppableUsesIn
void dropDroppableUsesIn(User &Usr)
Remove every use of this value in User that can safely be removed.
Definition: Value.cpp:209
llvm::Value::hasValueHandle
bool hasValueHandle() const
Return true if there is a value handle associated with this value.
Definition: Value.h:554
llvm::Value::use_end
const_use_iterator use_end() const
Definition: Value.h:369
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:168
llvm::Value::user_end
user_iterator user_end()
Definition: Value.h:405
llvm::Value::user_back
User * user_back()
Definition: Value.h:407
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:693
llvm::InlineAsm
Definition: InlineAsm.h:31
llvm::Value::Value
Value(Type *Ty, unsigned scid)
Definition: Value.cpp:53
llvm::Value::hasNUndroppableUsesOrMore
bool hasNUndroppableUsesOrMore(unsigned N) const
Return true if this value has N uses or more.
Definition: Value.cpp:195
llvm::Use::set
void set(Value *Val)
Definition: Value.h:868
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:206
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::isa_impl< InlineAsm, Value >::doit
static bool doit(const Value &Val)
Definition: Value.h:982
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::Value::getNameOrAsOperand
std::string getNameOrAsOperand() const
Definition: Value.cpp:443
llvm::Value::mutateType
void mutateType(Type *Ty)
Mutate the type of this Value to be of the specified type.
Definition: Value.h:801
llvm::Value::IsUsedByMD
unsigned IsUsedByMD
Definition: Value.h:117
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:843
llvm::Value::addMetadata
void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
Definition: Metadata.cpp:1268
uint64_t
llvm::isa_impl< ConstantData, Value >::doit
static bool doit(const Value &Val)
Definition: Value.h:962
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::Value::getUniqueUndroppableUser
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:179
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:153
llvm::Value::materialized_use_empty
bool materialized_use_empty() const
Definition: Value.h:349
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:544
llvm::Value::user_begin
const_user_iterator user_begin() const
Definition: Value.h:401
llvm::Value::getValueName
ValueName * getValueName() const
Definition: Value.cpp:281
llvm::Value::replaceNonMetadataUsesWith
void replaceNonMetadataUsesWith(Value *V)
Change non-metadata uses of this to point to a new Value.
Definition: Value.cpp:536
llvm::Value::print
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
Definition: AsmWriter.cpp:4569
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::isa_impl< ConstantAggregate, Value >::doit
static bool doit(const Value &Val)
Definition: Value.h:969
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::Value::setValueName
void setValueName(ValueName *VN)
Definition: Value.cpp:292
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:584
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:701
llvm::Value::materialized_uses
iterator_range< use_iterator > materialized_uses()
Definition: Value.h:370
llvm::operator==
bool operator==(uint64_t V1, const APInt &V2)
Definition: APInt.h:1979
iterator_range.h
llvm::Value::use_begin
use_iterator use_begin()
Definition: Value.h:360
llvm::ISD::BasicBlock
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
llvm::Value::user_empty
bool user_empty() const
Definition: Value.h:385
llvm::MDNode
Metadata node.
Definition: Metadata.h:906
llvm::Value::clearMetadata
void clearMetadata()
Erase all metadata attached to this Value.
Definition: Metadata.cpp:1291
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:4652
llvm::APInt
Class for arbitrary precision integers.
Definition: APInt.h:75
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:251
llvm::hasSingleElement
bool hasSingleElement(ContainerTy &&C)
Returns true if the given container only contains a single element.
Definition: STLExtras.h:259
llvm::Value::ValueTy
ValueTy
Concrete subclass of this.
Definition: Value.h:513
llvm::operator*
APInt operator*(APInt a, uint64_t RHS)
Definition: APInt.h:2103
llvm::Value::getSingleUndroppableUse
const Use * getSingleUndroppableUse() const
Definition: Value.h:457
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:549
llvm::Value::getNumUses
unsigned getNumUses() const
This method computes the number of uses of this Value.
Definition: Value.cpp:255
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:255
llvm::Value::stripPointerCasts
Value * stripPointerCasts()
Definition: Value.h:635
llvm::Value::replaceAllUsesWith
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Definition: Value.cpp:532
llvm::Value::getContext
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:991
llvm::Value::use_end
use_iterator use_end()
Definition: Value.h:368
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:1197
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::Value::stripAndAccumulateConstantOffsets
Value * stripAndAccumulateConstantOffsets(const DataLayout &DL, APInt &Offset, bool AllowNonInbounds, bool AllowInvariantGroup=false)
Definition: Value.h:717
Node
Definition: ItaniumDemangle.h:235
llvm::Value::setMetadata
void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
Definition: Metadata.cpp:1234
llvm::Value::getRawSubclassOptionalData
unsigned getRawSubclassOptionalData() const
Return the raw optional flags value contained in this value.
Definition: Value.h:539
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:309
llvm::isa_impl< GlobalObject, Value >::doit
static bool doit(const Value &Val)
Definition: Value.h:1030
llvm::Value::stripPointerCasts
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
Definition: Value.cpp:685
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:727
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:777
llvm::Value::use_begin
const_use_iterator use_begin() const
Definition: Value.h:364
llvm::Value::stripPointerCastsSameRepresentation
Value * stripPointerCastsSameRepresentation()
Definition: Value.h:656
llvm::Value::sortUseList
void sortUseList(Compare Cmp)
Sort the use-list.
Definition: Value.h:884
llvm::Value::HasMetadata
unsigned HasMetadata
Definition: Value.h:119
llvm::Value::eraseMetadata
bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
Definition: Metadata.cpp:1279
Alignment.h
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::Value::user_back
const User * user_back() const
Definition: Value.h:411
llvm::Value::user_iterator
user_iterator_impl< User > user_iterator
Definition: Value.h:390
llvm::Value::hasNUndroppableUses
bool hasNUndroppableUses(unsigned N) const
Return true if there this value.
Definition: Value.cpp:191
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:76
llvm::Value::hasMetadata
bool hasMetadata(StringRef Kind) const
Definition: Value.h:595
llvm::X86::FirstMacroFusionInstKind::Cmp
@ Cmp
llvm::Value::addUse
void addUse(Use &U)
This method should only be used by the Use class.
Definition: Value.h:505
Casting.h
llvm::Value::hasNUses
bool hasNUses(unsigned N) const
Return true if this Value has exactly N uses.
Definition: Value.cpp:149
llvm::Value::assertModuleIsMaterialized
void assertModuleIsMaterialized() const
Definition: Value.h:338
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:425
llvm::Value::HasDescriptor
unsigned HasDescriptor
Definition: Value.h:121
llvm::PrevailingType::Yes
@ Yes
llvm::Value::const_use_iterator
use_iterator_impl< const Use > const_use_iterator
Definition: Value.h:354
llvm::Value::materialized_uses
iterator_range< const_use_iterator > materialized_uses() const
Definition: Value.h:373
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:781
llvm::isa_impl< GlobalValue, Value >::doit
static bool doit(const Value &Val)
Definition: Value.h:1024
llvm::Value::stripInBoundsOffsets
Value * stripInBoundsOffsets(function_ref< void(const Value *)> Func=[](const Value *) {})
Definition: Value.h:744
llvm::Value::isUsedByMetadata
bool isUsedByMetadata() const
Return true if there is metadata referencing this value.
Definition: Value.h:557
llvm::Value::stripInBoundsConstantOffsets
const Value * stripInBoundsConstantOffsets() const
Strip off pointer casts and all-constant inbounds GEPs.
Definition: Value.cpp:697
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:983
llvm::ValueDeleter::operator()
void operator()(Value *V)
Definition: Value.h:856
N
#define N
llvm::Value::deleteValue
void deleteValue()
Delete a pointer to a generic Value.
Definition: Value.cpp:110
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:356
llvm::isa_impl< Constant, Value >::doit
static bool doit(const Value &Val)
Definition: Value.h:955
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:1223
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:357
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::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.cpp:540
llvm::Value::takeName
void takeName(Value *V)
Transfer the name from V to this value.
Definition: Value.cpp:382
llvm::Value::stripPointerCastsForAliasAnalysis
Value * stripPointerCastsForAliasAnalysis()
Definition: Value.h:668
llvm::GlobalIFunc
Definition: GlobalIFunc.h:34
llvm::Value::hasMetadata
bool hasMetadata() const
Return true if this value has any metadata attached to it.
Definition: Value.h:588
llvm::isa_impl< Argument, Value >::doit
static bool doit(const Value &Val)
Definition: Value.h:976
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::Value::users
iterator_range< user_iterator > users()
Definition: Value.h:421
llvm::isa_impl
Definition: Casting.h:56
llvm::Value::materialized_users
iterator_range< user_iterator > materialized_users()
Definition: Value.h:415
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:44