LLVM: include/llvm/IR/Metadata.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef LLVM_IR_METADATA_H
16#define LLVM_IR_METADATA_H
17
33#include
34#include
35#include
36#include
37#include
38#include
39#include <type_traits>
40#include
41
42namespace llvm {
43
52
56
57
58
60
61
62
63
66
67
68 const unsigned char SubclassID;
69
70protected:
71
73
74
76
80
81public:
83#define HANDLE_METADATA_LEAF(CLASS) CLASS##Kind,
84#include "llvm/IR/Metadata.def"
85 };
86
87protected:
90 static_assert(sizeof(*this) == 8, "Metadata fields poorly packed");
91 }
92
94
95
96
97
98
102
103public:
105
106
107
108
109
110
111
112
113
114
117
118
119
120
121
122
123
124
125
127 bool IsForDebug = false) const;
129 const Module *M = nullptr, bool IsForDebug = false) const;
130
131
132
133
134
135
136
137
138
140 const Module *M = nullptr) const;
142 const Module *M = nullptr) const;
143
144
145
147 LLVMContext::MD_range, LLVMContext::MD_nonnull, LLVMContext::MD_align};
148};
149
150
152
153
155 return reinterpret_cast<Metadata**>(MDs);
156}
157
158#define HANDLE_METADATA(CLASS) class CLASS;
159#include "llvm/IR/Metadata.def"
160
161
162
163#define HANDLE_METADATA_LEAF(CLASS) \
164 template <> struct isa_impl<CLASS, Metadata> { \
165 static inline bool doit(const Metadata &MD) { \
166 return MD.getMetadataID() == Metadata::CLASS##Kind; \
167 } \
168 };
169#include "llvm/IR/Metadata.def"
170
175
176
177
178
179
180
181
182
183class MetadataAsValue : public Value {
186
188
190
191
192 void dropUse() { MD = nullptr; }
193
194public:
196
200
202
204 return V->getValueID() == MetadataAsValueVal;
205 }
206
207private:
208 void handleChangedMetadata(Metadata *MD);
209 void track();
210 void untrack();
211};
212
213
214
215
216
217
218
219
221protected:
222
223
224
225
227
229
230public:
233
234
235
236
237
238
243 trackDebugValues();
244 }
247 retrackDebugValues(X);
248 }
251 trackDebugValues();
252 }
253
255 if (&X == this)
256 return *this;
257
258 untrackDebugValues();
260 retrackDebugValues(X);
261 return *this;
262 }
263
265 if (&X == this)
266 return *this;
267
268 untrackDebugValues();
270 trackDebugValues();
271 return *this;
272 }
273
275
277 untrackDebugValues();
279 }
280
282 assert(Idx < 3 && "Invalid debug value index.");
283 untrackDebugValue(Idx);
285 trackDebugValue(Idx);
286 }
287
294
295private:
296 LLVM_ABI void trackDebugValue(size_t Idx);
297 LLVM_ABI void trackDebugValues();
298
299 LLVM_ABI void untrackDebugValue(size_t Idx);
300 LLVM_ABI void untrackDebugValues();
301
303};
304
305
306
307
308
309
310
311
313public:
314
315
316
317
318
319
320
321
322
324 return track(&MD, *MD, static_cast<Metadata *>(nullptr));
325 }
326
327
328
329
330
331
335
336
337
338
339
340
344
345
346
347
348
349
353
354
355
356
359
360
361
362
363
364
365
366
367
369 return retrack(&MD, *MD, &New);
370 }
372
373
375
377
378private:
379
380
381
383};
384
385
386
387
388
389
392
393public:
395
396private:
400
401public:
403
405 assert(UseMap.empty() && "Cannot destroy in-use replaceable metadata");
406 }
407
409
410
411
412
414
416
418
420
421
422
423
424
425
427
428 unsigned getNumUses() const { return UseMap.size(); }
429
430private:
432 void dropRef(void *Ref);
433 void moveRef(void *Ref, void *New, const Metadata &MD);
434
435
436
437
438
440
441
443
444
445
446
447 static bool isReplaceable(const Metadata &MD);
448};
449
450
451
452
453
454
455
456
457
461
463
464
465 void dropUsers() {
467 }
468
469protected:
472 assert(V && "Expected valid value");
473 }
474
476
477public:
479
483
487
489
493
497
501
508
511
512protected:
513
514
515
516
517
521
522public:
527};
528
531
534
535public:
539
543
547
551};
552
555
559 }
560
561public:
565
569
573};
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
624
626template <typename U, typename V>
628
629template <typename U, typename V>
632
634 static const bool value = std::is_base_of<Constant, V>::value &&
636};
638 static const bool value = std::is_base_of<Constant, V>::value &&
639 std::is_convertible<M, const Metadata &>::value;
640};
641
642}
643
644
645
646
647
648template <class X, class Y>
649inline std::enable_if_t<detail::IsValidPointer<X, Y>::value, bool>
651 assert(MD && "Null pointer sent into hasa");
653 return isa(V->getValue());
654 return false;
655}
656template <class X, class Y>
657inline std::enable_if_t<detail::IsValidReference<X, Y &>::value, bool>
659 return hasa(&MD);
660}
661
662
663
664
665template <class X, class Y>
666inline std::enable_if_t<detail::IsValidPointer<X, Y>::value, X *>
670template <class X, class Y>
671inline std::enable_if_t<detail::IsValidReference<X, Y &>::value, X *>
675
676
677
678
679
680template <class X, class Y>
681inline std::enable_if_t<detail::IsValidPointer<X, Y>::value, X *>
684 return cast(V->getValue());
685 return nullptr;
686}
687
688
689
690
691
692
693template <class X, class Y>
694inline std::enable_if_t<detail::IsValidPointer<X, Y>::value, X *>
700
701
702
703
704
705
706template <class X, class Y>
707inline std::enable_if_t<detail::IsValidPointer<X, Y>::value, X *>
713
714}
715
716
717
718
719
720
723
725
727
728public:
731 MDString &operator=(const MDString &) = delete;
732
737
739
741
743
744
746
747
749
752
753
757};
758
759
760
765
770
772
773 explicit operator bool() const {
775 }
776
777
779
780
782
783
785
786
788
789
791
792
794
795
797
798
799
801
802
803
804
805
806
809 Result.TBAA = Other.TBAA == TBAA ? TBAA : nullptr;
813 Result.NoAliasAddrSpace =
815 return Result;
816 }
817
818
819
823 Result.TBAAStruct =
825 Result.Scope = Scope;
826 Result.NoAlias = NoAlias;
828 return Result;
829 }
830
831
832
833
837
838
839
841 Result.Scope = Scope;
842 Result.NoAlias = NoAlias;
844 return Result;
845 }
846
847
848
850
851
852
853
855
856
857
858
859
860
865};
866
867
868template<>
872 nullptr, nullptr);
873 }
874
877 nullptr, nullptr, nullptr);
878 }
879
887
891};
892
893
894
895
896
897
898
899
902
903public:
907 MD = Op.MD;
908 if (MD)
910 Op.MD = nullptr;
911 }
914 MD = Op.MD;
915 if (MD)
917 Op.MD = nullptr;
918 return *this;
919 }
920
921
926
928
933
935 untrack();
936 MD = nullptr;
937 }
939 untrack();
940 this->MD = MD;
942 }
943
944private:
946 if (MD) {
949 else
951 }
952 }
953
954 void untrack() {
955 assert(static_cast<void *>(this) == &MD && "Expected same address");
956 if (MD)
958 }
959};
960
966
972
973
974
975
976
979
980public:
983 std::unique_ptr ReplaceableUses)
984 : Ptr(ReplaceableUses.release()) {
986 }
994
996
997
1001
1007
1011 return nullptr;
1012 }
1013
1014
1020
1021
1022
1023
1024
1025 void
1026 makeReplaceable(std::unique_ptr ReplaceableUses) {
1027 assert(ReplaceableUses && "Expected non-null replaceable uses");
1029 "Expected same context");
1031 Ptr = ReplaceableUses.release();
1032 }
1033
1034
1035
1036
1039 std::unique_ptr ReplaceableUses(
1041 Ptr = &ReplaceableUses->getContext();
1042 return ReplaceableUses;
1043 }
1044};
1045
1049
1050#define HANDLE_MDNODE_LEAF(CLASS) \
1051 using Temp##CLASS = std::unique_ptr<CLASS, TempMDNodeDeleter>;
1052#define HANDLE_MDNODE_BRANCH(CLASS) HANDLE_MDNODE_LEAF(CLASS)
1053#include "llvm/IR/Metadata.def"
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1082
1083
1084
1085
1086
1087
1088
1089
1090 struct alignas(alignof(size_t)) Header {
1091 size_t IsResizable : 1;
1092 size_t IsLarge : 1;
1093 size_t SmallSize : 4;
1094 size_t SmallNumOps : 4;
1095 size_t : sizeof(size_t) * CHAR_BIT - 10;
1096
1097 unsigned NumUnresolved = 0;
1099
1100 static constexpr size_t NumOpsFitInVector =
1101 sizeof(LargeStorageVector) / sizeof(MDOperand);
1102 static_assert(
1103 NumOpsFitInVector * sizeof(MDOperand) == sizeof(LargeStorageVector),
1104 "sizeof(LargeStorageVector) must be a multiple of sizeof(MDOperand)");
1105
1106 static constexpr size_t MaxSmallSize = 15;
1107
1108 static constexpr size_t getOpSize(unsigned NumOps) {
1110 }
1111
1112
1113 static size_t getSmallSize(size_t NumOps, bool IsResizable, bool IsLarge) {
1114 return IsLarge ? NumOpsFitInVector
1115 : std::max(NumOps, NumOpsFitInVector * IsResizable);
1116 }
1117
1119 return getOpSize(
1121 sizeof(Header);
1122 }
1123
1124
1126 static bool isLarge(size_t NumOps) { return NumOps > MaxSmallSize; }
1127
1128 size_t getAllocSize() const {
1129 return getOpSize(SmallSize) + sizeof(Header);
1130 }
1131 void *getAllocation() {
1132 return reinterpret_cast<char *>(this + 1) -
1133 alignTo(getAllocSize(), alignof(uint64_t));
1134 }
1135
1136 void *getLargePtr() const {
1137 static_assert(alignof(LargeStorageVector) <= alignof(Header),
1138 "LargeStorageVector too strongly aligned");
1139 return reinterpret_cast<char *>(const_cast<Header *>(this)) -
1140 sizeof(LargeStorageVector);
1141 }
1142
1143 LLVM_ABI void *getSmallPtr();
1144
1145 LargeStorageVector &getLarge() {
1147 return *reinterpret_cast<LargeStorageVector *>(getLargePtr());
1148 }
1149
1150 const LargeStorageVector &getLarge() const {
1152 return *reinterpret_cast<const LargeStorageVector *>(getLargePtr());
1153 }
1154
1158
1161
1163 if (IsLarge)
1164 return getLarge();
1166 reinterpret_cast<MDOperand *>(this) - SmallSize, SmallNumOps);
1167 }
1168
1170 if (IsLarge)
1171 return getLarge();
1172 return ArrayRef(reinterpret_cast<const MDOperand *>(this) - SmallSize,
1173 SmallNumOps);
1174 }
1175
1177 if (!IsLarge)
1178 return SmallNumOps;
1179 return getLarge().size();
1180 }
1181 };
1182
1183 Header &getHeader() { return *(reinterpret_cast<Header *>(this) - 1); }
1184
1185 const Header &getHeader() const {
1186 return *(reinterpret_cast<const Header *>(this) - 1);
1187 }
1188
1189 ContextAndReplaceableUses Context;
1190
1191protected:
1195
1197 LLVM_ABI void operator delete(void *Mem);
1198
1199
1203
1204
1208
1210
1213
1215
1219
1220public:
1223 void *operator new(size_t) = delete;
1224
1232
1233
1235
1236
1237
1238
1239
1241
1243
1244
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1259
1263
1266
1267
1270 return false;
1272 }
1273
1276 return Context.getReplaceableUses()->getNumUses();
1277 }
1278
1279
1280
1281
1284 if (Context.hasReplaceableUses())
1285 Context.getReplaceableUses()->replaceAllUsesWith(MD);
1286 }
1287
1288
1289
1290
1291
1292
1293
1295
1296
1298
1299
1300
1301
1302
1303 template
1304 static std::enable_if_t<std::is_base_of<MDNode, T>::value, T *>
1306 return cast(N.release()->replaceWithPermanentImpl());
1307 }
1308
1309
1310
1311
1312
1313
1314
1315 template
1316 static std::enable_if_t<std::is_base_of<MDNode, T>::value, T *>
1318 return cast(N.release()->replaceWithUniquedImpl());
1319 }
1320
1321
1322
1323
1324
1325 template
1326 static std::enable_if_t<std::is_base_of<MDNode, T>::value, T *>
1328 return cast(N.release()->replaceWithDistinctImpl());
1329 }
1330
1331
1332
1333
1334
1335
1336
1337
1340 const Module *M = nullptr) const;
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1354
1355
1356private:
1360
1361protected:
1362
1363
1364
1366
1368
1371 template <class T, class StoreT>
1374
1375
1376
1377
1378
1380 assert(() && "Resizing is not supported for uniqued nodes");
1382 "Resizing is not supported for this node kind");
1383 getHeader().resize(NumOps);
1384 }
1385
1386private:
1387 void handleChangedOperand(void *Ref, Metadata *New);
1388
1389
1390 void dropReplaceableUses();
1391
1392 void resolveAfterOperandChange(Metadata *Old, Metadata *New);
1393 void decrementUnresolvedOperandCount();
1394 void countUnresolvedOperands();
1395
1396
1397
1398
1399
1400
1401 void makeUniqued();
1402
1403
1404
1405
1406
1407 void makeDistinct();
1408
1409 void deleteAsSubclass();
1411 void eraseFromStore();
1412
1413 template struct HasCachedHash;
1414 template static void dispatchRecalculateHash(NodeTy *N) {
1415 if constexpr (HasCachedHash::value)
1416 N->recalculateHash();
1417 }
1418 template static void dispatchResetHash(NodeTy *N) {
1419 if constexpr (HasCachedHash::value)
1420 N->setHash(0);
1421 }
1422
1423
1425 const Instruction *AInstr,
1426 const Instruction *BInstr);
1427
1428public:
1431
1435
1439
1441
1444 return getHeader().operands()[I];
1445 }
1446
1447
1448 unsigned getNumOperands() const { return getHeader().getNumOperands(); }
1449
1450
1453 default:
1454 return false;
1455#define HANDLE_MDNODE_LEAF(CLASS) \
1456 case CLASS##Kind: \
1457 return true;
1458#include "llvm/IR/Metadata.def"
1459 }
1460 }
1461
1462
1464
1465
1475
1476
1484
1485
1487
1488
1491};
1492
1493
1494
1495
1496
1500
1504 setHash(Hash);
1505 }
1506
1508
1509 void setHash(unsigned Hash) { SubclassData32 = Hash; }
1510 void recalculateHash();
1511
1512 LLVM_ABI static MDTuple *getImpl(LLVMContext &Context,
1515 bool ShouldCreate = true);
1516
1517 TempMDTuple cloneImpl() const {
1520 }
1521
1522public:
1523
1525
1527 return getImpl(Context, MDs, Uniqued);
1528 }
1529
1531 return getImpl(Context, MDs, Uniqued, false);
1532 }
1533
1534
1535
1536
1538 return getImpl(Context, MDs, Distinct);
1539 }
1540
1541
1542
1543
1544
1545
1548 return TempMDTuple(getImpl(Context, MDs, Temporary));
1549 }
1550
1551
1552 TempMDTuple clone() const { return cloneImpl(); }
1553
1554
1560
1561
1563
1567};
1568
1572
1576
1580
1585
1589
1590
1591
1592
1594 const MDNode *Node = nullptr;
1595
1596public:
1599
1600
1602
1603
1605 if (Node->getNumOperands() < 2)
1606 return nullptr;
1608 }
1610 if (Node->getNumOperands() > 2)
1612 return N->getString();
1614 }
1615};
1616
1617
1618
1619
1620
1623
1624public:
1630
1633
1635
1637 ++I;
1638 return *this;
1639 }
1640
1643 ++I;
1644 return Temp;
1645 }
1646
1649};
1650
1651
1652
1653
1654
1656 const MDTuple *N = nullptr;
1657
1658public:
1661
1662 template
1665 std::enable_if_t<std::is_convertible<U *, T *>::value> * = nullptr)
1667
1668 template
1671 std::enable_if_t<!std::is_convertible<U *, T *>::value> * = nullptr)
1673
1674 explicit operator bool() const { return get(); }
1675 explicit operator MDTuple *() const { return get(); }
1676
1680
1681
1682 unsigned size() const { return N ? N->getNumOperands() : 0u; }
1683 bool empty() const { return N ? N->getNumOperands() == 0 : true; }
1685
1686
1688
1691};
1692
1693#define HANDLE_METADATA(CLASS) \
1694 using CLASS##Array = MDTupleTypedArrayWrapper;
1695#include "llvm/IR/Metadata.def"
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1714
1716
1717public:
1722
1726
1728 if (Use)
1729 *Use = nullptr;
1730 }
1731
1733
1734
1736 if (!Use)
1737 return;
1738 *Use = MD;
1739
1740 if (*Use)
1742
1745 assert(!Use && "Use is still being tracked despite being untracked!");
1746 }
1747};
1748
1749
1750
1751
1752
1753
1754
1755
1756
1760
1761 std::string Name;
1762 Module *Parent = nullptr;
1763 void *Operands;
1764
1765 void setParent(Module *M) { Parent = M; }
1766
1768
1769 template class op_iterator_impl {
1771
1773 unsigned Idx = 0;
1774
1775 op_iterator_impl(const NamedMDNode *N, unsigned i) : Node(N), Idx(i) {}
1776
1777 public:
1778 using iterator_category = std::bidirectional_iterator_tag;
1779 using value_type = T1;
1780 using difference_type = std::ptrdiff_t;
1781 using pointer = value_type *;
1782 using reference = value_type;
1783
1784 op_iterator_impl() = default;
1785
1786 bool operator==(const op_iterator_impl &o) const { return Idx == o.Idx; }
1787 bool operator!=(const op_iterator_impl &o) const { return Idx != o.Idx; }
1788
1789 op_iterator_impl &operator++() {
1790 ++Idx;
1791 return *this;
1792 }
1793
1794 op_iterator_impl operator++(int) {
1795 op_iterator_impl tmp(*this);
1796 operator++();
1797 return tmp;
1798 }
1799
1800 op_iterator_impl &operator--() {
1801 --Idx;
1802 return *this;
1803 }
1804
1805 op_iterator_impl operator--(int) {
1806 op_iterator_impl tmp(*this);
1807 operator--();
1808 return tmp;
1809 }
1810
1811 T1 operator*() const { return Node->getOperand(Idx); }
1812 };
1813
1814public:
1817
1818
1820
1821
1823
1825
1826
1829
1837 bool IsForDebug = false) const;
1839
1840
1841
1842
1844
1847
1849
1852
1859};
1860
1861
1863
1864}
1865
1866#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref)
static ManagedStatic< DebugCounterOwner > Owner
This file defines DenseMapInfo traits for DenseMap.
This file defines the DenseMap class.
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
bool operator==(const MergedFunctionsInfo &LHS, const MergedFunctionsInfo &RHS)
This file defines the PointerUnion class, which is a discriminated union of pointer types.
This file defines the SmallVector class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
AliasScopeNode(const MDNode *N)
Definition Metadata.h:1598
const MDNode * getNode() const
Get the MDNode for this AliasScopeNode.
Definition Metadata.h:1601
const MDNode * getDomain() const
Get the MDNode for this AliasScopeNode's domain.
Definition Metadata.h:1604
StringRef getName() const
Definition Metadata.h:1609
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is an important base class in LLVM.
ContextAndReplaceableUses & operator=(const ContextAndReplaceableUses &)=delete
ReplaceableMetadataImpl * getReplaceableUses() const
Definition Metadata.h:1008
std::unique_ptr< ReplaceableMetadataImpl > takeReplaceableUses()
Drop RAUW support.
Definition Metadata.h:1037
ContextAndReplaceableUses & operator=(ContextAndReplaceableUses &&)=delete
ReplaceableMetadataImpl * getOrCreateReplaceableUses()
Ensure that this has RAUW support, and then return it.
Definition Metadata.h:1015
void makeReplaceable(std::unique_ptr< ReplaceableMetadataImpl > ReplaceableUses)
Assign RAUW support to this.
Definition Metadata.h:1026
ContextAndReplaceableUses(ContextAndReplaceableUses &&)=delete
ContextAndReplaceableUses(const ContextAndReplaceableUses &)=delete
LLVMContext & getContext() const
Definition Metadata.h:1002
~ContextAndReplaceableUses()
Definition Metadata.h:993
bool hasReplaceableUses() const
Whether this contains RAUW support.
Definition Metadata.h:998
ContextAndReplaceableUses()=delete
ContextAndReplaceableUses(LLVMContext &Context)
Definition Metadata.h:981
ContextAndReplaceableUses(std::unique_ptr< ReplaceableMetadataImpl > ReplaceableUses)
Definition Metadata.h:982
A parsed version of the target data layout string in and methods for querying it.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
Base class for tracking ValueAsMetadata/DIArgLists with user lookups and Owner callbacks outside of V...
Definition Metadata.h:220
DebugValueUser(const DebugValueUser &X)
Definition Metadata.h:249
DebugValueUser & operator=(DebugValueUser &&X)
Definition Metadata.h:254
LLVM_ABI void handleChangedValue(void *Old, Metadata *NewDebugValue)
To be called by ReplaceableMetadataImpl::replaceAllUsesWith, where Old is a pointer to one of the poi...
bool operator!=(const DebugValueUser &X) const
Definition Metadata.h:291
DebugValueUser(std::array< Metadata *, 3 > DebugValues)
Definition Metadata.h:241
bool operator==(const DebugValueUser &X) const
Definition Metadata.h:288
void resetDebugValues()
Definition Metadata.h:276
ArrayRef< Metadata * > getDebugValues() const
Definition Metadata.h:228
DebugValueUser & operator=(const DebugValueUser &X)
Definition Metadata.h:264
std::array< Metadata *, 3 > DebugValues
Definition Metadata.h:226
void resetDebugValue(size_t Idx, Metadata *DebugValue)
Definition Metadata.h:281
LLVM_ABI DbgVariableRecord * getUser()
DebugValueUser(DebugValueUser &&X)
Definition Metadata.h:245
~DebugValueUser()
Definition Metadata.h:274
void replaceUseWith(Metadata *MD)
Replace the use of this with MD.
Definition Metadata.h:1735
friend class MetadataTracking
Definition Metadata.h:1713
DistinctMDOperandPlaceholder()=delete
~DistinctMDOperandPlaceholder()
Definition Metadata.h:1727
unsigned getID() const
Definition Metadata.h:1732
DistinctMDOperandPlaceholder(const DistinctMDOperandPlaceholder &)=delete
DistinctMDOperandPlaceholder(unsigned ID)
Definition Metadata.h:1718
DistinctMDOperandPlaceholder(DistinctMDOperandPlaceholder &&)=delete
This is an important class for using LLVM in a threaded context.
Metadata node.
Definition Metadata.h:1078
friend class DIAssignID
Definition Metadata.h:1081
static LLVM_ABI MDNode * getMostGenericAliasScope(MDNode *A, MDNode *B)
static LLVM_ABI MDNode * getMergedCallsiteMetadata(MDNode *A, MDNode *B)
LLVM_ABI void printTree(raw_ostream &OS, const Module *M=nullptr) const
Print in tree shape.
LLVM_ABI void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
iterator_range< MDOperand * > mutable_op_range
Definition Metadata.h:1214
LLVM_ABI void resolveCycles()
Resolve cycles.
LLVM_ABI bool isTBAAVtableAccess() const
Check whether MDNode is a vtable access.
static LLVM_ABI CaptureComponents toCaptureComponents(const MDNode *MD)
Convert !captures metadata to CaptureComponents. MD may be nullptr.
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1577
mutable_op_range mutable_operands()
Definition Metadata.h:1216
static LLVM_ABI MDNode * getMergedCalleeTypeMetadata(const MDNode *A, const MDNode *B)
void replaceAllUsesWith(Metadata *MD)
RAUW a temporary.
Definition Metadata.h:1282
static LLVM_ABI MDNode * concatenate(MDNode *A, MDNode *B)
Methods for metadata merging.
static LLVM_ABI void deleteTemporary(MDNode *N)
Deallocate a node created by getTemporary.
LLVM_ABI void resolve()
Resolve a unique, unresolved node.
static LLVM_ABI MDNode * getMostGenericTBAA(MDNode *A, MDNode *B)
const MDOperand & getOperand(unsigned I) const
Definition Metadata.h:1442
static LLVM_ABI MDNode * getMostGenericNoaliasAddrspace(MDNode *A, MDNode *B)
LLVM_ABI void storeDistinctInContext()
bool isTemporary() const
Definition Metadata.h:1262
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1581
ArrayRef< MDOperand > operands() const
Definition Metadata.h:1440
op_iterator op_end() const
Definition Metadata.h:1436
bool hasGeneralizedMDString()
Check if this is a valid generalized type metadata node.
Definition Metadata.h:1268
MDNode(const MDNode &)=delete
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1569
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:1327
static LLVM_ABI MDNode * getMergedProfMetadata(MDNode *A, MDNode *B, const Instruction *AInstr, const Instruction *BInstr)
Merge !prof metadata from two instructions.
static bool classof(const Metadata *MD)
Methods for support type inquiry through isa, cast, and dyn_cast:
Definition Metadata.h:1451
friend class ReplaceableMetadataImpl
Definition Metadata.h:1079
bool isUniqued() const
Definition Metadata.h:1260
static LLVM_ABI MDNode * getMostGenericFPMath(MDNode *A, MDNode *B)
void setNumUnresolved(unsigned N)
Definition Metadata.h:1369
void resize(size_t NumOps)
Resize the node to hold NumOps operands.
Definition Metadata.h:1379
unsigned getNumOperands() const
Return number of MDNode operands.
Definition Metadata.h:1448
MDOperand * mutable_begin()
Definition Metadata.h:1211
LLVM_ABI MDNode(LLVMContext &Context, unsigned ID, StorageType Storage, ArrayRef< Metadata * > Ops1, ArrayRef< Metadata * > Ops2={})
iterator_range< op_iterator > op_range
Definition Metadata.h:1430
friend class LLVMContextImpl
Definition Metadata.h:1080
LLVM_ABI TempMDNode clone() const
Create a (temporary) clone of this.
static LLVM_ABI MDNode * getMostGenericRange(MDNode *A, MDNode *B)
bool isDistinct() const
Definition Metadata.h:1261
unsigned getNumTemporaryUses() const
Definition Metadata.h:1274
static LLVM_ABI MDNode * getMergedMemProfMetadata(MDNode *A, MDNode *B)
bool isReplaceable() const
Definition Metadata.h:1264
LLVM_ABI void setOperand(unsigned I, Metadata *New)
Set an operand.
bool isResolved() const
Check if node is fully resolved.
Definition Metadata.h:1258
op_iterator op_begin() const
Definition Metadata.h:1432
static LLVM_ABI MDNode * intersect(MDNode *A, MDNode *B)
static T * storeImpl(T *N, StorageType Storage, StoreT &Store)
LLVMContext & getContext() const
Definition Metadata.h:1242
MDOperand * mutable_end()
Definition Metadata.h:1212
static LLVM_ABI MDNode * fromCaptureComponents(LLVMContext &Ctx, CaptureComponents CC)
Convert CaptureComponents to !captures metadata.
static MDTuple * getIfExists(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1573
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:1305
LLVM_ABI void dropAllReferences()
void operator=(const MDNode &)=delete
const MDOperand * op_iterator
Definition Metadata.h:1429
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:1317
LLVM_ABI void dumpTree() const
User-friendly dump in tree shape.
static LLVM_ABI MDNode * getMostGenericAlignmentOrDereferenceable(MDNode *A, MDNode *B)
unsigned getNumUnresolved() const
Definition Metadata.h:1367
bool isAlwaysReplaceable() const
Definition Metadata.h:1265
Tracking metadata reference owned by Metadata.
Definition Metadata.h:900
bool equalsStr(StringRef Str) const
Definition Metadata.h:922
void reset(Metadata *MD, Metadata *Owner)
Definition Metadata.h:938
Metadata * operator->() const
Definition Metadata.h:931
MDOperand & operator=(const MDOperand &)=delete
~MDOperand()
Definition Metadata.h:927
Metadata & operator*() const
Definition Metadata.h:932
Metadata * get() const
Definition Metadata.h:929
MDOperand(const MDOperand &)=delete
void reset()
Definition Metadata.h:934
MDOperand & operator=(MDOperand &&Op)
Definition Metadata.h:913
MDOperand(MDOperand &&Op)
Definition Metadata.h:906
A single uniqued string.
Definition Metadata.h:721
unsigned getLength() const
Definition Metadata.h:740
const unsigned char * bytes_begin() const
Definition Metadata.h:750
MDString(const MDString &)=delete
static MDString * get(LLVMContext &Context, const char *Str)
Definition Metadata.h:734
MDString & operator=(MDString &&)=delete
static bool classof(const Metadata *MD)
Methods for support type inquiry through isa, cast, and dyn_cast.
Definition Metadata.h:754
const unsigned char * bytes_end() const
Definition Metadata.h:751
iterator begin() const
Pointer to the first byte of the string.
Definition Metadata.h:745
MDString & operator=(const MDString &)=delete
LLVM_ABI StringRef getString() const
StringRef::iterator iterator
Definition Metadata.h:742
iterator end() const
Pointer to one byte past the end of the string.
Definition Metadata.h:748
static LLVM_ABI MDString * get(LLVMContext &Context, StringRef Str)
MDTupleTypedArrayWrapper(const MDTupleTypedArrayWrapper< U > &Other, std::enable_if_t<!std::is_convertible< U *, T * >::value > *=nullptr)
Definition Metadata.h:1669
MDTupleTypedArrayWrapper()=default
bool empty() const
Definition Metadata.h:1683
MDTuple * get() const
Definition Metadata.h:1677
unsigned size() const
Definition Metadata.h:1682
MDTupleTypedArrayWrapper(const MDTuple *N)
Definition Metadata.h:1660
T * operator[](unsigned I) const
Definition Metadata.h:1684
iterator begin() const
Definition Metadata.h:1689
MDTuple * operator->() const
Definition Metadata.h:1678
MDTuple & operator*() const
Definition Metadata.h:1679
MDTupleTypedArrayWrapper(const MDTupleTypedArrayWrapper< U > &Other, std::enable_if_t< std::is_convertible< U *, T * >::value > *=nullptr)
Definition Metadata.h:1663
iterator end() const
Definition Metadata.h:1690
TypedMDOperandIterator< T > iterator
Definition Metadata.h:1687
Tuple of metadata.
Definition Metadata.h:1497
TempMDTuple clone() const
Return a (temporary) clone of this.
Definition Metadata.h:1552
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a distinct node.
Definition Metadata.h:1537
static bool classof(const Metadata *MD)
Definition Metadata.h:1564
void push_back(Metadata *MD)
Append an element to the tuple. This will resize the node.
Definition Metadata.h:1555
unsigned getHash() const
Get the hash, if any.
Definition Metadata.h:1524
friend class LLVMContextImpl
Definition Metadata.h:1498
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1526
static MDTuple * getIfExists(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition Metadata.h:1530
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a temporary node.
Definition Metadata.h:1546
friend class MDNode
Definition Metadata.h:1499
void pop_back()
Shrink the operands by 1.
Definition Metadata.h:1562
Manage lifetime of a slot tracker for printing IR.
A Module instance is used to store all the information related to an LLVM module.
A tuple of MDNodes.
Definition Metadata.h:1757
const_op_iterator op_begin() const
Definition Metadata.h:1850
NamedMDNode(const NamedMDNode &)=delete
op_iterator_impl< const MDNode * > const_op_iterator
Definition Metadata.h:1848
friend class Module
Definition Metadata.h:1759
LLVM_ABI void dump() const
LLVM_ABI void setOperand(unsigned I, MDNode *New)
LLVM_ABI StringRef getName() const
void dropAllReferences()
Remove all uses and clear node vector.
Definition Metadata.h:1822
LLVM_ABI void print(raw_ostream &ROS, bool IsForDebug=false) const
LLVM_ABI void eraseFromParent()
Drop all references and remove the node from parent module.
const_op_iterator op_end() const
Definition Metadata.h:1851
iterator_range< const_op_iterator > operands() const
Definition Metadata.h:1856
op_iterator op_end()
Definition Metadata.h:1846
LLVM_ABI MDNode * getOperand(unsigned i) const
friend class LLVMContextImpl
Definition Metadata.h:1758
op_iterator op_begin()
Definition Metadata.h:1845
op_iterator_impl< MDNode * > op_iterator
Definition Metadata.h:1843
LLVM_ABI unsigned getNumOperands() const
const Module * getParent() const
Definition Metadata.h:1828
LLVM_ABI void clearOperands()
Drop all references to this node's operands.
iterator_range< op_iterator > operands()
Definition Metadata.h:1853
Module * getParent()
Get the module that holds this named metadata collection.
Definition Metadata.h:1827
LLVM_ABI void addOperand(MDNode *M)
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMapEntryStorage - Holds the value in a StringMapEntry.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringRef - Represent a constant reference to a string, i.e.
const unsigned char * bytes_end() const
constexpr size_t size() const
size - Get the string size.
const unsigned char * bytes_begin() const
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
Typed iterator through MDNode operands.
Definition Metadata.h:1621
TypedMDOperandIterator operator++(int)
Definition Metadata.h:1641
std::ptrdiff_t difference_type
Definition Metadata.h:1627
T * operator*() const
Definition Metadata.h:1634
TypedMDOperandIterator()=default
std::input_iterator_tag iterator_category
Definition Metadata.h:1625
void pointer
Definition Metadata.h:1628
T * reference
Definition Metadata.h:1629
bool operator==(const TypedMDOperandIterator &X) const
Definition Metadata.h:1647
T * value_type
Definition Metadata.h:1626
TypedMDOperandIterator & operator++()
Definition Metadata.h:1636
TypedMDOperandIterator(MDNode::op_iterator I)
Definition Metadata.h:1632
bool operator!=(const TypedMDOperandIterator &X) const
Definition Metadata.h:1648
LLVM Value Representation.
LLVM_ABI Value(Type *Ty, unsigned scid)
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
struct LLVMOpaqueNamedMDNode * LLVMNamedMDNodeRef
Represents an LLVM Named Metadata Node.
struct LLVMOpaqueMetadata * LLVMMetadataRef
Represents an LLVM Metadata.
This file defines the ilist_node class template, which is a convenient base class for creating classe...
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
static constexpr bool HasDereference
Definition Metadata.h:630
decltype(static_cast< V >(*std::declval< U & >())) check_has_dereference
Definition Metadata.h:627
Transitional API for extracting constants from Metadata.
Definition Metadata.h:623
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:708
std::enable_if_t< detail::IsValidPointer< X, Y >::value, bool > hasa(Y &&MD)
Check whether Metadata has a Value.
Definition Metadata.h:650
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:682
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
Definition Metadata.h:695
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto cast_or_null(const Y &Val)
bool isa_and_nonnull(const Y &Val)
auto dyn_cast_or_null(const Y &Val)
CaptureComponents
Components of the pointer that may be captured.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
MutableArrayRef(T &OneElt) -> MutableArrayRef< T >
@ Ref
The access may reference the value stored in memory.
Attribute unwrap(LLVMAttributeRef Attr)
uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
ArrayRef(const T &OneElt) -> ArrayRef< T >
typename detail::detector< void, Op, Args... >::value_t is_detected
Detects if a given trait holds for some set of arguments 'Args'.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
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:59
LLVMConstants
Definition Metadata.h:53
@ DEBUG_METADATA_VERSION
Definition Metadata.h:54
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition Metadata.h:761
LLVM_ABI AAMDNodes concat(const AAMDNodes &Other) const
Determine the best AAMDNodes after concatenating two different locations together.
static LLVM_ABI MDNode * shiftTBAAStruct(MDNode *M, size_t off)
bool operator!=(const AAMDNodes &A) const
Definition Metadata.h:771
MDNode * NoAliasAddrSpace
The tag specifying the noalias address spaces.
Definition Metadata.h:790
MDNode * TBAAStruct
The tag for type-based alias analysis (tbaa struct).
Definition Metadata.h:781
MDNode * Scope
The tag for alias scope specification (used with noalias).
Definition Metadata.h:784
static LLVM_ABI MDNode * extendToTBAA(MDNode *TBAA, ssize_t len)
MDNode * TBAA
The tag for type-based alias analysis.
Definition Metadata.h:778
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:820
LLVM_ABI AAMDNodes merge(const AAMDNodes &Other) const
Given two sets of AAMDNodes applying to potentially different locations, determine the best AAMDNodes...
MDNode * NoAlias
The tag specifying the noalias scope.
Definition Metadata.h:787
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:807
LLVM_ABI AAMDNodes adjustForAccess(unsigned AccessSize)
Create a new AAMDNode for accessing AccessSize bytes of this AAMDNode.
AAMDNodes(MDNode *T, MDNode *TS, MDNode *S, MDNode *N, MDNode *NAS)
Definition Metadata.h:763
AAMDNodes extendTo(ssize_t Len) const
Create a new AAMDNode that describes this AAMDNode after extending it to apply to a series of bytes o...
Definition Metadata.h:834
bool operator==(const AAMDNodes &A) const
Definition Metadata.h:766
static LLVM_ABI MDNode * shiftTBAA(MDNode *M, size_t off)
static AAMDNodes getEmptyKey()
Definition Metadata.h:870
static unsigned getHashValue(const AAMDNodes &Val)
Definition Metadata.h:880
static AAMDNodes getTombstoneKey()
Definition Metadata.h:875
static bool isEqual(const AAMDNodes &LHS, const AAMDNodes &RHS)
Definition Metadata.h:888
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition Metadata.h:1046
void operator()(MDNode *Node) const
Definition Metadata.h:1586
Definition Metadata.h:633
static const bool value
Definition Metadata.h:634
Definition Metadata.h:637
static const bool value
Definition Metadata.h:638
Metadata * SimpleType
Definition Metadata.h:962
static SimpleType getSimplifiedValue(MDOperand &MD)
Definition Metadata.h:964
Metadata * SimpleType
Definition Metadata.h:968
static SimpleType getSimplifiedValue(const MDOperand &MD)
Definition Metadata.h:970
Define a template that can be specialized by smart pointers to reflect the fact that they are automat...