LLVM  14.0.0git
Metadata.h
Go to the documentation of this file.
1 //===- llvm/IR/Metadata.h - Metadata definitions ----------------*- 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 /// @file
10 /// This file contains the declarations for metadata subclasses.
11 /// They represent the different flavors of metadata that live in LLVM.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_IR_METADATA_H
16 #define LLVM_IR_METADATA_H
17 
18 #include "llvm/ADT/ArrayRef.h"
19 #include "llvm/ADT/DenseMap.h"
20 #include "llvm/ADT/DenseMapInfo.h"
21 #include "llvm/ADT/None.h"
22 #include "llvm/ADT/PointerUnion.h"
23 #include "llvm/ADT/STLExtras.h"
24 #include "llvm/ADT/SmallVector.h"
25 #include "llvm/ADT/StringMap.h"
26 #include "llvm/ADT/StringRef.h"
27 #include "llvm/ADT/ilist_node.h"
29 #include "llvm/IR/Constant.h"
30 #include "llvm/IR/LLVMContext.h"
31 #include "llvm/IR/Value.h"
33 #include "llvm/Support/Casting.h"
35 #include <cassert>
36 #include <cstddef>
37 #include <cstdint>
38 #include <iterator>
39 #include <memory>
40 #include <string>
41 #include <type_traits>
42 #include <utility>
43 
44 namespace llvm {
45 
46 class Module;
47 class ModuleSlotTracker;
48 class raw_ostream;
49 class Type;
50 
52  DEBUG_METADATA_VERSION = 3 // Current debug info version number.
53 };
54 
55 /// Magic number in the value profile metadata showing a target has been
56 /// promoted for the instruction and shouldn't be promoted again.
58 
59 /// Root of the metadata hierarchy.
60 ///
61 /// This is a root class for typeless data in the IR.
62 class Metadata {
64 
65  /// RTTI.
66  const unsigned char SubclassID;
67 
68 protected:
69  /// Active type of storage.
71 
72  /// Storage flag for non-uniqued, otherwise unowned, metadata.
73  unsigned char Storage : 7;
74 
75  unsigned char SubclassData1 : 1;
76  unsigned short SubclassData16 = 0;
77  unsigned SubclassData32 = 0;
78 
79 public:
80  enum MetadataKind {
81 #define HANDLE_METADATA_LEAF(CLASS) CLASS##Kind,
82 #include "llvm/IR/Metadata.def"
83  };
84 
85 protected:
87  : SubclassID(ID), Storage(Storage), SubclassData1(false) {
88  static_assert(sizeof(*this) == 8, "Metadata fields poorly packed");
89  }
90 
91  ~Metadata() = default;
92 
93  /// Default handling of a changed operand, which asserts.
94  ///
95  /// If subclasses pass themselves in as owners to a tracking node reference,
96  /// they must provide an implementation of this method.
97  void handleChangedOperand(void *, Metadata *) {
98  llvm_unreachable("Unimplemented in Metadata subclass");
99  }
100 
101 public:
102  unsigned getMetadataID() const { return SubclassID; }
103 
104  /// User-friendly dump.
105  ///
106  /// If \c M is provided, metadata nodes will be numbered canonically;
107  /// otherwise, pointer addresses are substituted.
108  ///
109  /// Note: this uses an explicit overload instead of default arguments so that
110  /// the nullptr version is easy to call from a debugger.
111  ///
112  /// @{
113  void dump() const;
114  void dump(const Module *M) const;
115  /// @}
116 
117  /// Print.
118  ///
119  /// Prints definition of \c this.
120  ///
121  /// If \c M is provided, metadata nodes will be numbered canonically;
122  /// otherwise, pointer addresses are substituted.
123  /// @{
124  void print(raw_ostream &OS, const Module *M = nullptr,
125  bool IsForDebug = false) const;
126  void print(raw_ostream &OS, ModuleSlotTracker &MST, const Module *M = nullptr,
127  bool IsForDebug = false) const;
128  /// @}
129 
130  /// Print as operand.
131  ///
132  /// Prints reference of \c this.
133  ///
134  /// If \c M is provided, metadata nodes will be numbered canonically;
135  /// otherwise, pointer addresses are substituted.
136  /// @{
137  void printAsOperand(raw_ostream &OS, const Module *M = nullptr) const;
139  const Module *M = nullptr) const;
140  /// @}
141 };
142 
143 // Create wrappers for C Binding types (see CBindingWrapping.h).
145 
146 // Specialized opaque metadata conversions.
148  return reinterpret_cast<Metadata**>(MDs);
149 }
150 
151 #define HANDLE_METADATA(CLASS) class CLASS;
152 #include "llvm/IR/Metadata.def"
153 
154 // Provide specializations of isa so that we don't need definitions of
155 // subclasses to see if the metadata is a subclass.
156 #define HANDLE_METADATA_LEAF(CLASS) \
157  template <> struct isa_impl<CLASS, Metadata> { \
158  static inline bool doit(const Metadata &MD) { \
159  return MD.getMetadataID() == Metadata::CLASS##Kind; \
160  } \
161  };
162 #include "llvm/IR/Metadata.def"
163 
164 inline raw_ostream &operator<<(raw_ostream &OS, const Metadata &MD) {
165  MD.print(OS);
166  return OS;
167 }
168 
169 /// Metadata wrapper in the Value hierarchy.
170 ///
171 /// A member of the \a Value hierarchy to represent a reference to metadata.
172 /// This allows, e.g., instrinsics to have metadata as operands.
173 ///
174 /// Notably, this is the only thing in either hierarchy that is allowed to
175 /// reference \a LocalAsMetadata.
176 class MetadataAsValue : public Value {
178  friend class LLVMContextImpl;
179 
180  Metadata *MD;
181 
182  MetadataAsValue(Type *Ty, Metadata *MD);
183 
184  /// Drop use of metadata (during teardown).
185  void dropUse() { MD = nullptr; }
186 
187 public:
189 
192 
193  Metadata *getMetadata() const { return MD; }
194 
195  static bool classof(const Value *V) {
196  return V->getValueID() == MetadataAsValueVal;
197  }
198 
199 private:
200  void handleChangedMetadata(Metadata *MD);
201  void track();
202  void untrack();
203 };
204 
205 /// API for tracking metadata references through RAUW and deletion.
206 ///
207 /// Shared API for updating \a Metadata pointers in subclasses that support
208 /// RAUW.
209 ///
210 /// This API is not meant to be used directly. See \a TrackingMDRef for a
211 /// user-friendly tracking reference.
213 public:
214  /// Track the reference to metadata.
215  ///
216  /// Register \c MD with \c *MD, if the subclass supports tracking. If \c *MD
217  /// gets RAUW'ed, \c MD will be updated to the new address. If \c *MD gets
218  /// deleted, \c MD will be set to \c nullptr.
219  ///
220  /// If tracking isn't supported, \c *MD will not change.
221  ///
222  /// \return true iff tracking is supported by \c MD.
223  static bool track(Metadata *&MD) {
224  return track(&MD, *MD, static_cast<Metadata *>(nullptr));
225  }
226 
227  /// Track the reference to metadata for \a Metadata.
228  ///
229  /// As \a track(Metadata*&), but with support for calling back to \c Owner to
230  /// tell it that its operand changed. This could trigger \c Owner being
231  /// re-uniqued.
232  static bool track(void *Ref, Metadata &MD, Metadata &Owner) {
233  return track(Ref, MD, &Owner);
234  }
235 
236  /// Track the reference to metadata for \a MetadataAsValue.
237  ///
238  /// As \a track(Metadata*&), but with support for calling back to \c Owner to
239  /// tell it that its operand changed. This could trigger \c Owner being
240  /// re-uniqued.
241  static bool track(void *Ref, Metadata &MD, MetadataAsValue &Owner) {
242  return track(Ref, MD, &Owner);
243  }
244 
245  /// Stop tracking a reference to metadata.
246  ///
247  /// Stops \c *MD from tracking \c MD.
248  static void untrack(Metadata *&MD) { untrack(&MD, *MD); }
249  static void untrack(void *Ref, Metadata &MD);
250 
251  /// Move tracking from one reference to another.
252  ///
253  /// Semantically equivalent to \c untrack(MD) followed by \c track(New),
254  /// except that ownership callbacks are maintained.
255  ///
256  /// Note: it is an error if \c *MD does not equal \c New.
257  ///
258  /// \return true iff tracking is supported by \c MD.
259  static bool retrack(Metadata *&MD, Metadata *&New) {
260  return retrack(&MD, *MD, &New);
261  }
262  static bool retrack(void *Ref, Metadata &MD, void *New);
263 
264  /// Check whether metadata is replaceable.
265  static bool isReplaceable(const Metadata &MD);
266 
268 
269 private:
270  /// Track a reference to metadata for an owner.
271  ///
272  /// Generalized version of tracking.
273  static bool track(void *Ref, Metadata &MD, OwnerTy Owner);
274 };
275 
276 /// Shared implementation of use-lists for replaceable metadata.
277 ///
278 /// Most metadata cannot be RAUW'ed. This is a shared implementation of
279 /// use-lists and associated API for the two that support it (\a ValueAsMetadata
280 /// and \a TempMDNode).
282  friend class MetadataTracking;
283 
284 public:
286 
287 private:
289  uint64_t NextIndex = 0;
291 
292 public:
294 
296  assert(UseMap.empty() && "Cannot destroy in-use replaceable metadata");
297  }
298 
299  LLVMContext &getContext() const { return Context; }
300 
301  /// Replace all uses of this with MD.
302  ///
303  /// Replace all uses of this with \c MD, which is allowed to be null.
304  void replaceAllUsesWith(Metadata *MD);
305 
306  /// Returns the list of all DIArgList users of this.
308 
309  /// Resolve all uses of this.
310  ///
311  /// Resolve all uses of this, turning off RAUW permanently. If \c
312  /// ResolveUsers, call \a MDNode::resolve() on any users whose last operand
313  /// is resolved.
314  void resolveAllUses(bool ResolveUsers = true);
315 
316 private:
317  void addRef(void *Ref, OwnerTy Owner);
318  void dropRef(void *Ref);
319  void moveRef(void *Ref, void *New, const Metadata &MD);
320 
321  /// Lazily construct RAUW support on MD.
322  ///
323  /// If this is an unresolved MDNode, RAUW support will be created on-demand.
324  /// ValueAsMetadata always has RAUW support.
325  static ReplaceableMetadataImpl *getOrCreate(Metadata &MD);
326 
327  /// Get RAUW support on MD, if it exists.
328  static ReplaceableMetadataImpl *getIfExists(Metadata &MD);
329 
330  /// Check whether this node will support RAUW.
331  ///
332  /// Returns \c true unless getOrCreate() would return null.
333  static bool isReplaceable(const Metadata &MD);
334 };
335 
336 /// Value wrapper in the Metadata hierarchy.
337 ///
338 /// This is a custom value handle that allows other metadata to refer to
339 /// classes in the Value hierarchy.
340 ///
341 /// Because of full uniquing support, each value is only wrapped by a single \a
342 /// ValueAsMetadata object, so the lookup maps are far more efficient than
343 /// those using ValueHandleBase.
346  friend class LLVMContextImpl;
347 
348  Value *V;
349 
350  /// Drop users without RAUW (during teardown).
351  void dropUsers() {
352  ReplaceableMetadataImpl::resolveAllUses(/* ResolveUsers */ false);
353  }
354 
355 protected:
356  ValueAsMetadata(unsigned ID, Value *V)
358  assert(V && "Expected valid value");
359  }
360 
361  ~ValueAsMetadata() = default;
362 
363 public:
364  static ValueAsMetadata *get(Value *V);
365 
367  return cast<ConstantAsMetadata>(get(C));
368  }
369 
370  static LocalAsMetadata *getLocal(Value *Local) {
371  return cast<LocalAsMetadata>(get(Local));
372  }
373 
374  static ValueAsMetadata *getIfExists(Value *V);
375 
377  return cast_or_null<ConstantAsMetadata>(getIfExists(C));
378  }
379 
381  return cast_or_null<LocalAsMetadata>(getIfExists(Local));
382  }
383 
384  Value *getValue() const { return V; }
385  Type *getType() const { return V->getType(); }
386  LLVMContext &getContext() const { return V->getContext(); }
387 
390  }
391 
392  static void handleDeletion(Value *V);
393  static void handleRAUW(Value *From, Value *To);
394 
395 protected:
396  /// Handle collisions after \a Value::replaceAllUsesWith().
397  ///
398  /// RAUW isn't supported directly for \a ValueAsMetadata, but if the wrapped
399  /// \a Value gets RAUW'ed and the target already exists, this is used to
400  /// merge the two metadata nodes.
403  }
404 
405 public:
406  static bool classof(const Metadata *MD) {
407  return MD->getMetadataID() == LocalAsMetadataKind ||
408  MD->getMetadataID() == ConstantAsMetadataKind;
409  }
410 };
411 
413  friend class ValueAsMetadata;
414 
416  : ValueAsMetadata(ConstantAsMetadataKind, C) {}
417 
418 public:
421  }
422 
425  }
426 
427  Constant *getValue() const {
428  return cast<Constant>(ValueAsMetadata::getValue());
429  }
430 
431  static bool classof(const Metadata *MD) {
432  return MD->getMetadataID() == ConstantAsMetadataKind;
433  }
434 };
435 
437  friend class ValueAsMetadata;
438 
439  LocalAsMetadata(Value *Local)
440  : ValueAsMetadata(LocalAsMetadataKind, Local) {
441  assert(!isa<Constant>(Local) && "Expected local value");
442  }
443 
444 public:
445  static LocalAsMetadata *get(Value *Local) {
446  return ValueAsMetadata::getLocal(Local);
447  }
448 
450  return ValueAsMetadata::getLocalIfExists(Local);
451  }
452 
453  static bool classof(const Metadata *MD) {
454  return MD->getMetadataID() == LocalAsMetadataKind;
455  }
456 };
457 
458 /// Transitional API for extracting constants from Metadata.
459 ///
460 /// This namespace contains transitional functions for metadata that points to
461 /// \a Constants.
462 ///
463 /// In prehistory -- when metadata was a subclass of \a Value -- \a MDNode
464 /// operands could refer to any \a Value. There's was a lot of code like this:
465 ///
466 /// \code
467 /// MDNode *N = ...;
468 /// auto *CI = dyn_cast<ConstantInt>(N->getOperand(2));
469 /// \endcode
470 ///
471 /// Now that \a Value and \a Metadata are in separate hierarchies, maintaining
472 /// the semantics for \a isa(), \a cast(), \a dyn_cast() (etc.) requires three
473 /// steps: cast in the \a Metadata hierarchy, extraction of the \a Value, and
474 /// cast in the \a Value hierarchy. Besides creating boiler-plate, this
475 /// requires subtle control flow changes.
476 ///
477 /// The end-goal is to create a new type of metadata, called (e.g.) \a MDInt,
478 /// so that metadata can refer to numbers without traversing a bridge to the \a
479 /// Value hierarchy. In this final state, the code above would look like this:
480 ///
481 /// \code
482 /// MDNode *N = ...;
483 /// auto *MI = dyn_cast<MDInt>(N->getOperand(2));
484 /// \endcode
485 ///
486 /// The API in this namespace supports the transition. \a MDInt doesn't exist
487 /// yet, and even once it does, changing each metadata schema to use it is its
488 /// own mini-project. In the meantime this API prevents us from introducing
489 /// complex and bug-prone control flow that will disappear in the end. In
490 /// particular, the above code looks like this:
491 ///
492 /// \code
493 /// MDNode *N = ...;
494 /// auto *CI = mdconst::dyn_extract<ConstantInt>(N->getOperand(2));
495 /// \endcode
496 ///
497 /// The full set of provided functions includes:
498 ///
499 /// mdconst::hasa <=> isa
500 /// mdconst::extract <=> cast
501 /// mdconst::extract_or_null <=> cast_or_null
502 /// mdconst::dyn_extract <=> dyn_cast
503 /// mdconst::dyn_extract_or_null <=> dyn_cast_or_null
504 ///
505 /// The target of the cast must be a subclass of \a Constant.
506 namespace mdconst {
507 
508 namespace detail {
509 
510 template <class T> T &make();
511 template <class T, class Result> struct HasDereference {
512  using Yes = char[1];
513  using No = char[2];
514  template <size_t N> struct SFINAE {};
515 
516  template <class U, class V>
517  static Yes &hasDereference(SFINAE<sizeof(static_cast<V>(*make<U>()))> * = 0);
518  template <class U, class V> static No &hasDereference(...);
519 
520  static const bool value =
521  sizeof(hasDereference<T, Result>(nullptr)) == sizeof(Yes);
522 };
523 template <class V, class M> struct IsValidPointer {
524  static const bool value = std::is_base_of<Constant, V>::value &&
526 };
527 template <class V, class M> struct IsValidReference {
528  static const bool value = std::is_base_of<Constant, V>::value &&
529  std::is_convertible<M, const Metadata &>::value;
530 };
531 
532 } // end namespace detail
533 
534 /// Check whether Metadata has a Value.
535 ///
536 /// As an analogue to \a isa(), check whether \c MD has an \a Value inside of
537 /// type \c X.
538 template <class X, class Y>
539 inline std::enable_if_t<detail::IsValidPointer<X, Y>::value, bool>
540 hasa(Y &&MD) {
541  assert(MD && "Null pointer sent into hasa");
542  if (auto *V = dyn_cast<ConstantAsMetadata>(MD))
543  return isa<X>(V->getValue());
544  return false;
545 }
546 template <class X, class Y>
547 inline std::enable_if_t<detail::IsValidReference<X, Y &>::value, bool>
548 hasa(Y &MD) {
549  return hasa(&MD);
550 }
551 
552 /// Extract a Value from Metadata.
553 ///
554 /// As an analogue to \a cast(), extract the \a Value subclass \c X from \c MD.
555 template <class X, class Y>
556 inline std::enable_if_t<detail::IsValidPointer<X, Y>::value, X *>
557 extract(Y &&MD) {
558  return cast<X>(cast<ConstantAsMetadata>(MD)->getValue());
559 }
560 template <class X, class Y>
561 inline std::enable_if_t<detail::IsValidReference<X, Y &>::value, X *>
562 extract(Y &MD) {
563  return extract(&MD);
564 }
565 
566 /// Extract a Value from Metadata, allowing null.
567 ///
568 /// As an analogue to \a cast_or_null(), extract the \a Value subclass \c X
569 /// from \c MD, allowing \c MD to be null.
570 template <class X, class Y>
571 inline std::enable_if_t<detail::IsValidPointer<X, Y>::value, X *>
573  if (auto *V = cast_or_null<ConstantAsMetadata>(MD))
574  return cast<X>(V->getValue());
575  return nullptr;
576 }
577 
578 /// Extract a Value from Metadata, if any.
579 ///
580 /// As an analogue to \a dyn_cast_or_null(), extract the \a Value subclass \c X
581 /// from \c MD, return null if \c MD doesn't contain a \a Value or if the \a
582 /// Value it does contain is of the wrong subclass.
583 template <class X, class Y>
584 inline std::enable_if_t<detail::IsValidPointer<X, Y>::value, X *>
585 dyn_extract(Y &&MD) {
586  if (auto *V = dyn_cast<ConstantAsMetadata>(MD))
587  return dyn_cast<X>(V->getValue());
588  return nullptr;
589 }
590 
591 /// Extract a Value from Metadata, if any, allowing null.
592 ///
593 /// As an analogue to \a dyn_cast_or_null(), extract the \a Value subclass \c X
594 /// from \c MD, return null if \c MD doesn't contain a \a Value or if the \a
595 /// Value it does contain is of the wrong subclass, allowing \c MD to be null.
596 template <class X, class Y>
597 inline std::enable_if_t<detail::IsValidPointer<X, Y>::value, X *>
599  if (auto *V = dyn_cast_or_null<ConstantAsMetadata>(MD))
600  return dyn_cast<X>(V->getValue());
601  return nullptr;
602 }
603 
604 } // end namespace mdconst
605 
606 //===----------------------------------------------------------------------===//
607 /// A single uniqued string.
608 ///
609 /// These are used to efficiently contain a byte sequence for metadata.
610 /// MDString is always unnamed.
611 class MDString : public Metadata {
613 
614  StringMapEntry<MDString> *Entry = nullptr;
615 
616  MDString() : Metadata(MDStringKind, Uniqued) {}
617 
618 public:
619  MDString(const MDString &) = delete;
620  MDString &operator=(MDString &&) = delete;
621  MDString &operator=(const MDString &) = delete;
622 
623  static MDString *get(LLVMContext &Context, StringRef Str);
624  static MDString *get(LLVMContext &Context, const char *Str) {
625  return get(Context, Str ? StringRef(Str) : StringRef());
626  }
627 
628  StringRef getString() const;
629 
630  unsigned getLength() const { return (unsigned)getString().size(); }
631 
633 
634  /// Pointer to the first byte of the string.
635  iterator begin() const { return getString().begin(); }
636 
637  /// Pointer to one byte past the end of the string.
638  iterator end() const { return getString().end(); }
639 
640  const unsigned char *bytes_begin() const { return getString().bytes_begin(); }
641  const unsigned char *bytes_end() const { return getString().bytes_end(); }
642 
643  /// Methods for support type inquiry through isa, cast, and dyn_cast.
644  static bool classof(const Metadata *MD) {
645  return MD->getMetadataID() == MDStringKind;
646  }
647 };
648 
649 /// A collection of metadata nodes that might be associated with a
650 /// memory access used by the alias-analysis infrastructure.
651 struct AAMDNodes {
652  explicit AAMDNodes() = default;
653  explicit AAMDNodes(MDNode *T, MDNode *TS, MDNode *S, MDNode *N)
654  : TBAA(T), TBAAStruct(TS), Scope(S), NoAlias(N) {}
655 
656  bool operator==(const AAMDNodes &A) const {
657  return TBAA == A.TBAA && TBAAStruct == A.TBAAStruct && Scope == A.Scope &&
658  NoAlias == A.NoAlias;
659  }
660 
661  bool operator!=(const AAMDNodes &A) const { return !(*this == A); }
662 
663  explicit operator bool() const {
664  return TBAA || TBAAStruct || Scope || NoAlias;
665  }
666 
667  /// The tag for type-based alias analysis.
668  MDNode *TBAA = nullptr;
669 
670  /// The tag for type-based alias analysis (tbaa struct).
671  MDNode *TBAAStruct = nullptr;
672 
673  /// The tag for alias scope specification (used with noalias).
674  MDNode *Scope = nullptr;
675 
676  /// The tag specifying the noalias scope.
677  MDNode *NoAlias = nullptr;
678 
679  // Shift tbaa Metadata node to start off bytes later
680  static MDNode *shiftTBAA(MDNode *M, size_t off);
681 
682  // Shift tbaa.struct Metadata node to start off bytes later
683  static MDNode *shiftTBAAStruct(MDNode *M, size_t off);
684 
685  /// Given two sets of AAMDNodes that apply to the same pointer,
686  /// give the best AAMDNodes that are compatible with both (i.e. a set of
687  /// nodes whose allowable aliasing conclusions are a subset of those
688  /// allowable by both of the inputs). However, for efficiency
689  /// reasons, do not create any new MDNodes.
690  AAMDNodes intersect(const AAMDNodes &Other) const {
691  AAMDNodes Result;
692  Result.TBAA = Other.TBAA == TBAA ? TBAA : nullptr;
693  Result.TBAAStruct = Other.TBAAStruct == TBAAStruct ? TBAAStruct : nullptr;
694  Result.Scope = Other.Scope == Scope ? Scope : nullptr;
695  Result.NoAlias = Other.NoAlias == NoAlias ? NoAlias : nullptr;
696  return Result;
697  }
698 
699  /// Create a new AAMDNode that describes this AAMDNode after applying a
700  /// constant offset to the start of the pointer.
701  AAMDNodes shift(size_t Offset) const {
702  AAMDNodes Result;
703  Result.TBAA = TBAA ? shiftTBAA(TBAA, Offset) : nullptr;
704  Result.TBAAStruct =
706  Result.Scope = Scope;
707  Result.NoAlias = NoAlias;
708  return Result;
709  }
710 
711  /// Given two sets of AAMDNodes applying to potentially different locations,
712  /// determine the best AAMDNodes that apply to both.
713  AAMDNodes merge(const AAMDNodes &Other) const;
714 };
715 
716 // Specialize DenseMapInfo for AAMDNodes.
717 template<>
719  static inline AAMDNodes getEmptyKey() {
721  nullptr, nullptr, nullptr);
722  }
723 
724  static inline AAMDNodes getTombstoneKey() {
726  nullptr, nullptr, nullptr);
727  }
728 
729  static unsigned getHashValue(const AAMDNodes &Val) {
734  }
735 
736  static bool isEqual(const AAMDNodes &LHS, const AAMDNodes &RHS) {
737  return LHS == RHS;
738  }
739 };
740 
741 /// Tracking metadata reference owned by Metadata.
742 ///
743 /// Similar to \a TrackingMDRef, but it's expected to be owned by an instance
744 /// of \a Metadata, which has the option of registering itself for callbacks to
745 /// re-unique itself.
746 ///
747 /// In particular, this is used by \a MDNode.
748 class MDOperand {
749  Metadata *MD = nullptr;
750 
751 public:
752  MDOperand() = default;
753  MDOperand(MDOperand &&) = delete;
754  MDOperand(const MDOperand &) = delete;
755  MDOperand &operator=(MDOperand &&) = delete;
756  MDOperand &operator=(const MDOperand &) = delete;
757  ~MDOperand() { untrack(); }
758 
759  Metadata *get() const { return MD; }
760  operator Metadata *() const { return get(); }
761  Metadata *operator->() const { return get(); }
762  Metadata &operator*() const { return *get(); }
763 
764  void reset() {
765  untrack();
766  MD = nullptr;
767  }
768  void reset(Metadata *MD, Metadata *Owner) {
769  untrack();
770  this->MD = MD;
771  track(Owner);
772  }
773 
774 private:
775  void track(Metadata *Owner) {
776  if (MD) {
777  if (Owner)
778  MetadataTracking::track(this, *MD, *Owner);
779  else
781  }
782  }
783 
784  void untrack() {
785  assert(static_cast<void *>(this) == &MD && "Expected same address");
786  if (MD)
788  }
789 };
790 
791 template <> struct simplify_type<MDOperand> {
792  using SimpleType = Metadata *;
793 
794  static SimpleType getSimplifiedValue(MDOperand &MD) { return MD.get(); }
795 };
796 
797 template <> struct simplify_type<const MDOperand> {
798  using SimpleType = Metadata *;
799 
800  static SimpleType getSimplifiedValue(const MDOperand &MD) { return MD.get(); }
801 };
802 
803 /// Pointer to the context, with optional RAUW support.
804 ///
805 /// Either a raw (non-null) pointer to the \a LLVMContext, or an owned pointer
806 /// to \a ReplaceableMetadataImpl (which has a reference to \a LLVMContext).
809 
810 public:
813  std::unique_ptr<ReplaceableMetadataImpl> ReplaceableUses)
814  : Ptr(ReplaceableUses.release()) {
815  assert(getReplaceableUses() && "Expected non-null replaceable uses");
816  }
817  ContextAndReplaceableUses() = delete;
822  operator=(const ContextAndReplaceableUses &) = delete;
824 
825  operator LLVMContext &() { return getContext(); }
826 
827  /// Whether this contains RAUW support.
828  bool hasReplaceableUses() const {
829  return Ptr.is<ReplaceableMetadataImpl *>();
830  }
831 
833  if (hasReplaceableUses())
834  return getReplaceableUses()->getContext();
835  return *Ptr.get<LLVMContext *>();
836  }
837 
839  if (hasReplaceableUses())
840  return Ptr.get<ReplaceableMetadataImpl *>();
841  return nullptr;
842  }
843 
844  /// Ensure that this has RAUW support, and then return it.
846  if (!hasReplaceableUses())
847  makeReplaceable(std::make_unique<ReplaceableMetadataImpl>(getContext()));
848  return getReplaceableUses();
849  }
850 
851  /// Assign RAUW support to this.
852  ///
853  /// Make this replaceable, taking ownership of \c ReplaceableUses (which must
854  /// not be null).
855  void
856  makeReplaceable(std::unique_ptr<ReplaceableMetadataImpl> ReplaceableUses) {
857  assert(ReplaceableUses && "Expected non-null replaceable uses");
858  assert(&ReplaceableUses->getContext() == &getContext() &&
859  "Expected same context");
860  delete getReplaceableUses();
861  Ptr = ReplaceableUses.release();
862  }
863 
864  /// Drop RAUW support.
865  ///
866  /// Cede ownership of RAUW support, returning it.
867  std::unique_ptr<ReplaceableMetadataImpl> takeReplaceableUses() {
868  assert(hasReplaceableUses() && "Expected to own replaceable uses");
869  std::unique_ptr<ReplaceableMetadataImpl> ReplaceableUses(
871  Ptr = &ReplaceableUses->getContext();
872  return ReplaceableUses;
873  }
874 };
875 
877  inline void operator()(MDNode *Node) const;
878 };
879 
880 #define HANDLE_MDNODE_LEAF(CLASS) \
881  using Temp##CLASS = std::unique_ptr<CLASS, TempMDNodeDeleter>;
882 #define HANDLE_MDNODE_BRANCH(CLASS) HANDLE_MDNODE_LEAF(CLASS)
883 #include "llvm/IR/Metadata.def"
884 
885 /// Metadata node.
886 ///
887 /// Metadata nodes can be uniqued, like constants, or distinct. Temporary
888 /// metadata nodes (with full support for RAUW) can be used to delay uniquing
889 /// until forward references are known. The basic metadata node is an \a
890 /// MDTuple.
891 ///
892 /// There is limited support for RAUW at construction time. At construction
893 /// time, if any operand is a temporary node (or an unresolved uniqued node,
894 /// which indicates a transitive temporary operand), the node itself will be
895 /// unresolved. As soon as all operands become resolved, it will drop RAUW
896 /// support permanently.
897 ///
898 /// If an unresolved node is part of a cycle, \a resolveCycles() needs
899 /// to be called on some member of the cycle once all temporary nodes have been
900 /// replaced.
901 class MDNode : public Metadata {
903  friend class LLVMContextImpl;
904  friend class DIArgList;
905 
906  unsigned NumOperands;
907  unsigned NumUnresolved;
908 
910 
911 protected:
914  ~MDNode() = default;
915 
916  void *operator new(size_t Size, unsigned NumOps);
917  void operator delete(void *Mem);
918 
919  /// Required by std, but never called.
920  void operator delete(void *, unsigned) {
921  llvm_unreachable("Constructor throws?");
922  }
923 
924  /// Required by std, but never called.
925  void operator delete(void *, unsigned, bool) {
926  llvm_unreachable("Constructor throws?");
927  }
928 
929  void dropAllReferences();
930 
931  MDOperand *mutable_begin() { return mutable_end() - NumOperands; }
932  MDOperand *mutable_end() { return reinterpret_cast<MDOperand *>(this); }
933 
935 
938  }
939 
940 public:
941  MDNode(const MDNode &) = delete;
942  void operator=(const MDNode &) = delete;
943  void *operator new(size_t) = delete;
944 
945  static inline MDTuple *get(LLVMContext &Context, ArrayRef<Metadata *> MDs);
946  static inline MDTuple *getIfExists(LLVMContext &Context,
948  static inline MDTuple *getDistinct(LLVMContext &Context,
950  static inline TempMDTuple getTemporary(LLVMContext &Context,
952 
953  /// Create a (temporary) clone of this.
954  TempMDNode clone() const;
955 
956  /// Deallocate a node created by getTemporary.
957  ///
958  /// Calls \c replaceAllUsesWith(nullptr) before deleting, so any remaining
959  /// references will be reset.
960  static void deleteTemporary(MDNode *N);
961 
962  LLVMContext &getContext() const { return Context.getContext(); }
963 
964  /// Replace a specific operand.
965  void replaceOperandWith(unsigned I, Metadata *New);
966 
967  /// Check if node is fully resolved.
968  ///
969  /// If \a isTemporary(), this always returns \c false; if \a isDistinct(),
970  /// this always returns \c true.
971  ///
972  /// If \a isUniqued(), returns \c true if this has already dropped RAUW
973  /// support (because all operands are resolved).
974  ///
975  /// As forward declarations are resolved, their containers should get
976  /// resolved automatically. However, if this (or one of its operands) is
977  /// involved in a cycle, \a resolveCycles() needs to be called explicitly.
978  bool isResolved() const { return !isTemporary() && !NumUnresolved; }
979 
980  bool isUniqued() const { return Storage == Uniqued; }
981  bool isDistinct() const { return Storage == Distinct; }
982  bool isTemporary() const { return Storage == Temporary; }
983 
984  /// RAUW a temporary.
985  ///
986  /// \pre \a isTemporary() must be \c true.
988  assert(isTemporary() && "Expected temporary node");
989  if (Context.hasReplaceableUses())
990  Context.getReplaceableUses()->replaceAllUsesWith(MD);
991  }
992 
993  /// Resolve cycles.
994  ///
995  /// Once all forward declarations have been resolved, force cycles to be
996  /// resolved.
997  ///
998  /// \pre No operands (or operands' operands, etc.) have \a isTemporary().
999  void resolveCycles();
1000 
1001  /// Resolve a unique, unresolved node.
1002  void resolve();
1003 
1004  /// Replace a temporary node with a permanent one.
1005  ///
1006  /// Try to create a uniqued version of \c N -- in place, if possible -- and
1007  /// return it. If \c N cannot be uniqued, return a distinct node instead.
1008  template <class T>
1009  static std::enable_if_t<std::is_base_of<MDNode, T>::value, T *>
1010  replaceWithPermanent(std::unique_ptr<T, TempMDNodeDeleter> N) {
1011  return cast<T>(N.release()->replaceWithPermanentImpl());
1012  }
1013 
1014  /// Replace a temporary node with a uniqued one.
1015  ///
1016  /// Create a uniqued version of \c N -- in place, if possible -- and return
1017  /// it. Takes ownership of the temporary node.
1018  ///
1019  /// \pre N does not self-reference.
1020  template <class T>
1021  static std::enable_if_t<std::is_base_of<MDNode, T>::value, T *>
1022  replaceWithUniqued(std::unique_ptr<T, TempMDNodeDeleter> N) {
1023  return cast<T>(N.release()->replaceWithUniquedImpl());
1024  }
1025 
1026  /// Replace a temporary node with a distinct one.
1027  ///
1028  /// Create a distinct version of \c N -- in place, if possible -- and return
1029  /// it. Takes ownership of the temporary node.
1030  template <class T>
1031  static std::enable_if_t<std::is_base_of<MDNode, T>::value, T *>
1032  replaceWithDistinct(std::unique_ptr<T, TempMDNodeDeleter> N) {
1033  return cast<T>(N.release()->replaceWithDistinctImpl());
1034  }
1035 
1036 private:
1037  MDNode *replaceWithPermanentImpl();
1038  MDNode *replaceWithUniquedImpl();
1039  MDNode *replaceWithDistinctImpl();
1040 
1041 protected:
1042  /// Set an operand.
1043  ///
1044  /// Sets the operand directly, without worrying about uniquing.
1045  void setOperand(unsigned I, Metadata *New);
1046 
1047  void storeDistinctInContext();
1048  template <class T, class StoreT>
1049  static T *storeImpl(T *N, StorageType Storage, StoreT &Store);
1050  template <class T> static T *storeImpl(T *N, StorageType Storage);
1051 
1052 private:
1053  void handleChangedOperand(void *Ref, Metadata *New);
1054 
1055  /// Drop RAUW support, if any.
1056  void dropReplaceableUses();
1057 
1058  void resolveAfterOperandChange(Metadata *Old, Metadata *New);
1059  void decrementUnresolvedOperandCount();
1060  void countUnresolvedOperands();
1061 
1062  /// Mutate this to be "uniqued".
1063  ///
1064  /// Mutate this so that \a isUniqued().
1065  /// \pre \a isTemporary().
1066  /// \pre already added to uniquing set.
1067  void makeUniqued();
1068 
1069  /// Mutate this to be "distinct".
1070  ///
1071  /// Mutate this so that \a isDistinct().
1072  /// \pre \a isTemporary().
1073  void makeDistinct();
1074 
1075  void deleteAsSubclass();
1076  MDNode *uniquify();
1077  void eraseFromStore();
1078 
1079  template <class NodeTy> struct HasCachedHash;
1080  template <class NodeTy>
1081  static void dispatchRecalculateHash(NodeTy *N, std::true_type) {
1082  N->recalculateHash();
1083  }
1084  template <class NodeTy>
1085  static void dispatchRecalculateHash(NodeTy *, std::false_type) {}
1086  template <class NodeTy>
1087  static void dispatchResetHash(NodeTy *N, std::true_type) {
1088  N->setHash(0);
1089  }
1090  template <class NodeTy>
1091  static void dispatchResetHash(NodeTy *, std::false_type) {}
1092 
1093 public:
1094  using op_iterator = const MDOperand *;
1096 
1098  return const_cast<MDNode *>(this)->mutable_begin();
1099  }
1100 
1102  return const_cast<MDNode *>(this)->mutable_end();
1103  }
1104 
1105  op_range operands() const { return op_range(op_begin(), op_end()); }
1106 
1107  const MDOperand &getOperand(unsigned I) const {
1108  assert(I < NumOperands && "Out of range");
1109  return op_begin()[I];
1110  }
1111 
1112  /// Return number of MDNode operands.
1113  unsigned getNumOperands() const { return NumOperands; }
1114 
1115  /// Methods for support type inquiry through isa, cast, and dyn_cast:
1116  static bool classof(const Metadata *MD) {
1117  switch (MD->getMetadataID()) {
1118  default:
1119  return false;
1120 #define HANDLE_MDNODE_LEAF(CLASS) \
1121  case CLASS##Kind: \
1122  return true;
1123 #include "llvm/IR/Metadata.def"
1124  }
1125  }
1126 
1127  /// Check whether MDNode is a vtable access.
1128  bool isTBAAVtableAccess() const;
1129 
1130  /// Methods for metadata merging.
1131  static MDNode *concatenate(MDNode *A, MDNode *B);
1132  static MDNode *intersect(MDNode *A, MDNode *B);
1133  static MDNode *getMostGenericTBAA(MDNode *A, MDNode *B);
1135  static MDNode *getMostGenericRange(MDNode *A, MDNode *B);
1138 };
1139 
1140 /// Tuple of metadata.
1141 ///
1142 /// This is the simple \a MDNode arbitrary tuple. Nodes are uniqued by
1143 /// default based on their operands.
1144 class MDTuple : public MDNode {
1145  friend class LLVMContextImpl;
1146  friend class MDNode;
1147 
1148  MDTuple(LLVMContext &C, StorageType Storage, unsigned Hash,
1149  ArrayRef<Metadata *> Vals)
1150  : MDNode(C, MDTupleKind, Storage, Vals) {
1151  setHash(Hash);
1152  }
1153 
1154  ~MDTuple() { dropAllReferences(); }
1155 
1156  void setHash(unsigned Hash) { SubclassData32 = Hash; }
1157  void recalculateHash();
1158 
1159  static MDTuple *getImpl(LLVMContext &Context, ArrayRef<Metadata *> MDs,
1160  StorageType Storage, bool ShouldCreate = true);
1161 
1162  TempMDTuple cloneImpl() const {
1163  return getTemporary(getContext(), SmallVector<Metadata *, 4>(operands()));
1164  }
1165 
1166 public:
1167  /// Get the hash, if any.
1168  unsigned getHash() const { return SubclassData32; }
1169 
1171  return getImpl(Context, MDs, Uniqued);
1172  }
1173 
1175  return getImpl(Context, MDs, Uniqued, /* ShouldCreate */ false);
1176  }
1177 
1178  /// Return a distinct node.
1179  ///
1180  /// Return a distinct node -- i.e., a node that is not uniqued.
1182  return getImpl(Context, MDs, Distinct);
1183  }
1184 
1185  /// Return a temporary node.
1186  ///
1187  /// For use in constructing cyclic MDNode structures. A temporary MDNode is
1188  /// not uniqued, may be RAUW'd, and must be manually deleted with
1189  /// deleteTemporary.
1190  static TempMDTuple getTemporary(LLVMContext &Context,
1191  ArrayRef<Metadata *> MDs) {
1192  return TempMDTuple(getImpl(Context, MDs, Temporary));
1193  }
1194 
1195  /// Return a (temporary) clone of this.
1196  TempMDTuple clone() const { return cloneImpl(); }
1197 
1198  static bool classof(const Metadata *MD) {
1199  return MD->getMetadataID() == MDTupleKind;
1200  }
1201 };
1202 
1204  return MDTuple::get(Context, MDs);
1205 }
1206 
1208  return MDTuple::getIfExists(Context, MDs);
1209 }
1210 
1212  return MDTuple::getDistinct(Context, MDs);
1213 }
1214 
1216  ArrayRef<Metadata *> MDs) {
1217  return MDTuple::getTemporary(Context, MDs);
1218 }
1219 
1222 }
1223 
1224 /// This is a simple wrapper around an MDNode which provides a higher-level
1225 /// interface by hiding the details of how alias analysis information is encoded
1226 /// in its operands.
1228  const MDNode *Node = nullptr;
1229 
1230 public:
1231  AliasScopeNode() = default;
1232  explicit AliasScopeNode(const MDNode *N) : Node(N) {}
1233 
1234  /// Get the MDNode for this AliasScopeNode.
1235  const MDNode *getNode() const { return Node; }
1236 
1237  /// Get the MDNode for this AliasScopeNode's domain.
1238  const MDNode *getDomain() const {
1239  if (Node->getNumOperands() < 2)
1240  return nullptr;
1241  return dyn_cast_or_null<MDNode>(Node->getOperand(1));
1242  }
1243  StringRef getName() const {
1244  if (Node->getNumOperands() > 2)
1245  if (MDString *N = dyn_cast_or_null<MDString>(Node->getOperand(2)))
1246  return N->getString();
1247  return StringRef();
1248  }
1249 };
1250 
1251 /// Typed iterator through MDNode operands.
1252 ///
1253 /// An iterator that transforms an \a MDNode::iterator into an iterator over a
1254 /// particular Metadata subclass.
1255 template <class T> class TypedMDOperandIterator {
1256  MDNode::op_iterator I = nullptr;
1257 
1258 public:
1259  using iterator_category = std::input_iterator_tag;
1260  using value_type = T *;
1261  using difference_type = std::ptrdiff_t;
1262  using pointer = void;
1263  using reference = T *;
1264 
1265  TypedMDOperandIterator() = default;
1267 
1268  T *operator*() const { return cast_or_null<T>(*I); }
1269 
1271  ++I;
1272  return *this;
1273  }
1274 
1276  TypedMDOperandIterator Temp(*this);
1277  ++I;
1278  return Temp;
1279  }
1280 
1281  bool operator==(const TypedMDOperandIterator &X) const { return I == X.I; }
1282  bool operator!=(const TypedMDOperandIterator &X) const { return I != X.I; }
1283 };
1284 
1285 /// Typed, array-like tuple of metadata.
1286 ///
1287 /// This is a wrapper for \a MDTuple that makes it act like an array holding a
1288 /// particular type of metadata.
1289 template <class T> class MDTupleTypedArrayWrapper {
1290  const MDTuple *N = nullptr;
1291 
1292 public:
1293  MDTupleTypedArrayWrapper() = default;
1295 
1296  template <class U>
1298  const MDTupleTypedArrayWrapper<U> &Other,
1299  std::enable_if_t<std::is_convertible<U *, T *>::value> * = nullptr)
1300  : N(Other.get()) {}
1301 
1302  template <class U>
1304  const MDTupleTypedArrayWrapper<U> &Other,
1305  std::enable_if_t<!std::is_convertible<U *, T *>::value> * = nullptr)
1306  : N(Other.get()) {}
1307 
1308  explicit operator bool() const { return get(); }
1309  explicit operator MDTuple *() const { return get(); }
1310 
1311  MDTuple *get() const { return const_cast<MDTuple *>(N); }
1312  MDTuple *operator->() const { return get(); }
1313  MDTuple &operator*() const { return *get(); }
1314 
1315  // FIXME: Fix callers and remove condition on N.
1316  unsigned size() const { return N ? N->getNumOperands() : 0u; }
1317  bool empty() const { return N ? N->getNumOperands() == 0 : true; }
1318  T *operator[](unsigned I) const { return cast_or_null<T>(N->getOperand(I)); }
1319 
1320  // FIXME: Fix callers and remove condition on N.
1322 
1323  iterator begin() const { return N ? iterator(N->op_begin()) : iterator(); }
1324  iterator end() const { return N ? iterator(N->op_end()) : iterator(); }
1325 };
1326 
1327 #define HANDLE_METADATA(CLASS) \
1328  using CLASS##Array = MDTupleTypedArrayWrapper<CLASS>;
1329 #include "llvm/IR/Metadata.def"
1330 
1331 /// Placeholder metadata for operands of distinct MDNodes.
1332 ///
1333 /// This is a lightweight placeholder for an operand of a distinct node. It's
1334 /// purpose is to help track forward references when creating a distinct node.
1335 /// This allows distinct nodes involved in a cycle to be constructed before
1336 /// their operands without requiring a heavyweight temporary node with
1337 /// full-blown RAUW support.
1338 ///
1339 /// Each placeholder supports only a single MDNode user. Clients should pass
1340 /// an ID, retrieved via \a getID(), to indicate the "real" operand that this
1341 /// should be replaced with.
1342 ///
1343 /// While it would be possible to implement move operators, they would be
1344 /// fairly expensive. Leave them unimplemented to discourage their use
1345 /// (clients can use std::deque, std::list, BumpPtrAllocator, etc.).
1347  friend class MetadataTracking;
1348 
1349  Metadata **Use = nullptr;
1350 
1351 public:
1353  : Metadata(DistinctMDOperandPlaceholderKind, Distinct) {
1354  SubclassData32 = ID;
1355  }
1356 
1357  DistinctMDOperandPlaceholder() = delete;
1360 
1362  if (Use)
1363  *Use = nullptr;
1364  }
1365 
1366  unsigned getID() const { return SubclassData32; }
1367 
1368  /// Replace the use of this with MD.
1370  if (!Use)
1371  return;
1372  *Use = MD;
1373 
1374  if (*Use)
1376 
1377  Metadata *T = cast<Metadata>(this);
1379  assert(!Use && "Use is still being tracked despite being untracked!");
1380  }
1381 };
1382 
1383 //===----------------------------------------------------------------------===//
1384 /// A tuple of MDNodes.
1385 ///
1386 /// Despite its name, a NamedMDNode isn't itself an MDNode.
1387 ///
1388 /// NamedMDNodes are named module-level entities that contain lists of MDNodes.
1389 ///
1390 /// It is illegal for a NamedMDNode to appear as an operand of an MDNode.
1391 class NamedMDNode : public ilist_node<NamedMDNode> {
1392  friend class LLVMContextImpl;
1393  friend class Module;
1394 
1395  std::string Name;
1396  Module *Parent = nullptr;
1397  void *Operands; // SmallVector<TrackingMDRef, 4>
1398 
1399  void setParent(Module *M) { Parent = M; }
1400 
1401  explicit NamedMDNode(const Twine &N);
1402 
1403  template <class T1, class T2> class op_iterator_impl {
1404  friend class NamedMDNode;
1405 
1406  const NamedMDNode *Node = nullptr;
1407  unsigned Idx = 0;
1408 
1409  op_iterator_impl(const NamedMDNode *N, unsigned i) : Node(N), Idx(i) {}
1410 
1411  public:
1412  using iterator_category = std::bidirectional_iterator_tag;
1413  using value_type = T2;
1414  using difference_type = std::ptrdiff_t;
1415  using pointer = value_type *;
1416  using reference = value_type &;
1417 
1418  op_iterator_impl() = default;
1419 
1420  bool operator==(const op_iterator_impl &o) const { return Idx == o.Idx; }
1421  bool operator!=(const op_iterator_impl &o) const { return Idx != o.Idx; }
1422 
1423  op_iterator_impl &operator++() {
1424  ++Idx;
1425  return *this;
1426  }
1427 
1428  op_iterator_impl operator++(int) {
1429  op_iterator_impl tmp(*this);
1430  operator++();
1431  return tmp;
1432  }
1433 
1434  op_iterator_impl &operator--() {
1435  --Idx;
1436  return *this;
1437  }
1438 
1439  op_iterator_impl operator--(int) {
1440  op_iterator_impl tmp(*this);
1441  operator--();
1442  return tmp;
1443  }
1444 
1445  T1 operator*() const { return Node->getOperand(Idx); }
1446  };
1447 
1448 public:
1449  NamedMDNode(const NamedMDNode &) = delete;
1450  ~NamedMDNode();
1451 
1452  /// Drop all references and remove the node from parent module.
1453  void eraseFromParent();
1454 
1455  /// Remove all uses and clear node vector.
1457  /// Drop all references to this node's operands.
1458  void clearOperands();
1459 
1460  /// Get the module that holds this named metadata collection.
1461  inline Module *getParent() { return Parent; }
1462  inline const Module *getParent() const { return Parent; }
1463 
1464  MDNode *getOperand(unsigned i) const;
1465  unsigned getNumOperands() const;
1466  void addOperand(MDNode *M);
1467  void setOperand(unsigned I, MDNode *New);
1468  StringRef getName() const;
1469  void print(raw_ostream &ROS, bool IsForDebug = false) const;
1470  void print(raw_ostream &ROS, ModuleSlotTracker &MST,
1471  bool IsForDebug = false) const;
1472  void dump() const;
1473 
1474  // ---------------------------------------------------------------------------
1475  // Operand Iterator interface...
1476  //
1477  using op_iterator = op_iterator_impl<MDNode *, MDNode>;
1478 
1479  op_iterator op_begin() { return op_iterator(this, 0); }
1481 
1482  using const_op_iterator = op_iterator_impl<const MDNode *, MDNode>;
1483 
1484  const_op_iterator op_begin() const { return const_op_iterator(this, 0); }
1486 
1488  return make_range(op_begin(), op_end());
1489  }
1491  return make_range(op_begin(), op_end());
1492  }
1493 };
1494 
1495 // Create wrappers for C Binding types (see CBindingWrapping.h).
1497 
1498 } // end namespace llvm
1499 
1500 #endif // LLVM_IR_METADATA_H
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::ValueAsMetadata::getConstantIfExists
static ConstantAsMetadata * getConstantIfExists(Value *C)
Definition: Metadata.h:376
i
i
Definition: README.txt:29
llvm::ReplaceableMetadataImpl::getAllArgListUsers
SmallVector< Metadata * > getAllArgListUsers()
Returns the list of all DIArgList users of this.
Definition: Metadata.cpp:198
llvm::ContextAndReplaceableUses::ContextAndReplaceableUses
ContextAndReplaceableUses(LLVMContext &Context)
Definition: Metadata.h:811
llvm::MDString::end
iterator end() const
Pointer to one byte past the end of the string.
Definition: Metadata.h:638
llvm::ContextAndReplaceableUses::getReplaceableUses
ReplaceableMetadataImpl * getReplaceableUses() const
Definition: Metadata.h:838
llvm::DIArgList
List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.
Definition: DebugInfoMetadata.h:3604
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::MDNode::storeImpl
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
Definition: MetadataImpl.h:42
llvm::MDTupleTypedArrayWrapper::operator*
MDTuple & operator*() const
Definition: Metadata.h:1313
llvm::ReplaceableMetadataImpl::ReplaceableMetadataImpl
ReplaceableMetadataImpl(LLVMContext &Context)
Definition: Metadata.h:293
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::Metadata::MetadataKind
MetadataKind
Definition: Metadata.h:80
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::MetadataTracking::untrack
static void untrack(Metadata *&MD)
Stop tracking a reference to metadata.
Definition: Metadata.h:248
llvm::NamedMDNode
A tuple of MDNodes.
Definition: Metadata.h:1391
llvm::StringMapEntry
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMapEntry.h:98
llvm::MetadataTracking::isReplaceable
static bool isReplaceable(const Metadata &MD)
Check whether metadata is replaceable.
Definition: Metadata.cpp:194
llvm::Metadata::Distinct
@ Distinct
Definition: Metadata.h:70
llvm::mdconst::extract
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
Definition: Metadata.h:557
llvm::NamedMDNode::getNumOperands
unsigned getNumOperands() const
Definition: Metadata.cpp:1120
llvm::Metadata::Temporary
@ Temporary
Definition: Metadata.h:70
llvm::ValueAsMetadata::ValueAsMetadata
ValueAsMetadata(unsigned ID, Value *V)
Definition: Metadata.h:356
llvm::MDString::bytes_begin
const unsigned char * bytes_begin() const
Definition: Metadata.h:640
llvm::ValueAsMetadata::getType
Type * getType() const
Definition: Metadata.h:385
llvm::MDTupleTypedArrayWrapper::empty
bool empty() const
Definition: Metadata.h:1317
llvm::NamedMDNode::op_begin
const_op_iterator op_begin() const
Definition: Metadata.h:1484
StringRef.h
pointer
Replace within non kernel function use of LDS with pointer
Definition: AMDGPUReplaceLDSUseWithPointer.cpp:443
llvm::MetadataTracking::track
static bool track(Metadata *&MD)
Track the reference to metadata.
Definition: Metadata.h:223
llvm::MDNode::setOperand
void setOperand(unsigned I, Metadata *New)
Set an operand.
Definition: Metadata.cpp:889
llvm::NamedMDNode::operands
iterator_range< const_op_iterator > operands() const
Definition: Metadata.h:1490
llvm::NamedMDNode::op_end
op_iterator op_end()
Definition: Metadata.h:1480
llvm::TypedMDOperandIterator::operator++
TypedMDOperandIterator operator++(int)
Definition: Metadata.h:1275
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::MDString::classof
static bool classof(const Metadata *MD)
Methods for support type inquiry through isa, cast, and dyn_cast.
Definition: Metadata.h:644
getImpl
static LazyValueInfoImpl & getImpl(void *&PImpl, AssumptionCache *AC, const Module *M)
This lazily constructs the LazyValueInfoImpl.
Definition: LazyValueInfo.cpp:1507
llvm::mdconst::detail::HasDereference::SFINAE
Definition: Metadata.h:514
ErrorHandling.h
llvm::NamedMDNode::~NamedMDNode
~NamedMDNode()
Definition: Metadata.cpp:1115
llvm::Metadata::SubclassData32
unsigned SubclassData32
Definition: Metadata.h:77
llvm::TypedMDOperandIterator::TypedMDOperandIterator
TypedMDOperandIterator(MDNode::op_iterator I)
Definition: Metadata.h:1266
llvm::MDOperand::reset
void reset(Metadata *MD, Metadata *Owner)
Definition: Metadata.h:768
llvm::MDNode::operator=
void operator=(const MDNode &)=delete
llvm::ValueAsMetadata::~ValueAsMetadata
~ValueAsMetadata()=default
llvm::AliasScopeNode::AliasScopeNode
AliasScopeNode()=default
llvm::SmallDenseMap
Definition: DenseMap.h:880
llvm::NamedMDNode::getParent
const Module * getParent() const
Definition: Metadata.h:1462
llvm::ValueAsMetadata::handleDeletion
static void handleDeletion(Value *V)
Definition: Metadata.cpp:392
llvm::ReplaceableMetadataImpl::~ReplaceableMetadataImpl
~ReplaceableMetadataImpl()
Definition: Metadata.h:295
llvm::AAMDNodes
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition: Metadata.h:651
llvm::NamedMDNode::setOperand
void setOperand(unsigned I, MDNode *New)
Definition: Metadata.cpp:1132
llvm::MDTupleTypedArrayWrapper::MDTupleTypedArrayWrapper
MDTupleTypedArrayWrapper(const MDTupleTypedArrayWrapper< U > &Other, std::enable_if_t< std::is_convertible< U *, T * >::value > *=nullptr)
Definition: Metadata.h:1297
llvm::Metadata::SubclassData16
unsigned short SubclassData16
Definition: Metadata.h:76
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
DenseMap.h
llvm::AtomicOrderingCABI::release
@ release
llvm::AAMDNodes::TBAAStruct
MDNode * TBAAStruct
The tag for type-based alias analysis (tbaa struct).
Definition: Metadata.h:671
llvm::Metadata::printAsOperand
void printAsOperand(raw_ostream &OS, const Module *M=nullptr) const
Print as operand.
Definition: AsmWriter.cpp:4717
T1
#define T1
Definition: Mips16ISelLowering.cpp:340
llvm::operator!=
bool operator!=(uint64_t V1, const APInt &V2)
Definition: APInt.h:1976
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::ConstantAsMetadata::get
static ConstantAsMetadata * get(Constant *C)
Definition: Metadata.h:419
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
CBindingWrapping.h
llvm::MetadataTracking::retrack
static bool retrack(Metadata *&MD, Metadata *&New)
Move tracking from one reference to another.
Definition: Metadata.h:259
llvm::NamedMDNode::dropAllReferences
void dropAllReferences()
Remove all uses and clear node vector.
Definition: Metadata.h:1456
llvm::NamedMDNode::op_end
const_op_iterator op_end() const
Definition: Metadata.h:1485
llvm::Metadata::SubclassData1
unsigned char SubclassData1
Definition: Metadata.h:75
llvm::DenseMapInfo< AAMDNodes >::isEqual
static bool isEqual(const AAMDNodes &LHS, const AAMDNodes &RHS)
Definition: Metadata.h:736
llvm::ValueAsMetadata::get
static ValueAsMetadata * get(Value *V)
Definition: Metadata.cpp:368
llvm::LocalAsMetadata
Definition: Metadata.h:436
STLExtras.h
llvm::MDNode::MDNode
MDNode(LLVMContext &Context, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2=None)
Definition: Metadata.cpp:525
llvm::MetadataAsValue
Metadata wrapper in the Value hierarchy.
Definition: Metadata.h:176
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::mdconst::detail::HasDereference::No
char[2] No
Definition: Metadata.h:513
llvm::AAMDNodes::Scope
MDNode * Scope
The tag for alias scope specification (used with noalias).
Definition: Metadata.h:674
llvm::StringMapEntryStorage
StringMapEntryStorage - Holds the value in a StringMapEntry.
Definition: StringMapEntry.h:67
llvm::MDNode::replaceWithPermanent
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithPermanent(std::unique_ptr< T, TempMDNodeDeleter > N)
Replace a temporary node with a permanent one.
Definition: Metadata.h:1010
llvm::ModuleSlotTracker
Manage lifetime of a slot tracker for printing IR.
Definition: ModuleSlotTracker.h:44
llvm::PointerUnion::get
T get() const
Returns the value of the specified pointer type.
Definition: PointerUnion.h:157
llvm::NamedMDNode::dump
void dump() const
Definition: AsmWriter.cpp:4778
size_t
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1203
llvm::MDNode::operands
op_range operands() const
Definition: Metadata.h:1105
llvm::MDOperand::~MDOperand
~MDOperand()
Definition: Metadata.h:757
llvm::MDNode::op_range
iterator_range< op_iterator > op_range
Definition: Metadata.h:1095
llvm::mdconst::dyn_extract_or_null
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract_or_null(Y &&MD)
Extract a Value from Metadata, if any, allowing null.
Definition: Metadata.h:598
llvm::PointerUnion::is
bool is() const
Test if the Union currently holds the type matching T.
Definition: PointerUnion.h:147
llvm::MDNode::storeDistinctInContext
void storeDistinctInContext()
Definition: Metadata.cpp:855
llvm::ConstantAsMetadata::getValue
Constant * getValue() const
Definition: Metadata.h:427
llvm::MDNode::getNumOperands
unsigned getNumOperands() const
Return number of MDNode operands.
Definition: Metadata.h:1113
llvm::MDTuple::getDistinct
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a distinct node.
Definition: Metadata.h:1181
llvm::MDOperand::reset
void reset()
Definition: Metadata.h:764
llvm::AAMDNodes::shiftTBAA
static MDNode * shiftTBAA(MDNode *M, size_t off)
Definition: TypeBasedAliasAnalysis.cpp:742
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::MetadataTracking
API for tracking metadata references through RAUW and deletion.
Definition: Metadata.h:212
llvm::NamedMDNode::addOperand
void addOperand(MDNode *M)
Definition: Metadata.cpp:1130
DEFINE_ISA_CONVERSION_FUNCTIONS
#define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref)
Definition: CBindingWrapping.h:28
llvm::DenseMapInfo
Definition: APInt.h:34
llvm::simplify_type< MDOperand >::getSimplifiedValue
static SimpleType getSimplifiedValue(MDOperand &MD)
Definition: Metadata.h:794
llvm::ConstantAsMetadata::classof
static bool classof(const Metadata *MD)
Definition: Metadata.h:431
llvm::Metadata::Metadata
Metadata(unsigned ID, StorageType Storage)
Definition: Metadata.h:86
llvm::ModRefInfo::Ref
@ Ref
The access may reference the value stored in memory.
llvm::ValueAsMetadata::replaceAllUsesWith
void replaceAllUsesWith(Metadata *MD)
Handle collisions after Value::replaceAllUsesWith().
Definition: Metadata.h:401
llvm::AliasScopeNode::getNode
const MDNode * getNode() const
Get the MDNode for this AliasScopeNode.
Definition: Metadata.h:1235
llvm::AAMDNodes::operator!=
bool operator!=(const AAMDNodes &A) const
Definition: Metadata.h:661
llvm::mdconst::detail::HasDereference::hasDereference
static Yes & hasDereference(SFINAE< sizeof(static_cast< V >(*make< U >()))> *=0)
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::LLVMContextImpl
Definition: LLVMContextImpl.h:1341
llvm::NamedMDNode::getName
StringRef getName() const
Definition: Metadata.cpp:1141
llvm::AAMDNodes::AAMDNodes
AAMDNodes(MDNode *T, MDNode *TS, MDNode *S, MDNode *N)
Definition: Metadata.h:653
llvm::MDNode::mutable_operands
mutable_op_range mutable_operands()
Definition: Metadata.h:936
Y
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
llvm::MDTuple::classof
static bool classof(const Metadata *MD)
Definition: Metadata.h:1198
llvm::MDNode::mutable_op_range
iterator_range< MDOperand * > mutable_op_range
Definition: Metadata.h:934
llvm::MDTuple
Tuple of metadata.
Definition: Metadata.h:1144
llvm::StringRef::iterator
const char * iterator
Definition: StringRef.h:62
llvm::mdconst::extract_or_null
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract_or_null(Y &&MD)
Extract a Value from Metadata, allowing null.
Definition: Metadata.h:572
llvm::TypedMDOperandIterator
Typed iterator through MDNode operands.
Definition: Metadata.h:1255
llvm::mdconst::detail::HasDereference
Definition: Metadata.h:511
llvm::simplify_type
Definition: ilist_iterator.h:178
false
Definition: StackSlotColoring.cpp:142
llvm::Metadata::StorageType
StorageType
Active type of storage.
Definition: Metadata.h:70
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::Value::getValueID
unsigned getValueID() const
Return an ID for the concrete type of this object.
Definition: Value.h:526
llvm::MDOperand::operator->
Metadata * operator->() const
Definition: Metadata.h:761
llvm::Metadata::getMetadataID
unsigned getMetadataID() const
Definition: Metadata.h:102
llvm::MDNode::mutable_begin
MDOperand * mutable_begin()
Definition: Metadata.h:931
llvm::NamedMDNode::eraseFromParent
void eraseFromParent()
Drop all references and remove the node from parent module.
Definition: Metadata.cpp:1137
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::MDNode::getTemporary
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1215
llvm::MDTupleTypedArrayWrapper::end
iterator end() const
Definition: Metadata.h:1324
llvm::MDNode::classof
static bool classof(const Metadata *MD)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition: Metadata.h:1116
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::DistinctMDOperandPlaceholder::DistinctMDOperandPlaceholder
DistinctMDOperandPlaceholder(unsigned ID)
Definition: Metadata.h:1352
llvm::TypedMDOperandIterator::difference_type
std::ptrdiff_t difference_type
Definition: Metadata.h:1261
StringMap.h
llvm::MDNode::mutable_end
MDOperand * mutable_end()
Definition: Metadata.h:932
llvm::Metadata
Root of the metadata hierarchy.
Definition: Metadata.h:62
llvm::DEBUG_METADATA_VERSION
@ DEBUG_METADATA_VERSION
Definition: Metadata.h:52
LLVMNamedMDNodeRef
struct LLVMOpaqueNamedMDNode * LLVMNamedMDNodeRef
Represents an LLVM Named Metadata Node.
Definition: Types.h:96
llvm::ValueAsMetadata::getLocalIfExists
static LocalAsMetadata * getLocalIfExists(Value *Local)
Definition: Metadata.h:380
llvm::None
const NoneType None
Definition: None.h:23
llvm::MDString::iterator
StringRef::iterator iterator
Definition: Metadata.h:632
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
llvm::TypedMDOperandIterator::operator!=
bool operator!=(const TypedMDOperandIterator &X) const
Definition: Metadata.h:1282
llvm::MDTupleTypedArrayWrapper::size
unsigned size() const
Definition: Metadata.h:1316
Operands
mir Rename Register Operands
Definition: MIRNamerPass.cpp:78
llvm::LocalAsMetadata::getIfExists
static LocalAsMetadata * getIfExists(Value *Local)
Definition: Metadata.h:449
llvm::ContextAndReplaceableUses::getContext
LLVMContext & getContext() const
Definition: Metadata.h:832
llvm::MDNode::getOperand
const MDOperand & getOperand(unsigned I) const
Definition: Metadata.h:1107
llvm::TypedMDOperandIterator::TypedMDOperandIterator
TypedMDOperandIterator()=default
llvm::MDNode::resolveCycles
void resolveCycles()
Resolve cycles.
Definition: Metadata.cpp:642
llvm::AAMDNodes::AAMDNodes
AAMDNodes()=default
llvm::ContextAndReplaceableUses::ContextAndReplaceableUses
ContextAndReplaceableUses(std::unique_ptr< ReplaceableMetadataImpl > ReplaceableUses)
Definition: Metadata.h:812
llvm::ReplaceableMetadataImpl::resolveAllUses
void resolveAllUses(bool ResolveUsers=true)
Resolve all uses of this.
Definition: Metadata.cpp:300
llvm::LocalAsMetadata::get
static LocalAsMetadata * get(Value *Local)
Definition: Metadata.h:445
llvm::MDTupleTypedArrayWrapper::MDTupleTypedArrayWrapper
MDTupleTypedArrayWrapper()=default
llvm::MDString::bytes_end
const unsigned char * bytes_end() const
Definition: Metadata.h:641
llvm::MDString::begin
iterator begin() const
Pointer to the first byte of the string.
Definition: Metadata.h:635
llvm::MDNode::resolve
void resolve()
Resolve a unique, unresolved node.
Definition: Metadata.cpp:597
llvm::Constant
This is an important base class in LLVM.
Definition: Constant.h:41
llvm::MDNode::intersect
static MDNode * intersect(MDNode *A, MDNode *B)
Definition: Metadata.cpp:928
llvm::MDTupleTypedArrayWrapper::operator->
MDTuple * operator->() const
Definition: Metadata.h:1312
llvm::TypedMDOperandIterator::operator++
TypedMDOperandIterator & operator++()
Definition: Metadata.h:1270
llvm::mdconst::detail::make
T & make()
llvm::AAMDNodes::shift
AAMDNodes shift(size_t Offset) const
Create a new AAMDNode that describes this AAMDNode after applying a constant offset to the start of t...
Definition: Metadata.h:701
uint64_t
llvm::StringRef::end
iterator end() const
Definition: StringRef.h:130
const
aarch64 promote const
Definition: AArch64PromoteConstant.cpp:232
llvm::MetadataTracking::track
static bool track(void *Ref, Metadata &MD, Metadata &Owner)
Track the reference to metadata for Metadata.
Definition: Metadata.h:232
llvm::MDTupleTypedArrayWrapper::begin
iterator begin() const
Definition: Metadata.h:1323
llvm::MDTupleTypedArrayWrapper::MDTupleTypedArrayWrapper
MDTupleTypedArrayWrapper(const MDTuple *N)
Definition: Metadata.h:1294
llvm::MDNode::replaceWithUniqued
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithUniqued(std::unique_ptr< T, TempMDNodeDeleter > N)
Replace a temporary node with a uniqued one.
Definition: Metadata.h:1022
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::MDNode::getIfExists
static MDTuple * getIfExists(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1207
llvm::DistinctMDOperandPlaceholder
Placeholder metadata for operands of distinct MDNodes.
Definition: Metadata.h:1346
llvm::MDTupleTypedArrayWrapper::MDTupleTypedArrayWrapper
MDTupleTypedArrayWrapper(const MDTupleTypedArrayWrapper< U > &Other, std::enable_if_t<!std::is_convertible< U *, T * >::value > *=nullptr)
Definition: Metadata.h:1303
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::MetadataAsValue::~MetadataAsValue
~MetadataAsValue()
Definition: Metadata.cpp:68
llvm::ContextAndReplaceableUses::getOrCreateReplaceableUses
ReplaceableMetadataImpl * getOrCreateReplaceableUses()
Ensure that this has RAUW support, and then return it.
Definition: Metadata.h:845
ArrayRef.h
llvm::NamedMDNode::op_iterator
op_iterator_impl< MDNode *, MDNode > op_iterator
Definition: Metadata.h:1477
llvm::MDNode::getMostGenericTBAA
static MDNode * getMostGenericTBAA(MDNode *A, MDNode *B)
Definition: TypeBasedAliasAnalysis.cpp:477
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::MDString::get
static MDString * get(LLVMContext &Context, StringRef Str)
Definition: Metadata.cpp:473
llvm::ReplaceableMetadataImpl
Shared implementation of use-lists for replaceable metadata.
Definition: Metadata.h:281
llvm::NamedMDNode::getOperand
MDNode * getOperand(unsigned i) const
Definition: Metadata.cpp:1124
llvm::MDNode::getMostGenericAlignmentOrDereferenceable
static MDNode * getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B)
Definition: Metadata.cpp:1093
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::TypedMDOperandIterator::iterator_category
std::input_iterator_tag iterator_category
Definition: Metadata.h:1259
llvm::ContextAndReplaceableUses
Pointer to the context, with optional RAUW support.
Definition: Metadata.h:807
llvm::MDTuple::getHash
unsigned getHash() const
Get the hash, if any.
Definition: Metadata.h:1168
llvm::MDTupleTypedArrayWrapper::operator[]
T * operator[](unsigned I) const
Definition: Metadata.h:1318
llvm::AAMDNodes::intersect
AAMDNodes intersect(const AAMDNodes &Other) const
Given two sets of AAMDNodes that apply to the same pointer, give the best AAMDNodes that are compatib...
Definition: Metadata.h:690
llvm::SPII::Store
@ Store
Definition: SparcInstrInfo.h:33
llvm::operator==
bool operator==(uint64_t V1, const APInt &V2)
Definition: APInt.h:1974
PointerUnion.h
llvm::MDNode::~MDNode
~MDNode()=default
llvm::ContextAndReplaceableUses::~ContextAndReplaceableUses
~ContextAndReplaceableUses()
Definition: Metadata.h:823
llvm::MDNode::dropAllReferences
void dropAllReferences()
Definition: Metadata.cpp:708
iterator_range.h
llvm::MDTuple::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1170
llvm::MetadataTracking::track
static bool track(void *Ref, Metadata &MD, MetadataAsValue &Owner)
Track the reference to metadata for MetadataAsValue.
Definition: Metadata.h:241
llvm::ValueAsMetadata::getValue
Value * getValue() const
Definition: Metadata.h:384
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MDNode
Metadata node.
Definition: Metadata.h:901
llvm::ValueAsMetadata::getContext
LLVMContext & getContext() const
Definition: Metadata.h:386
llvm::ContextAndReplaceableUses::operator=
ContextAndReplaceableUses & operator=(ContextAndReplaceableUses &&)=delete
llvm::StringRef::bytes_begin
const unsigned char * bytes_begin() const
Definition: StringRef.h:132
llvm::AAMDNodes::operator==
bool operator==(const AAMDNodes &A) const
Definition: Metadata.h:656
llvm::Metadata::print
void print(raw_ostream &OS, const Module *M=nullptr, bool IsForDebug=false) const
Print.
Definition: AsmWriter.cpp:4727
llvm::MDTupleTypedArrayWrapper
Typed, array-like tuple of metadata.
Definition: Metadata.h:1289
llvm::MDString::getLength
unsigned getLength() const
Definition: Metadata.h:630
llvm::operator*
APInt operator*(APInt a, uint64_t RHS)
Definition: APInt.h:2098
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::Metadata::~Metadata
~Metadata()=default
llvm::DenseMapInfo< AAMDNodes >::getHashValue
static unsigned getHashValue(const AAMDNodes &Val)
Definition: Metadata.h:729
llvm::ReplaceableMetadataImpl::OwnerTy
MetadataTracking::OwnerTy OwnerTy
Definition: Metadata.h:285
llvm::AAMDNodes::merge
AAMDNodes merge(const AAMDNodes &Other) const
Given two sets of AAMDNodes applying to potentially different locations, determine the best AAMDNodes...
Definition: TypeBasedAliasAnalysis.cpp:524
llvm::MDString::get
static MDString * get(LLVMContext &Context, const char *Str)
Definition: Metadata.h:624
None.h
llvm::mdconst::detail::IsValidReference
Definition: Metadata.h:527
llvm::TempMDNodeDeleter
Definition: Metadata.h:876
llvm::DistinctMDOperandPlaceholder::DistinctMDOperandPlaceholder
DistinctMDOperandPlaceholder()=delete
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::MetadataAsValue::getMetadata
Metadata * getMetadata() const
Definition: Metadata.h:193
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
llvm::Value::getType
Type * getType() const
All values are typed, get the type of this value.
Definition: Value.h:256
llvm::MDNode::concatenate
static MDNode * concatenate(MDNode *A, MDNode *B)
Methods for metadata merging.
Definition: Metadata.cpp:914
llvm::NamedMDNode::const_op_iterator
op_iterator_impl< const MDNode *, MDNode > const_op_iterator
Definition: Metadata.h:1482
llvm::MDNode::isUniqued
bool isUniqued() const
Definition: Metadata.h:980
A
* A
Definition: README_ALTIVEC.txt:89
uint32_t
llvm::Value::getContext
LLVMContext & getContext() const
All values hold a context through their type.
Definition: Value.cpp:978
llvm::MDTupleTypedArrayWrapper::get
MDTuple * get() const
Definition: Metadata.h:1311
llvm::MDNode::getMostGenericAliasScope
static MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)
Definition: Metadata.cpp:941
llvm::mdconst::dyn_extract
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
Definition: Metadata.h:585
llvm::ValueAsMetadata::getConstant
static ConstantAsMetadata * getConstant(Value *C)
Definition: Metadata.h:366
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::ContextAndReplaceableUses::hasReplaceableUses
bool hasReplaceableUses() const
Whether this contains RAUW support.
Definition: Metadata.h:828
Module
Machine Check Debug Module
Definition: MachineCheckDebugify.cpp:122
llvm::MDNode::isTBAAVtableAccess
bool isTBAAVtableAccess() const
Check whether MDNode is a vtable access.
Definition: TypeBasedAliasAnalysis.cpp:454
llvm::DenseMapInfo< AAMDNodes >::getTombstoneKey
static AAMDNodes getTombstoneKey()
Definition: Metadata.h:724
llvm::MDTuple::getTemporary
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a temporary node.
Definition: Metadata.h:1190
Node
Definition: ItaniumDemangle.h:234
llvm::ReplaceableMetadataImpl::getContext
LLVMContext & getContext() const
Definition: Metadata.h:299
llvm::MDNode::getDistinct
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1211
llvm::Metadata::Storage
unsigned char Storage
Storage flag for non-uniqued, otherwise unowned, metadata.
Definition: Metadata.h:73
llvm::NamedMDNode::operands
iterator_range< op_iterator > operands()
Definition: Metadata.h:1487
llvm::PointerUnion
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
Definition: PointerUnion.h:119
llvm::ilist_node
Definition: ilist_node.h:148
llvm::ContextAndReplaceableUses::makeReplaceable
void makeReplaceable(std::unique_ptr< ReplaceableMetadataImpl > ReplaceableUses)
Assign RAUW support to this.
Definition: Metadata.h:856
llvm::DistinctMDOperandPlaceholder::~DistinctMDOperandPlaceholder
~DistinctMDOperandPlaceholder()
Definition: Metadata.h:1361
llvm::DenseMapBase< SmallDenseMap< KeyT, ValueT, 4, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >, KeyT, ValueT, DenseMapInfo< KeyT >, llvm::detail::DenseMapPair< KeyT, ValueT > >::empty
LLVM_NODISCARD bool empty() const
Definition: DenseMap.h:97
llvm::MDNode::getContext
LLVMContext & getContext() const
Definition: Metadata.h:962
llvm::mdconst::detail::HasDereference::value
static const bool value
Definition: Metadata.h:520
llvm::TypedMDOperandIterator::value_type
T * value_type
Definition: Metadata.h:1260
llvm::Metadata::handleChangedOperand
void handleChangedOperand(void *, Metadata *)
Default handling of a changed operand, which asserts.
Definition: Metadata.h:97
llvm::ContextAndReplaceableUses::ContextAndReplaceableUses
ContextAndReplaceableUses()=delete
llvm::MDNode::isDistinct
bool isDistinct() const
Definition: Metadata.h:981
llvm::DistinctMDOperandPlaceholder::replaceUseWith
void replaceUseWith(Metadata *MD)
Replace the use of this with MD.
Definition: Metadata.h:1369
llvm::ConstantAsMetadata
Definition: Metadata.h:412
Constant.h
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
llvm::AliasScopeNode::getName
StringRef getName() const
Definition: Metadata.h:1243
llvm::MDNode::replaceAllUsesWith
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
Definition: Metadata.h:987
llvm::DenseMapInfo< AAMDNodes >::getEmptyKey
static AAMDNodes getEmptyKey()
Definition: Metadata.h:719
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::NamedMDNode::getParent
Module * getParent()
Get the module that holds this named metadata collection.
Definition: Metadata.h:1461
llvm::AAMDNodes::NoAlias
MDNode * NoAlias
The tag specifying the noalias scope.
Definition: Metadata.h:677
llvm::NamedMDNode::op_begin
op_iterator op_begin()
Definition: Metadata.h:1479
llvm::MetadataAsValue::get
static MetadataAsValue * get(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:106
llvm::mdconst::detail::IsValidPointer::value
static const bool value
Definition: Metadata.h:524
llvm::AliasScopeNode::getDomain
const MDNode * getDomain() const
Get the MDNode for this AliasScopeNode's domain.
Definition: Metadata.h:1238
llvm::MDNode::isResolved
bool isResolved() const
Check if node is fully resolved.
Definition: Metadata.h:978
llvm::mdconst::detail::IsValidPointer
Definition: Metadata.h:523
llvm::TypedMDOperandIterator::operator==
bool operator==(const TypedMDOperandIterator &X) const
Definition: Metadata.h:1281
Casting.h
llvm::mdconst::detail::HasDereference::Yes
char[1] Yes
Definition: Metadata.h:512
llvm::ValueAsMetadata::getAllArgListUsers
SmallVector< Metadata * > getAllArgListUsers()
Definition: Metadata.h:388
llvm::mdconst::detail::IsValidReference::value
static const bool value
Definition: Metadata.h:528
llvm::TypedMDOperandIterator::reference
T * reference
Definition: Metadata.h:1263
llvm::ContextAndReplaceableUses::takeReplaceableUses
std::unique_ptr< ReplaceableMetadataImpl > takeReplaceableUses()
Drop RAUW support.
Definition: Metadata.h:867
llvm::TempMDNodeDeleter::operator()
void operator()(MDNode *Node) const
Definition: Metadata.h:1220
llvm::NOMORE_ICP_MAGICNUM
const uint64_t NOMORE_ICP_MAGICNUM
Magic number in the value profile metadata showing a target has been promoted for the instruction and...
Definition: Metadata.h:57
llvm::NamedMDNode::print
void print(raw_ostream &ROS, bool IsForDebug=false) const
Definition: AsmWriter.cpp:4524
llvm::MetadataTracking::OwnerTy
PointerUnion< MetadataAsValue *, Metadata * > OwnerTy
Definition: Metadata.h:267
llvm::MDNode::deleteTemporary
static void deleteTemporary(MDNode *N)
Deallocate a node created by getTemporary.
Definition: Metadata.cpp:849
llvm::MetadataAsValue::classof
static bool classof(const Value *V)
Definition: Metadata.h:195
llvm::LocalAsMetadata::classof
static bool classof(const Metadata *MD)
Definition: Metadata.h:453
llvm::MDString::operator=
MDString & operator=(MDString &&)=delete
llvm::ReplaceableMetadataImpl::replaceAllUsesWith
void replaceAllUsesWith(Metadata *MD)
Replace all uses of this with MD.
Definition: Metadata.cpp:252
llvm::AAMDNodes::TBAA
MDNode * TBAA
The tag for type-based alias analysis.
Definition: Metadata.h:668
llvm::ValueAsMetadata::handleRAUW
static void handleRAUW(Value *From, Value *To)
Definition: Metadata.cpp:411
llvm::MDNode::replaceOperandWith
void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
Definition: Metadata.cpp:877
llvm::MDNode::replaceWithDistinct
static std::enable_if_t< std::is_base_of< MDNode, T >::value, T * > replaceWithDistinct(std::unique_ptr< T, TempMDNodeDeleter > N)
Replace a temporary node with a distinct one.
Definition: Metadata.h:1032
llvm::ConstantAsMetadata::getIfExists
static ConstantAsMetadata * getIfExists(Constant *C)
Definition: Metadata.h:423
llvm::MDOperand::MDOperand
MDOperand()=default
llvm::ValueAsMetadata::getIfExists
static ValueAsMetadata * getIfExists(Value *V)
Definition: Metadata.cpp:387
llvm::MDNode::isTemporary
bool isTemporary() const
Definition: Metadata.h:982
llvm::MDTuple::getIfExists
static MDTuple * getIfExists(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition: Metadata.h:1174
llvm::MetadataAsValue::getIfExists
static MetadataAsValue * getIfExists(LLVMContext &Context, Metadata *MD)
Definition: Metadata.cpp:114
llvm::MDNode::getMostGenericRange
static MDNode * getMostGenericRange(MDNode *A, MDNode *B)
Definition: Metadata.cpp:1021
SmallVector.h
llvm::simplify_type< const MDOperand >::getSimplifiedValue
static SimpleType getSimplifiedValue(const MDOperand &MD)
Definition: Metadata.h:800
llvm::AliasScopeNode
This is a simple wrapper around an MDNode which provides a higher-level interface by hiding the detai...
Definition: Metadata.h:1227
llvm::MDNode::getMostGenericFPMath
static MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
Definition: Metadata.cpp:973
N
#define N
LineType::Metadata
@ Metadata
llvm::MDNode::op_end
op_iterator op_end() const
Definition: Metadata.h:1101
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition: iterator_range.h:30
llvm::mdconst::hasa
std::enable_if_t< detail::IsValidPointer< X, Y >::value, bool > hasa(Y &&MD)
Check whether Metadata has a Value.
Definition: Metadata.h:540
ilist_node.h
llvm::Metadata::dump
void dump() const
User-friendly dump.
Definition: AsmWriter.cpp:4781
DenseMapInfo.h
llvm::TypedMDOperandIterator::pointer
void pointer
Definition: Metadata.h:1262
llvm::ValueAsMetadata
Value wrapper in the Metadata hierarchy.
Definition: Metadata.h:344
llvm::MDTupleTypedArrayWrapper::iterator
TypedMDOperandIterator< T > iterator
Definition: Metadata.h:1321
llvm::MDNode::clone
TempMDNode clone() const
Create a (temporary) clone of this.
Definition: Metadata.cpp:543
llvm::AliasScopeNode::AliasScopeNode
AliasScopeNode(const MDNode *N)
Definition: Metadata.h:1232
LLVMContext.h
From
BlockVerifier::State From
Definition: BlockVerifier.cpp:55
llvm::MDString::getString
StringRef getString() const
Definition: Metadata.cpp:483
llvm::MDOperand::operator=
MDOperand & operator=(MDOperand &&)=delete
llvm::NamedMDNode::clearOperands
void clearOperands()
Drop all references to this node's operands.
Definition: Metadata.cpp:1139
llvm::StringRef::size
LLVM_NODISCARD size_t size() const
size - Get the string size.
Definition: StringRef.h:157
llvm::ValueAsMetadata::getLocal
static LocalAsMetadata * getLocal(Value *Local)
Definition: Metadata.h:370
llvm::MDString
A single uniqued string.
Definition: Metadata.h:611
llvm::DistinctMDOperandPlaceholder::getID
unsigned getID() const
Definition: Metadata.h:1366
llvm::StringRef::begin
iterator begin() const
Definition: StringRef.h:128
Value.h
LLVMMetadataRef
struct LLVMOpaqueMetadata * LLVMMetadataRef
Represents an LLVM Metadata.
Definition: Types.h:89
llvm::MDOperand::operator*
Metadata & operator*() const
Definition: Metadata.h:762
llvm::MDNode::op_begin
op_iterator op_begin() const
Definition: Metadata.h:1097
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::MDOperand::get
Metadata * get() const
Definition: Metadata.h:759
llvm::Metadata::Uniqued
@ Uniqued
Definition: Metadata.h:70
llvm::AAMDNodes::shiftTBAAStruct
static MDNode * shiftTBAAStruct(MDNode *M, size_t off)
Definition: TypeBasedAliasAnalysis.cpp:761
llvm::MDOperand
Tracking metadata reference owned by Metadata.
Definition: Metadata.h:748
llvm::ValueAsMetadata::classof
static bool classof(const Metadata *MD)
Definition: Metadata.h:406
llvm::MDTuple::clone
TempMDTuple clone() const
Return a (temporary) clone of this.
Definition: Metadata.h:1196
llvm::LLVMConstants
LLVMConstants
Definition: Metadata.h:51
Other
Optional< std::vector< StOtherPiece > > Other
Definition: ELFYAML.cpp:1172
llvm::Use
A Use represents the edge between a Value definition and its users.
Definition: Use.h:44
llvm::StringRef::bytes_end
const unsigned char * bytes_end() const
Definition: StringRef.h:135
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:37
llvm::TypedMDOperandIterator::operator*
T * operator*() const
Definition: Metadata.h:1268