LLVM: include/llvm/Transforms/IPO/Attributor.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97#ifndef LLVM_TRANSFORMS_IPO_ATTRIBUTOR_H
98#define LLVM_TRANSFORMS_IPO_ATTRIBUTOR_H
99
142
143#include
144#include
145#include
146
147namespace llvm {
148
161
163
164
167
175
176
178
179
180
181
187
188struct ValueAndContext : public std::pair<Value *, const Instruction *> {
189 using Base = std::pair<Value *, const Instruction *>;
193
196};
197
198
199
202
203
204
205
206
207
210 const Value &V, bool ForAnalysisOnly = true);
211
212
213
215
216
217
218
221
222
223
224
226
227
228
229
230
231
232
233
234
235LLVM_ABI std::optional<Value *>
237 const std::optional<Value *> &B, Type *Ty);
238
239
240
244
248
249
253
254
255
259
260
263 "Inconsistent state!");
265 }
266
267
268
270
272 return true;
273
274
275
277 }
278
280 if (R.isUnassigned())
281 return *this;
283 return *this = R;
289 return *this;
291 Size = std::max(Size, R.Size);
294 } else {
297 }
298 return *this;
299 }
300
301
302
303
304
306 if (L.Offset < R.Offset)
307 return true;
308 if (L.Offset == R.Offset)
309 return L.Size < R.Size;
310 return false;
311 }
312
313
314
315
316
317
318
319 static constexpr int64_t Unassigned = std::numeric_limits<int32_t>::min();
320 static constexpr int64_t Unknown = std::numeric_limits<int32_t>::max();
321};
322
324 OS << "[" << R.Offset << ", " << R.Size << "]";
325 return OS;
326}
327
329 return A.Offset == B.Offset && A.Size == B.Size;
330}
331
333
334
338 const DataLayout &DL, RangeTy *RangePtr = nullptr);
339
340
341
342
343
344
345
346
347
348
349
350
354 const AbstractAttribute &QueryingAA, bool &UsedAssumedInformation,
355 bool OnlyExact = false);
356
357
358
359
360
361
362
363
364
365
368 const AbstractAttribute &QueryingAA, bool &UsedAssumedInformation,
369 bool OnlyExact = false);
370
371
372
375 bool &IsKnown);
376
377
378
381 bool &IsKnown);
382
383
384
385
386
387
388
389
390
395 std::function<bool(const Function &F)> GoBackwardsCB = nullptr);
396
397
402 std::function<bool(const Function &F)> GoBackwardsCB = nullptr);
403
404
407
408
416}
417
418template <>
420 : public DenseMapInfoAA::ValueAndContext::Base {
423 return Base::getEmptyKey();
424 }
426 return Base::getTombstoneKey();
427 }
429 return Base::getHashValue(VAC);
430 }
431
434 return Base::isEqual(LHS, RHS);
435 }
436};
437
438template <>
448 return Base::getHashValue(S);
449 }
450
452 return Base::isEqual(LHS, RHS);
453 }
454};
455
456template <>
457struct DenseMapInfo<const AA::InstExclusionSetTy *>
458 : public DenseMapInfo<void *> {
459 using super = DenseMapInfo<void *>;
462 }
465 super::getTombstoneKey());
466 }
468 unsigned H = 0;
469 if (BES)
470 for (const auto *II : *BES)
471 H += DenseMapInfo<const Instruction *>::getHashValue(II);
472 return H;
473 }
477 return true;
478 if (LHS == getEmptyKey() || RHS == getEmptyKey() ||
479 LHS == getTombstoneKey() || RHS == getTombstoneKey())
480 return false;
481 auto SizeLHS = LHS ? LHS->size() : 0;
482 auto SizeRHS = RHS ? RHS->size() : 0;
483 if (SizeLHS != SizeRHS)
484 return false;
485 if (SizeRHS == 0)
486 return true;
488 }
489};
490
491
492
494
495
500
505
511
512
513
515public:
519
520protected:
521
522
524
529
531
532public:
536
541
544 OS << "AADepNode Impl\n";
545 }
547
550};
551
552
553
554
555
556
560
565
566
567
568
571
574
576
577
579
580
582};
583
584
585
586
587
588
589
590
591
592
594
595
597
598
610
611
612
613
615
616
625
626
627
628
633
634
635
640
641
642
647
648
649
654
655
659
660
664
665
667 unsigned ArgNo) {
670 }
671
672
674 unsigned ArgNo) {
678 if (CSArgNo >= 0)
682 }
683
684
685
686
687
698
700 return Enc == RHS.Enc && RHS.CBContext == CBContext;
701 }
703
704
705
706
707
708
709
711 switch (getEncodingBits()) {
712 case ENC_VALUE:
713 case ENC_RETURNED_VALUE:
714 case ENC_FLOATING_FUNCTION:
715 return *getAsValuePtr();
716 case ENC_CALL_SITE_ARGUMENT_USE:
717 return *(getAsUsePtr()->getUser());
718 default:
720 };
721 }
722
723
726
727
728
730 return Arg->getParent();
732 CB->getCalledOperand()->stripPointerCasts());
733 }
735 }
736
737
739
740
741
747 return true;
748 default:
749 return false;
750 }
751 }
752
753
758 return true;
759 default:
760 return false;
761 };
762 }
763
764
773 return nullptr;
774 }
775
776
780 return I;
782 if (!Arg->getParent()->isDeclaration())
783 return &Arg->getParent()->getEntryBlock().front();
785 if (->isDeclaration())
786 return &(F->getEntryBlock().front());
787 return nullptr;
788 }
789
790
798
799
805
806
807
808
809
810
812 return getArgNo( true);
813 }
814
815
816
817
818
819
821 return getArgNo( false);
822 }
823
824
829 break;
832 return AttributeList::FunctionIndex;
835 return AttributeList::ReturnIndex;
837 return getCalleeArgNo() + AttributeList::FirstArgIndex;
840 }
842 "There is no attribute index for a floating or invalid position!");
843 }
844
845
851
852
855 return CB->getAttributes();
857 }
858
859
860 void setAttrList(const AttributeList &AttrList) const {
862 return CB->setAttributes(AttrList);
864 }
865
866
867
871 "Only valid for function/call site positions!");
873 return CB->arg_size();
875 }
876
877
878
882 "Only valid for function/call site positions!");
884 return CB->getArgOperand(ArgNo);
886 }
887
888
890 char EncodingBits = getEncodingBits();
891 if (EncodingBits == ENC_CALL_SITE_ARGUMENT_USE)
893 if (EncodingBits == ENC_FLOATING_FUNCTION)
895
896 Value *V = getAsValuePtr();
897 if (!V)
907 }
908
914 return true;
915 default:
916 return false;
917 }
918 }
919
920
925 return true;
926 default:
927 return false;
928 }
929 }
930
931
934 Result.CBContext = nullptr;
935 return Result;
936 }
937
938
940
941
943
944
945
946
949
950
951
952 operator void *() const { return Enc.getOpaqueValue(); }
953
954private:
955
957 : CBContext(CBContext) {
959 }
960
961
962 explicit IRPosition(Value &AnchorVal, Kind PK,
964 : CBContext(CBContext) {
965 switch (PK) {
967 llvm_unreachable("Cannot create invalid IRP with an anchor value!");
968 break;
970
972 Enc = {&AnchorVal, ENC_FLOATING_FUNCTION};
973 else
974 Enc = {&AnchorVal, ENC_VALUE};
975 break;
978 Enc = {&AnchorVal, ENC_VALUE};
979 break;
982 Enc = {&AnchorVal, ENC_RETURNED_VALUE};
983 break;
985 Enc = {&AnchorVal, ENC_VALUE};
986 break;
989 "Cannot create call site argument IRP with an anchor value!");
990 break;
991 }
993 }
994
995
996
997
998 int getArgNo(bool CallbackCalleeArgIfApplicable) const {
999 if (CallbackCalleeArgIfApplicable)
1001 return Arg->getArgNo();
1007 return cast(U.getUser())->getArgOperandNo(&U);
1008 }
1009 default:
1010 return -1;
1011 }
1012 }
1013
1014
1015
1016
1019 "Use constructor is for call site arguments only!");
1020 Enc = {&U, ENC_CALL_SITE_ARGUMENT_USE};
1022 }
1023
1024
1026
1027
1028
1029 Value *getAsValuePtr() const {
1030 assert(getEncodingBits() != ENC_CALL_SITE_ARGUMENT_USE &&
1031 "Not a value pointer!");
1032 return reinterpret_cast<Value *>(Enc.getPointer());
1033 }
1034
1035
1036
1037 Use *getAsUsePtr() const {
1038 assert(getEncodingBits() == ENC_CALL_SITE_ARGUMENT_USE &&
1039 "Not a value pointer!");
1040 return reinterpret_cast<Use *>(Enc.getPointer());
1041 }
1042
1043
1044
1045 static bool isReturnPosition(char EncodingBits) {
1046 return EncodingBits == ENC_RETURNED_VALUE;
1047 }
1048
1049
1050
1051 bool isReturnPosition() const { return isReturnPosition(getEncodingBits()); }
1052
1053
1054
1055
1056
1057
1058
1059 enum {
1060 ENC_VALUE = 0b00,
1061 ENC_RETURNED_VALUE = 0b01,
1062 ENC_FLOATING_FUNCTION = 0b10,
1063 ENC_CALL_SITE_ARGUMENT_USE = 0b11,
1064 };
1065
1066
1067
1068 static constexpr int NumEncodingBits =
1070 static_assert(NumEncodingBits >= 2, "At least two bits are required!");
1071
1072
1073 PointerIntPair<void *, NumEncodingBits, char> Enc;
1074
1075
1076
1078
1079
1080 char getEncodingBits() const { return Enc.getInt(); }
1081};
1082
1083
1093
1095 return a == b;
1096 }
1097};
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1125 using iterator = decltype(IRPositions)::iterator;
1126
1127public:
1129 iterator begin() { return IRPositions.begin(); }
1130 iterator end() { return IRPositions.end(); }
1131};
1132
1133
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146 template <typename, typename = void>
1148
1149 template
1151 bool RequestCachedOnly = false) {
1152 if (!LegacyPass && !FAM)
1153 return nullptr;
1154 if (FAM) {
1155 if (CachedOnly || RequestCachedOnly)
1156 return FAM->getCachedResult<Analysis>(const_cast<Function &>(F));
1158 }
1160 if (!CachedOnly && !RequestCachedOnly)
1161 return &LegacyPass
1162 ->getAnalysis(
1164 .getResult();
1165 if (auto *P =
1166 LegacyPass
1167 ->getAnalysisIfAvailable())
1168 return &P->getResult();
1169 }
1170 return nullptr;
1171 }
1172
1173
1175 assert(FAM && "Can only be used from the new PM!");
1176 FAM->clear();
1177 }
1178
1180 : FAM(&FAM), CachedOnly(CachedOnly) {}
1182 : LegacyPass(P), CachedOnly(CachedOnly) {}
1184
1185private:
1187 Pass *LegacyPass = nullptr;
1188
1189
1190
1191 bool CachedOnly = false;
1192};
1193
1194template
1196 Analysis, std::void_t> = true;
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1213 bool UseExplorer = true)
1214 : CGSCC(CGSCC), DL(M.getDataLayout()), Allocator(Allocator), AG(AG),
1215 TargetTriple(M.getTargetTriple()) {
1216 if (UseExplorer)
1218
1219 true, true,
1220 true,
1221
1223
1226 },
1227
1230 });
1231 }
1232
1234
1235
1236 for (auto &It : FuncInfoMap)
1237 It.getSecond()->~FunctionInfo();
1238
1240 for (auto *BES : BESets)
1241 BES->~InstExclusionSetTy();
1242 if (Explorer)
1243 Explorer->~MustBeExecutedContextExplorer();
1244 }
1245
1246
1247
1248
1249 template
1251 bool LookThroughConstantExprUses = true) {
1253
1254 for (unsigned Idx = 0; Idx < Worklist.size(); ++Idx) {
1255 Use &U = *Worklist[Idx];
1256
1257
1258 if (LookThroughConstantExprUses && isa(U.getUser())) {
1261 continue;
1262 }
1263
1264 CB(U);
1265 }
1266 }
1267
1268
1270
1271
1273
1274
1276
1277
1278
1280 return getFunctionInfo(F).OpcodeInstMap;
1281 }
1282
1283
1285 return getFunctionInfo(F).RWInsts;
1286 }
1287
1288
1290 return Explorer;
1291 }
1292
1293
1297
1298
1300 FunctionInfo &FI = getFunctionInfo(F);
1301 return FI.IsKernel;
1302 }
1303
1304
1305
1307 FunctionInfo &FI = getFunctionInfo(*Arg.getParent());
1308 return FI.CalledViaMustTail || FI.ContainsMustTailCall;
1309 }
1310
1312 return AssumeOnlyValues.contains(&I);
1313 }
1314
1315
1316
1318
1319
1320 template
1322 bool CachedOnly = false) {
1323 return AG.getAnalysis(F, CachedOnly);
1324 }
1325
1326
1328
1329
1331
1332
1335 auto It = BESets.find(BES);
1336 if (It != BESets.end())
1337 return *It;
1339 bool Success = BESets.insert(UniqueBES).second;
1341 assert(Success && "Expected only new entries to be added");
1342 return UniqueBES;
1343 }
1344
1345
1347
1348
1350
1351
1352
1355
1356
1358
1360
1361private:
1362 struct FunctionInfo {
1364
1365
1366
1368
1369
1370
1372
1373
1374 bool CalledViaMustTail;
1375
1376
1377 bool ContainsMustTailCall;
1378
1379
1380 bool IsKernel;
1381 };
1382
1383
1384 DenseMap<const Function *, FunctionInfo *> FuncInfoMap;
1385
1386
1387 FunctionInfo &getFunctionInfo(const Function &F) {
1388 FunctionInfo *&FI = FuncInfoMap[&F];
1389 if (!FI) {
1390 FI = new (Allocator) FunctionInfo();
1391 initializeInformationCache(F, *FI);
1392 }
1393 return *FI;
1394 }
1395
1396
1397
1399
1400
1401
1402
1403
1404 LLVM_ABI void initializeInformationCache(const Function &F, FunctionInfo &FI);
1405
1406
1407 const DataLayout &DL;
1408
1409
1411
1412
1413 MustBeExecutedContextExplorer *Explorer = nullptr;
1414
1415
1417
1418
1419 SetVector<const Instruction *> AssumeOnlyValues;
1420
1421
1422 DenseSet<const AA::InstExclusionSetTy *> BESets;
1423
1424
1425 AnalysisGetter &AG;
1426
1427
1428 SmallPtrSet<const Function *, 8> InlineableFunctions;
1429
1430
1431 Triple TargetTriple;
1432
1433
1434
1436};
1437
1438
1440
1442
1443
1444
1445
1446
1447
1448
1449
1451
1452
1454
1455
1457
1458
1459
1461
1462
1464
1465
1466
1468
1469
1471 nullptr;
1472
1473
1474
1476 Function &AssumedCallee, unsigned NumAssumedCallees)>
1478
1479
1481
1482
1484
1485
1487
1488
1489
1493
1494
1495
1497
1500};
1501
1502
1504 "How many AAs should be initialized");
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1534
1535
1536
1537
1538
1539
1540
1541
1545
1547
1548
1549
1550
1551
1552
1553
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576 template
1582
1583
1584
1585
1586
1587
1588 template
1591 DepClassTy DepClass, bool ForceUpdate = false,
1592 bool UpdateAfterInit = true) {
1593 if (!shouldPropagateCallBaseContext(IRP))
1595
1597 true)) {
1598 if (ForceUpdate && Phase == AttributorPhase::UPDATE)
1599 updateAA(*AAPtr);
1600 return AAPtr;
1601 }
1602
1603 bool ShouldUpdateAA;
1605 return nullptr;
1606
1608 return nullptr;
1609
1610
1611
1612 auto &AA = AAType::createForPosition(IRP, *this);
1613
1614
1615
1617
1618
1619 if (Phase == AttributorPhase::SEEDING && !shouldSeedAttribute(AA)) {
1620 AA.getState().indicatePessimisticFixpoint();
1621 return &AA;
1622 }
1623
1624
1625
1626 {
1628 return AA.getName().str() +
1629 std::to_string(AA.getIRPosition().getPositionKind());
1630 });
1631 ++InitializationChainLength;
1632 AA.initialize(*this);
1633 --InitializationChainLength;
1634 }
1635
1636 if (!ShouldUpdateAA) {
1637 AA.getState().indicatePessimisticFixpoint();
1638 return &AA;
1639 }
1640
1641
1642
1643 if (UpdateAfterInit) {
1644 AttributorPhase OldPhase = Phase;
1645 Phase = AttributorPhase::UPDATE;
1646
1647 updateAA(AA);
1648
1649 Phase = OldPhase;
1650 }
1651
1652 if (QueryingAA && AA.getState().isValidState())
1654 DepClass);
1655 return &AA;
1656 }
1657
1658 template
1663
1664
1665
1666 template
1670 bool AllowInvalidState = false) {
1671 static_assert(std::is_base_of<AbstractAttribute, AAType>::value,
1672 "Cannot query an attribute with a type not derived from "
1673 "'AbstractAttribute'!");
1674
1675
1677 if (!AAPtr)
1678 return nullptr;
1679
1680 AAType *AA = static_cast<AAType *>(AAPtr);
1681
1682
1684 AA->getState().isValidState())
1686 DepClass);
1687
1688
1689 if (!AllowInvalidState && ->getState().isValidState())
1690 return nullptr;
1691 return AA;
1692 }
1693
1694
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1711
1712
1713
1714
1715
1716
1717
1718
1720 static_assert(std::is_base_of<AbstractAttribute, AAType>::value,
1721 "Cannot register an attribute with a type not derived from "
1722 "'AbstractAttribute'!");
1723
1724
1727
1728 assert(!AAPtr && "Attribute already in map!");
1729 AAPtr = &AA;
1730
1731
1732 if (Phase == AttributorPhase::SEEDING || Phase == AttributorPhase::UPDATE)
1733 DG.SyntheticRoot.Deps.insert(
1735
1736 return AA;
1737 }
1738
1739
1741
1742
1743 bool isModulePass() const { return Configuration.IsModulePass; }
1744
1745
1746
1749 unsigned NumAssumedCallees) {
1750 return Configuration.IndirectCalleeSpecializationCallback
1751 ? Configuration.IndirectCalleeSpecializationCallback(
1752 *this, AA, CB, Callee, NumAssumedCallees)
1753 : true;
1754 }
1755
1756
1757
1759
1760
1763 return Functions.empty() || Functions.count(Fn);
1764 }
1765
1767
1768
1769 if (Phase == AttributorPhase::MANIFEST || Phase == AttributorPhase::CLEANUP)
1770 return false;
1771
1773
1775
1776 if (!AssociatedFn && AAType::requiresCalleeForCallBase())
1777 return false;
1778
1779
1780 if (AAType::requiresNonAsmForCallBase() &&
1782 return false;
1783 }
1784
1785
1786 if (AAType::requiresCallersForArgOrFunction())
1790 return false;
1791
1792 if (!AAType::isValidIRPositionForUpdate(*this, IRP))
1793 return false;
1794
1795
1796
1799 }
1800
1801 template
1803 if (!AAType::isValidIRPositionForInit(*this, IRP))
1804 return false;
1805
1806 if (Configuration.Allowed && !Configuration.Allowed->count(&AAType::ID))
1807 return false;
1808
1809
1811 if (AnchorFn && (AnchorFn->hasFnAttribute(Attribute::Naked) ||
1813 return false;
1814
1815
1817 return false;
1818
1820
1821 return !AAType::hasTrivialInitializer() || ShouldUpdateAA;
1822 }
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1835
1836
1837
1838
1839
1841 return F.hasExactDefinition() || InfoCache.InlineableFunctions.count(&F) ||
1842 (Configuration.IPOAmendableCB && Configuration.IPOAmendableCB(F));
1843 }
1844
1845
1846
1847
1848
1850 assert(F.hasLocalLinkage() &&
1851 "Only local linkage is assumed dead initially.");
1852
1853 if (Configuration.DefaultInitializeLiveInternals)
1855 if (Configuration.InitializationCallback)
1856 Configuration.InitializationCallback(*this, F);
1857 }
1858
1859
1860
1862 Value *&V = ToBeChangedUses[&U];
1863 if (V && (V->stripPointerCasts() == NV.stripPointerCasts() ||
1865 return false;
1867 "Use was registered twice for replacement with different values!");
1868 V = &NV;
1869 return true;
1870 }
1871
1872
1873
1874
1876 bool ChangeDroppable = true) {
1881 }
1883 auto &Entry = ToBeChangedValues[&V];
1885 if (CurNV && (CurNV->stripPointerCasts() == NV.stripPointerCasts() ||
1887 return false;
1889 "Value replacement was registered twice with different values!");
1890 Entry = {&NV, ChangeDroppable};
1891 return true;
1892 }
1893
1894
1895
1897 ToBeChangedToUnreachableInsts.insert(I);
1898 }
1899
1900
1901
1902
1904 InvokeWithDeadSuccessor.insert(&II);
1905 }
1906
1907
1908
1910
1911
1912
1914
1915
1916
1918 ManifestAddedBlocks.insert(&BB);
1919 }
1920
1921
1923 if (Configuration.DeleteFns)
1924 ToBeDeletedFunctions.insert(&F);
1925 }
1926
1927
1928
1932
1933
1934
1935
1936
1937
1940 bool IgnoreSubsumingPositions = false,
1942
1943
1944
1945
1946
1947
1948
1949
1950
1954 bool IgnoreSubsumingPositions = false);
1955
1956
1961
1962
1963
1966 bool ForceReplace = false);
1967
1968private:
1969
1970
1971
1972
1973
1974 template <Attribute::AttrKind AK, typename AAType>
1976 bool SkipHasAttrCheck = false);
1977
1978
1979 template
1983 CB);
1984
1985
1987
1988public:
1989
1990
1991 LLVM_ABI std::optional<Constant *>
1993 bool &UsedAssumedInformation);
1996 bool &UsedAssumedInformation) {
1998 }
1999
2000
2001
2004 bool &UsedAssumedInformation,
2007 }
2010 bool &UsedAssumedInformation,
2013 UsedAssumedInformation, S);
2014 }
2015
2016
2017
2018
2019
2020 LLVM_ABI std::optional<Value *>
2023
2024
2025
2026
2027
2028
2029
2034 bool RecurseForSelectAndPHI = true);
2035
2036
2037
2038
2039
2040
2045 SimplificationCallbacks[IRP].emplace_back(CB);
2046 }
2047
2048
2050 return SimplificationCallbacks.count(IRP);
2051 }
2052
2053
2054
2055
2057 std::function<std::optional<Constant *>(
2062 GlobalVariableSimplificationCallbacks[&GV].emplace_back(CB);
2063 }
2064
2065
2067 return GlobalVariableSimplificationCallbacks.count(&GV);
2068 }
2069
2070
2071
2072
2073 std::optional<Constant *>
2076 bool &UsedAssumedInformation) {
2077 assert(GlobalVariableSimplificationCallbacks.contains(&GV));
2078 for (auto &CB : GlobalVariableSimplificationCallbacks.lookup(&GV)) {
2079 auto SimplifiedGV = CB(GV, AA, UsedAssumedInformation);
2080
2081 assert(SimplifiedGV.has_value() && "SimplifiedGV has not value");
2082 return *SimplifiedGV;
2083 }
2085 }
2086
2091 VirtualUseCallbacks[&V].emplace_back(CB);
2092 }
2093
2094private:
2095
2097 SimplificationCallbacks;
2098
2099
2100
2103 GlobalVariableSimplificationCallbacks;
2104
2106 VirtualUseCallbacks;
2107
2108public:
2109
2110 LLVM_ABI std::optional<Value *>
2113 bool &UsedAssumedInformation);
2114
2115
2116
2117
2120 bool &UsedAssumedInformation,
2121 bool CheckBBLivenessOnly = false,
2123
2124
2125
2126
2130 bool &UsedAssumedInformation,
2131 bool CheckBBLivenessOnly = false,
2133 bool CheckForDeadStore = false);
2134
2135
2136
2137
2139 const AAIsDead *FnLivenessAA,
2140 bool &UsedAssumedInformation,
2141 bool CheckBBLivenessOnly = false,
2143
2144
2145
2146
2149 const AAIsDead *FnLivenessAA,
2150 bool &UsedAssumedInformation,
2151 bool CheckBBLivenessOnly = false,
2153
2154
2155
2156
2159 const AAIsDead *FnLivenessAA,
2161
2162
2163
2164
2165
2166
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2183 bool CheckBBLivenessOnly = false,
2185 bool IgnoreDroppableUses = true,
2186 function_ref<bool(const Use &OldU, const Use &NewU)> EquivalentUseCB =
2187 nullptr);
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200 template <typename RemarkKind, typename RemarkCallBack>
2202 RemarkCallBack &&RemarkCB) const {
2203 if (!Configuration.OREGetter)
2204 return;
2205
2207 auto &ORE = Configuration.OREGetter(F);
2208
2210 ORE.emit([&]() {
2211 return RemarkCB(RemarkKind(Configuration.PassName, RemarkName, I))
2212 << " [" << RemarkName << "]";
2213 });
2214 else
2215 ORE.emit([&]() {
2216 return RemarkCB(RemarkKind(Configuration.PassName, RemarkName, I));
2217 });
2218 }
2219
2220
2221 template <typename RemarkKind, typename RemarkCallBack>
2223 RemarkCallBack &&RemarkCB) const {
2224 if (!Configuration.OREGetter)
2225 return;
2226
2227 auto &ORE = Configuration.OREGetter(F);
2228
2230 ORE.emit([&]() {
2231 return RemarkCB(RemarkKind(Configuration.PassName, RemarkName, F))
2232 << " [" << RemarkName << "]";
2233 });
2234 else
2235 ORE.emit([&]() {
2236 return RemarkCB(RemarkKind(Configuration.PassName, RemarkName, F));
2237 });
2238 }
2239
2240
2241
2242
2243
2244
2245 struct ArgumentReplacementInfo {
2246
2247
2248
2249
2250
2251
2252
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2267 std::function<void(const ArgumentReplacementInfo &, AbstractCallSite,
2269
2270
2271
2272
2278 return ReplacementTypes;
2279 }
2280
2281
2282
2283 private:
2284
2285
2286
2291 : A(A), ReplacedFn(*Arg.getParent()), ReplacedArg(Arg),
2292 ReplacementTypes(ReplacementTypes),
2293 CalleeRepairCB(std::move(CalleeRepairCB)),
2294 ACSRepairCB(std::move(ACSRepairCB)) {}
2295
2296
2298
2299
2301
2302
2303 const Argument &ReplacedArg;
2304
2305
2307
2308
2310
2311
2313
2314
2316 };
2317
2318
2319
2320
2321
2322
2323
2324
2328
2329
2330
2331
2332
2333
2334
2335
2336
2341
2342
2343
2344
2345
2346
2347
2348
2351 bool RequireAllCallSites,
2352 bool &UsedAssumedInformation);
2353
2354
2355
2356
2357
2358
2359
2360
2363 bool RequireAllCallSites,
2365 bool &UsedAssumedInformation,
2366 bool CheckPotentiallyDead = false);
2367
2368
2369
2370
2371
2376 bool RecurseForSelectAndPHI = true);
2377
2378
2379
2380
2381
2382
2387 bool &UsedAssumedInformation,
2388 bool CheckBBLivenessOnly = false,
2389 bool CheckPotentiallyDead = false);
2390
2391
2392
2393
2394
2398 bool &UsedAssumedInformation,
2399 bool CheckBBLivenessOnly = false,
2400 bool CheckPotentiallyDead = false);
2401
2402
2403
2404
2407 bool &UsedAssumedInformation,
2408 bool CheckBBLivenessOnly = false,
2409 bool CheckPotentiallyDead = false) {
2411 Pred, QueryingAA,
2412 {(unsigned)Instruction::Invoke, (unsigned)Instruction::CallBr,
2413 (unsigned)Instruction::Call},
2414 UsedAssumedInformation, CheckBBLivenessOnly, CheckPotentiallyDead);
2415 }
2416
2417
2418
2419
2420
2421
2425 bool &UsedAssumedInformation);
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2442
2443
2444
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2461 bool Force = false);
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2479
2480
2482
2483
2485
2487 return CGModifiedFunctions;
2488 }
2489
2490private:
2491
2492
2493
2494
2495
2496
2497 void runTillFixpoint();
2498
2499
2501
2502
2503
2504
2506
2507
2508
2509 void identifyDeadInternalFunctions();
2510
2511
2512
2514
2515
2516
2517 void rememberDependences();
2518
2519
2520 LLVM_ABI bool shouldPropagateCallBaseContext(const IRPosition &IRP);
2521
2522
2523
2524
2527
2528
2529
2531
2532
2533
2534
2535
2536 using AAMapKeyTy = std::pair<const char *, IRPosition>;
2538
2539
2540
2542 ArgumentReplacementMap;
2543
2544
2546
2547
2549
2550
2552
2553
2554
2556
2557
2558
2559 struct DepInfo {
2563 };
2564
2565
2566
2567
2568
2569
2570
2571
2572 using DependenceVector = SmallVector<DepInfo, 8>;
2574
2575
2576 DenseSet<const Function *> VisitedFunctions;
2577
2578
2579
2580 SmallMapVector<Use *, Value *, 32> ToBeChangedUses;
2581
2582
2583
2584 SmallMapVector<Value *, PointerIntPair<Value *, 1, bool>, 32>
2585 ToBeChangedValues;
2586
2587
2588 SmallSetVector<WeakVH, 16> ToBeChangedToUnreachableInsts;
2589
2590
2591 SmallSetVector<WeakVH, 16> InvokeWithDeadSuccessor;
2592
2593
2594
2595 enum class AttributorPhase {
2596 SEEDING,
2597 UPDATE,
2598 MANIFEST,
2599 CLEANUP,
2600 } Phase = AttributorPhase::SEEDING;
2601
2602
2603 unsigned InitializationChainLength = 0;
2604
2605
2606
2607
2608 SmallPtrSet<BasicBlock *, 8> ManifestAddedBlocks;
2609 SmallSetVector<Function *, 8> ToBeDeletedFunctions;
2610 SmallSetVector<BasicBlock *, 8> ToBeDeletedBlocks;
2611 SmallSetVector<WeakVH, 8> ToBeDeletedInsts;
2612
2613
2614
2615
2616 SmallSetVector<AbstractAttribute *, 16> QueryAAsAwaitingUpdate;
2617
2618
2619 const AttributorConfig Configuration;
2620
2621 friend AADepGraph;
2622 friend AttributorCallGraph;
2623};
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2644
2645
2646
2648
2649
2650
2652
2653
2654
2655
2656
2657
2658
2660
2661
2662
2663
2664
2665
2666
2668};
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680template <typename base_ty, base_ty BestState, base_ty WorstState>
2683
2686
2687
2692
2693
2698
2699
2700
2702
2703
2705
2706
2711
2712
2717
2718
2720
2721
2723
2724
2725 bool
2730
2731
2732 bool
2734 return !(*this == R);
2735 }
2736
2737
2738
2739
2743
2744
2745
2746
2750
2752 joinOR(R.getAssumed(), R.getKnown());
2753 }
2754
2756 joinAND(R.getAssumed(), R.getKnown());
2757 }
2758
2759protected:
2760
2762
2763
2765
2766
2768
2769
2771
2772
2774
2775
2777};
2778
2779
2780template <typename base_ty = uint32_t, base_ty BestState = ~base_ty(0),
2781 base_ty WorstState = 0>
2788
2789
2791 return (this->Known & BitsEncoding) == BitsEncoding;
2792 }
2793
2794
2796 return (this->Assumed & BitsEncoding) == BitsEncoding;
2797 }
2798
2799
2801
2803 this->Known |= Bits;
2804 return *this;
2805 }
2806
2807
2811
2812
2814 this->Known = (this->Known & ~BitsEncoding);
2815 return *this;
2816 }
2817
2818
2820
2822 return *this;
2823 }
2824
2825private:
2826 void handleNewAssumedValue(base_t Value) override {
2828 }
2829 void handleNewKnownValue(base_t Value) override { addKnownBits(Value); }
2830 void joinOR(base_t AssumedValue, base_t KnownValue) override {
2831 this->Known |= KnownValue;
2832 this->Assumed |= AssumedValue;
2833 }
2834 void joinAND(base_t AssumedValue, base_t KnownValue) override {
2835 this->Known &= KnownValue;
2836 this->Assumed &= AssumedValue;
2837 }
2838};
2839
2840
2841
2842template <typename base_ty = uint32_t, base_ty BestState = ~base_ty(0),
2843 base_ty WorstState = 0>
2848
2851
2852
2854 static constexpr base_t
2858
2859
2861
2863 return *this;
2864 }
2865
2866
2868
2871 return *this;
2872 }
2873
2874private:
2875 void handleNewAssumedValue(base_t Value) override {
2877 }
2879 void joinOR(base_t AssumedValue, base_t KnownValue) override {
2880 this->Known = std::max(this->Known, KnownValue);
2881 this->Assumed = std::max(this->Assumed, AssumedValue);
2882 }
2883 void joinAND(base_t AssumedValue, base_t KnownValue) override {
2884 this->Known = std::min(this->Known, KnownValue);
2885 this->Assumed = std::min(this->Assumed, AssumedValue);
2886 }
2887};
2888
2889
2890
2891template <typename base_ty = uint32_t>
2894
2895
2897
2899 return *this;
2900 }
2901
2902
2904
2907 return *this;
2908 }
2909
2910private:
2911 void handleNewAssumedValue(base_t Value) override {
2913 }
2915 void joinOR(base_t AssumedValue, base_t KnownValue) override {
2916 this->Assumed = std::min(this->Assumed, KnownValue);
2917 this->Assumed = std::min(this->Assumed, AssumedValue);
2918 }
2919 void joinAND(base_t AssumedValue, base_t KnownValue) override {
2920 this->Assumed = std::max(this->Assumed, KnownValue);
2921 this->Assumed = std::max(this->Assumed, AssumedValue);
2922 }
2923};
2924
2925
2929
2932
2933
2935
2936
2941
2942
2944
2945
2947
2948private:
2949 void handleNewAssumedValue(base_t Value) override {
2952 }
2953 void handleNewKnownValue(base_t Value) override {
2954 if (Value)
2956 }
2957 void joinOR(base_t AssumedValue, base_t KnownValue) override {
2958 Known |= KnownValue;
2959 Assumed |= AssumedValue;
2960 }
2961 void joinAND(base_t AssumedValue, base_t KnownValue) override {
2962 Known &= KnownValue;
2963 Assumed &= AssumedValue;
2964 }
2965};
2966
2967
2969
2970
2972
2973
2975
2976
2978
2982
2986
2987
2989 return ConstantRange::getFull(BitWidth);
2990 }
2991
2992
2994 return ConstantRange::getEmpty(BitWidth);
2995 }
2999
3000
3002
3003
3007
3008
3010
3011
3016
3017
3022
3023
3025
3026
3028
3029
3034
3035
3039
3040
3045
3046
3050
3051
3055
3056
3057
3058
3060
3061
3063 return *this;
3064 }
3065
3067
3068
3069 Known = Known.unionWith(R.getKnown());
3071 return *this;
3072 }
3073};
3074
3075
3076
3077
3078
3079
3081
3082
3084
3086
3087
3089 : Universal(false), Set(Assumptions) {}
3090
3092 : Universal(Universal), Set(Assumptions) {}
3093
3095
3097
3098 bool empty() const { return Set.empty() && !Universal; }
3099
3100
3101
3103 bool IsUniversal = Universal;
3104 unsigned Size = Set.size();
3105
3106
3107 if (RHS.isUniversal())
3108 return false;
3109
3110
3111 if (Universal)
3112 Set = RHS.getSet();
3113 else
3115
3116 Universal &= RHS.isUniversal();
3117 return IsUniversal != Universal || Size != Set.size();
3118 }
3119
3120
3121
3123 bool IsUniversal = Universal;
3124 unsigned Size = Set.size();
3125
3126
3127 if (.isUniversal() && !Universal)
3129
3130 Universal |= RHS.isUniversal();
3131 return IsUniversal != Universal || Size != Set.size();
3132 }
3133
3134 private:
3135
3136 bool Universal;
3137
3138
3140 };
3141
3143
3144
3145
3147 : Known(Known), Assumed(true), IsAtFixedpoint(false) {}
3148
3149
3150 bool isValidState() const override { return !Assumed.empty(); }
3151
3152
3153 bool isAtFixpoint() const override { return IsAtFixedpoint; }
3154
3155
3157 IsAtFixedpoint = true;
3158 Known = Assumed;
3160 }
3161
3162
3164 IsAtFixedpoint = true;
3165 Assumed = Known;
3167 }
3168
3169
3171
3172
3174
3175
3177 return Assumed.getSet().contains(Elem) || Known.getSet().contains(Elem);
3178 }
3179
3180
3181
3183 bool IsUniversal = Assumed.isUniversal();
3184 unsigned SizeBefore = Assumed.getSet().size();
3185
3186
3187
3188 Assumed.getIntersection(RHS);
3189 Assumed.getUnion(Known);
3190
3191 return SizeBefore != Assumed.getSet().size() ||
3192 IsUniversal != Assumed.isUniversal();
3193 }
3194
3195
3196
3198
3199private:
3200
3201 SetContents Known;
3202
3203
3204 SetContents Assumed;
3205
3206 bool IsAtFixedpoint;
3207};
3208
3209
3210template <typename StateTy, typename BaseType, class... Ts>
3212
3214
3217
3218
3220
3221
3223};
3224
3225
3226template <Attribute::AttrKind AK, typename BaseType, typename AAType>
3229
3230
3231
3232
3234
3235
3237
3238
3239
3241
3242
3243
3245
3248 bool IgnoreSubsumingPositions = false) {
3250 return true;
3251 if (AAType::isImpliedByPoison() &&
3253 return true;
3254 return A.hasAttr(IRP, {ImpliedAttributeKind}, IgnoreSubsumingPositions,
3255 ImpliedAttributeKind);
3256 }
3257
3258
3260 if (isa(this->getIRPosition().getAssociatedValue()))
3264 if (DeducedAttrs.empty())
3266 return A.manifestAttrs(this->getIRPosition(), DeducedAttrs);
3267 }
3268
3269
3271
3272
3277};
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3324
3326
3327
3329
3330
3332
3333
3334
3335
3336
3337
3338
3340
3341
3342
3344
3345
3346
3348
3349
3351
3352
3353
3355
3356
3360
3361
3365 assert((!IsFnInterface || AssociatedFn) &&
3366 "Function interface without a function?");
3367
3368
3369
3370
3371
3372
3373
3374
3375 return !IsFnInterface || A.isFunctionIPOAmendable(*AssociatedFn);
3376 }
3377
3378
3379
3380
3381
3382
3383
3384
3385
3387
3388
3389
3390
3391
3392
3393
3394 virtual bool isQueryAA() const { return false; }
3395
3396
3399
3400
3403
3404
3405
3408 virtual void printWithDeps(raw_ostream &OS) const;
3410
3411
3413
3414
3416
3417
3419
3420
3421
3423
3424protected:
3425
3426
3427
3428
3429
3430
3432
3433
3434
3435
3436
3440
3441
3442
3443
3444
3445
3447
3448
3449
3450
3451
3452
3453
3454
3456};
3457
3458
3459
3460
3466template <typename base_ty, base_ty BestState, base_ty WorstState>
3474 const IntegerRangeState &State);
3475
3476
3485
3486
3487
3491
3492
3493
3500
3501
3502
3503
3504template
3506 auto Assumed = S.getAssumed();
3507 S ^= R;
3510}
3511
3512
3513
3514
3515
3517 : public IRAttribute<Attribute::NoUnwind,
3518 StateWrapper<BooleanState, AbstractAttribute>,
3519 AANoUnwind> {
3521
3522
3524
3525
3527
3528
3531
3532
3534
3535
3537
3538
3540 return (AA->getIdAddr() == &ID);
3541 }
3542
3543
3545};
3546
3549 StateWrapper<BooleanState, AbstractAttribute>,
3550 AANoSync> {
3552
3555 bool IgnoreSubsumingPositions = false) {
3556
3557 assert(ImpliedAttributeKind == Attribute::NoSync);
3558 if (A.hasAttr(IRP, {Attribute::NoSync}, IgnoreSubsumingPositions,
3559 Attribute::NoSync))
3560 return true;
3561
3562
3563
3564
3566 if ( || F->isConvergent())
3567 return false;
3568
3570 A.getAttrs(IRP, {Attribute::Memory}, Attrs, IgnoreSubsumingPositions);
3571
3573 for (const Attribute &Attr : Attrs)
3574 ME &= Attr.getMemoryEffects();
3575
3577 return false;
3578
3579 A.manifestAttrs(IRP, Attribute::get(F->getContext(), Attribute::NoSync));
3580 return true;
3581 }
3582
3583
3587 return false;
3588 return IRAttribute::isValidIRPositionForInit(A, IRP);
3589 }
3590
3591
3593
3594
3596
3597
3598
3599
3601
3602
3604
3605
3606
3607
3608
3609
3611 bool ExecutedAligned);
3612
3613
3616
3617
3619
3620
3622
3623
3625 return (AA->getIdAddr() == &ID);
3626 }
3627
3628
3630};
3631
3632
3634 : public IRAttribute<Attribute::MustProgress,
3635 StateWrapper<BooleanState, AbstractAttribute>,
3636 AAMustProgress> {
3638
3641 bool IgnoreSubsumingPositions = false) {
3642
3643 assert(ImpliedAttributeKind == Attribute::MustProgress);
3644 return A.hasAttr(IRP, {Attribute::MustProgress, Attribute::WillReturn},
3645 IgnoreSubsumingPositions, Attribute::MustProgress);
3646 }
3647
3648
3650
3651
3653
3654
3657
3658
3660
3661
3663
3664
3665
3667 return (AA->getIdAddr() == &ID);
3668 }
3669
3670
3672};
3673
3674
3676 : public IRAttribute<Attribute::NonNull,
3677 StateWrapper<BooleanState, AbstractAttribute>,
3678 AANonNull> {
3680
3681
3683
3684
3685
3686
3688
3689
3692 return false;
3693 return IRAttribute::isValidIRPositionForInit(A, IRP);
3694 }
3695
3696
3699 bool IgnoreSubsumingPositions = false);
3700
3701
3703
3704
3706
3707
3710
3711
3713
3714
3716
3717
3719 return (AA->getIdAddr() == &ID);
3720 }
3721
3722
3724};
3725
3726
3728 : public IRAttribute<Attribute::NoRecurse,
3729 StateWrapper<BooleanState, AbstractAttribute>,
3730 AANoRecurse> {
3732
3733
3735
3736
3738
3739
3742
3743
3745
3746
3748
3749
3751 return (AA->getIdAddr() == &ID);
3752 }
3753
3754
3756};
3757
3758
3760 : public IRAttribute<Attribute::WillReturn,
3761 StateWrapper<BooleanState, AbstractAttribute>,
3762 AAWillReturn> {
3764
3767 bool IgnoreSubsumingPositions = false) {
3768
3769 assert(ImpliedAttributeKind == Attribute::WillReturn);
3771 IgnoreSubsumingPositions))
3772 return true;
3774 return false;
3776 Attribute::WillReturn));
3777 return true;
3778 }
3779
3780
3783
3784
3785 if (.hasAttr(IRP, {Attribute::MustProgress}))
3786 return false;
3787
3789 A.getAttrs(IRP, {Attribute::Memory}, Attrs,
3790 false);
3791
3793 for (const Attribute &Attr : Attrs)
3794 ME &= Attr.getMemoryEffects();
3796 }
3797
3798
3800
3801
3803
3804
3807
3808
3810
3811
3813
3814
3816 return (AA->getIdAddr() == &ID);
3817 }
3818
3819
3821};
3822
3823
3825 : public StateWrapper<BooleanState, AbstractAttribute> {
3828
3829
3831
3832
3834
3835
3837
3838
3840
3841
3844
3845
3847
3848
3850
3851
3852
3854 return (AA->getIdAddr() == &ID);
3855 }
3856
3857
3859};
3860
3861
3863 : public StateWrapper<BooleanState, AbstractAttribute> {
3866
3867
3868
3869
3873
3874
3877
3878
3880
3881
3883
3884
3885
3887 return (AA->getIdAddr() == &ID);
3888 }
3889
3890
3892};
3893
3894
3896 : public IRAttribute<Attribute::NoAlias,
3897 StateWrapper<BooleanState, AbstractAttribute>,
3898 AANoAlias> {
3900
3901
3904 return false;
3905 return IRAttribute::isValidIRPositionForInit(A, IRP);
3906 }
3907
3908
3911 bool IgnoreSubsumingPositions = false);
3912
3913
3915
3916
3918
3919
3921
3922
3925
3926
3928
3929
3931
3932
3934 return (AA->getIdAddr() == &ID);
3935 }
3936
3937
3939};
3940
3941
3944 StateWrapper<BooleanState, AbstractAttribute>,
3945 AANoFree> {
3947
3948
3951 bool IgnoreSubsumingPositions = false) {
3952
3953 assert(ImpliedAttributeKind == Attribute::NoFree);
3954 return A.hasAttr(
3955 IRP, {Attribute::ReadNone, Attribute::ReadOnly, Attribute::NoFree},
3956 IgnoreSubsumingPositions, Attribute::NoFree);
3957 }
3958
3959
3963 return false;
3964 return IRAttribute::isValidIRPositionForInit(A, IRP);
3965 }
3966
3967
3969
3970
3972
3973
3976
3977
3979
3980
3982
3983
3985 return (AA->getIdAddr() == &ID);
3986 }
3987
3988
3990};
3991
3992
3994 : public IRAttribute<Attribute::NoReturn,
3995 StateWrapper<BooleanState, AbstractAttribute>,
3996 AANoReturn> {
3998
3999
4001
4002
4004
4005
4008
4009
4011
4012
4014
4015
4017 return (AA->getIdAddr() == &ID);
4018 }
4019
4020
4022};
4023
4024
4026 : public StateWrapper<BitIntegerState<uint8_t, 3, 0>, AbstractAttribute> {
4029
4030
4037
4038
4039 enum {
4042
4044 };
4045 static_assert(IS_DEAD == getBestState(), "Unexpected BEST_STATE value");
4046
4047protected:
4048
4049
4050
4051
4053
4054
4056
4057
4059
4060
4062
4063
4065
4066
4067
4068
4069
4071
4072
4073
4077 "Instruction must be in the same anchor scope function.");
4078
4080 return true;
4081 }
4082
4083 return false;
4084 }
4085
4086public:
4087
4090
4091
4095
4096
4098
4099
4100
4102 return false;
4103 }
4104
4105
4107
4108
4110
4111
4113 return (AA->getIdAddr() == &ID);
4114 }
4115
4116
4118
4120};
4121
4122
4124
4127
4128
4137
4138
4140
4141
4142
4143
4144
4145
4146
4148
4149
4150
4151
4152
4153
4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168 void computeKnownDerefBytesFromAccessedMap() {
4171 if (KnownBytes < Access.first)
4172 break;
4173 KnownBytes = std::max(KnownBytes, Access.first + (int64_t)Access.second);
4174 }
4175
4177 }
4178
4179
4181
4182
4184
4185
4189 }
4190
4191
4196 }
4197
4198
4203 }
4204
4205
4206 void takeKnownDerefBytesMaximum(uint64_t Bytes) {
4208
4209
4210 computeKnownDerefBytesFromAccessedMap();
4211 }
4212
4213
4214 void takeAssumedDerefBytesMinimum(uint64_t Bytes) {
4216 }
4217
4218
4219 void addAccessedBytes(int64_t Offset, uint64_t Size) {
4221 AccessedBytes = std::max(AccessedBytes, Size);
4222
4223
4224 computeKnownDerefBytesFromAccessedMap();
4225 }
4226
4227
4228 bool operator==(const DerefState &R) const {
4230 this->GlobalState == R.GlobalState;
4231 }
4232
4233
4234 bool operator!=(const DerefState &R) const { return !(*this == R); }
4235
4236
4237 DerefState operator^=(const DerefState &R) {
4239 GlobalState ^= R.GlobalState;
4240 return *this;
4241 }
4242
4243
4244 DerefState operator+=(const DerefState &R) {
4246 GlobalState += R.GlobalState;
4247 return *this;
4248 }
4249
4250
4251 DerefState operator&=(const DerefState &R) {
4253 GlobalState &= R.GlobalState;
4254 return *this;
4255 }
4256
4257
4258 DerefState operator|=(const DerefState &R) {
4260 GlobalState |= R.GlobalState;
4261 return *this;
4262 }
4263};
4264
4265
4267 : public IRAttribute<Attribute::Dereferenceable,
4268 StateWrapper<DerefState, AbstractAttribute>,
4269 AADereferenceable> {
4271
4272
4275 return false;
4276 return IRAttribute::isValidIRPositionForInit(A, IRP);
4277 }
4278
4279
4280
4282
4283
4284
4286
4287
4291
4292
4296
4297
4300
4301
4303
4304
4306
4307
4308
4310 return (AA->getIdAddr() == &ID);
4311 }
4312
4313
4315};
4316
4319
4321 : public IRAttribute<Attribute::Alignment,
4322 StateWrapper<AAAlignmentStateType, AbstractAttribute>,
4323 AAAlign> {
4325
4326
4329 return false;
4330 return IRAttribute::isValidIRPositionForInit(A, IRP);
4331 }
4332
4333
4335
4336
4338
4339
4341
4342
4344
4345
4347 return (AA->getIdAddr() == &ID);
4348 }
4349
4350
4353
4354
4356};
4357
4358
4359
4360
4361
4365
4366
4367
4368
4369
4371
4372
4373
4374
4375
4377
4378
4381
4382
4384
4385
4387
4388
4389
4391 return (AA->getIdAddr() == &ID);
4392 }
4393
4394
4396};
4397
4398
4401 Attribute::Captures,
4402 StateWrapper<BitIntegerState<uint16_t, 7, 0>, AbstractAttribute>,
4403 AANoCapture> {
4405
4406
4409 bool IgnoreSubsumingPositions = false);
4410
4411
4412
4416
4417
4420 return false;
4421 return IRAttribute::isValidIRPositionForInit(A, IRP);
4422 }
4423
4424
4425
4426 enum {
4430
4431
4432
4434
4435
4436
4439 };
4440
4441
4442
4444
4445
4446
4448
4449
4450
4454
4455
4456
4460
4461
4464
4465
4467
4468
4470
4471
4473 return (AA->getIdAddr() == &ID);
4474 }
4475
4476
4478};
4479
4481
4483
4490
4491
4494 DS.indicatePessimisticFixpoint();
4495 return DS;
4496 }
4501
4502
4504
4505
4507
4508
4511
4512
4514 return BS.indicatePessimisticFixpoint();
4515 }
4516
4517
4519 return BS.indicateOptimisticFixpoint();
4520 }
4521
4522
4524 BS ^= VS.BS;
4526 return *this;
4527 }
4528
4531 return false;
4533 return true;
4535 }
4536
4537protected:
4538
4540
4541
4543
4544
4546
4547
4548
4549
4550
4552};
4553
4554
4556 : public StateWrapper<ValueSimplifyStateType, AbstractAttribute, Type *> {
4560
4561
4564
4565
4567
4568
4570
4571
4572
4574 return (AA->getIdAddr() == &ID);
4575 }
4576
4577
4579
4580private:
4581
4582
4583
4584
4585
4586 virtual std::optional<Value *>
4587 getAssumedSimplifiedValue(Attributor &A) const = 0;
4588
4590};
4591
4595
4596
4598
4599
4600
4602
4603
4606
4607
4609
4610
4612
4613
4615 return (AA->getIdAddr() == &ID);
4616 }
4617
4618
4620};
4621
4622
4623
4624
4625
4626
4627
4628
4629
4630
4631
4633 : public StateWrapper<BooleanState, AbstractAttribute> {
4636
4637
4640 return false;
4642 }
4643
4644
4646
4647
4649
4650
4652
4653
4654
4655
4657
4658
4661
4662
4664
4665
4667
4668
4669
4671 return (AA->getIdAddr() == &ID);
4672 }
4673
4674
4676};
4677
4678
4679
4682 Attribute::None,
4683 StateWrapper<BitIntegerState<uint8_t, 3>, AbstractAttribute>,
4684 AAMemoryBehavior> {
4686
4687
4689
4690
4693 return false;
4694 return IRAttribute::isValidIRPositionForInit(A, IRP);
4695 }
4696
4697
4698
4699 enum {
4703
4705 };
4707
4708
4709
4711
4712
4713
4715
4716
4717
4719
4720
4721
4723
4724
4725
4727
4728
4729
4731
4732
4735
4736
4738
4739
4741
4742
4743
4745 return (AA->getIdAddr() == &ID);
4746 }
4747
4748
4750};
4751
4752
4753
4756 Attribute::None,
4757 StateWrapper<BitIntegerState<uint32_t, 511>, AbstractAttribute>,
4758 AAMemoryLocation> {
4760
4762
4763
4765
4766
4768
4769
4773 return false;
4774 return IRAttribute::isValidIRPositionForInit(A, IRP);
4775 }
4776
4777
4778
4779 enum {
4793
4794
4796
4798 };
4800
4801
4802
4804
4805
4806
4810
4811
4812
4816
4817
4818
4822
4823
4824
4828
4829
4830
4834
4835
4836
4840
4841
4842
4846
4847
4848
4849
4854
4855
4856
4857
4862
4863
4864
4866
4867
4868
4872
4873
4874
4878
4879
4880
4881
4882
4883
4889
4890
4892
4893
4900
4901
4902
4903
4904
4905
4909 Pred,
4911
4912
4915
4916
4920
4921
4923
4924
4926
4927
4928
4930 return (AA->getIdAddr() == &ID);
4931 }
4932
4933
4935};
4936
4937
4939 : public StateWrapper<IntegerRangeState, AbstractAttribute, uint32_t> {
4943
4944
4947 return false;
4949 }
4950
4951
4953
4954
4957
4958
4961
4962
4963
4966 const Instruction *CtxI = nullptr) const = 0;
4967
4968
4969
4972 const Instruction *CtxI = nullptr) const = 0;
4973
4974
4975
4976 std::optional<Constant *>
4982 AA::getWithType(*ConstantInt::get(Ty->getContext(), *C), *Ty));
4983 }
4985 return std::nullopt;
4986 return nullptr;
4987 }
4988
4989
4991
4992
4994
4995
4996
4998 return (AA->getIdAddr() == &ID);
4999 }
5000
5001
5003};
5004
5005
5006
5007
5008
5009
5010
5011
5012
5015
5017
5019 : IsValidState(IsValid), UndefIsContained(false) {}
5020
5021
5022 bool isValidState() const override { return IsValidState.isValidState(); }
5023
5024
5025 bool isAtFixpoint() const override { return IsValidState.isAtFixpoint(); }
5026
5027
5029 return IsValidState.indicatePessimisticFixpoint();
5030 }
5031
5032
5034 return IsValidState.indicateOptimisticFixpoint();
5035 }
5036
5037
5040
5041
5042
5044 assert(isValidState() && "This set shoud not be used when it is invalid!");
5045 return Set;
5046 }
5047
5048
5050 assert(isValidState() && "This flag shoud not be used when it is invalid!");
5051 return UndefIsContained;
5052 }
5053
5056 return false;
5058 return true;
5060 return false;
5061 return Set == RHS.getAssumedSet();
5062 }
5063
5064
5065
5067
5068
5072
5076
5077
5081
5082
5084
5085
5087
5088
5090
5091
5093 IsValidState ^= PVS.IsValidState;
5095 return *this;
5096 }
5097
5099 IsValidState &= PVS.IsValidState;
5101 return *this;
5102 }
5103
5107
5108protected:
5110 assert(isValidState() && "This set shoud not be used when it is invalid!");
5111 return Set;
5112 }
5113
5114private:
5115
5116
5117 void checkAndInvalidate() {
5120 else
5121 reduceUndefValue();
5122 }
5123
5124
5125
5126 void reduceUndefValue() { UndefIsContained = UndefIsContained & Set.empty(); }
5127
5128
5129 void insert(const MemberTy &C) {
5131 return;
5132 Set.insert(C);
5133 checkAndInvalidate();
5134 }
5135
5136
5138
5140 return;
5141
5142 if (.isValidState()) {
5144 return;
5145 }
5146 Set.insert_range(R.Set);
5147 UndefIsContained |= R.undefIsContained();
5148 checkAndInvalidate();
5149 }
5150
5151
5152 void unionWithUndef() {
5153 UndefIsContained = true;
5154 reduceUndefValue();
5155 }
5156
5157
5159
5160 if (.isValidState())
5161 return;
5162
5164 *this = R;
5165 return;
5166 }
5167 SetTy IntersectSet;
5168 for (const MemberTy &C : Set) {
5170 IntersectSet.insert(C);
5171 }
5172 Set = IntersectSet;
5173 UndefIsContained &= R.undefIsContained();
5174 reduceUndefValue();
5175 }
5176
5177
5178 BooleanState IsValidState;
5179
5180
5182
5183
5184 bool UndefIsContained;
5185};
5186
5191
5195
5199
5201
5205 if (Caller == Callee)
5206 return Caller;
5208 return Caller;
5210 return Callee;
5212 }
5213
5218
5221 Callee.Mode = unionAssumed(Callee.Mode, Caller.Mode);
5222 Callee.ModeF32 = unionAssumed(Callee.ModeF32, Caller.ModeF32);
5223 return Callee;
5224 }
5225 };
5226
5228
5229
5231
5233
5235
5236
5237
5239
5241
5242
5243
5250
5252
5258
5262
5266
5268 Known = Known.unionWith(Caller.getKnown());
5269 return *this;
5270 }
5271};
5272
5276
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
5298 : public StateWrapper<PotentialConstantIntValuesState, AbstractAttribute> {
5301
5302
5305 return false;
5307 }
5308
5309
5311
5312
5315 return *this;
5316 }
5317
5318
5321
5322
5323 std::optional<Constant *>
5326 return nullptr;
5331 *Ty));
5332 }
5336 return std::nullopt;
5337 }
5338
5339 return nullptr;
5340 }
5341
5342
5345 return 0;
5346 unsigned TrailingZeros = getAssumedSet().begin()->getBitWidth() + 1;
5348 if (It.countTrailingZeros() < TrailingZeros)
5349 TrailingZeros = It.countTrailingZeros();
5350 }
5352 return 0;
5353 return TrailingZeros;
5354 }
5355
5357
5358
5360
5361
5362
5364 return (AA->getIdAddr() == &ID);
5365 }
5366
5367
5369};
5370
5372 : public StateWrapper<PotentialLLVMValuesState, AbstractAttribute> {
5375
5376
5378
5379
5382
5383
5386
5387
5392
5393
5395
5396
5398
5399
5400
5402 return (AA->getIdAddr() == &ID);
5403 }
5404
5405
5407
5408private:
5409 virtual bool getAssumedSimplifiedValues(
5411 AA::ValueScope, bool RecurseForSelectAndPHI = false) const = 0;
5412
5414};
5415
5416
5418 : public IRAttribute<Attribute::NoUndef,
5419 StateWrapper<BooleanState, AbstractAttribute>,
5420 AANoUndef> {
5422
5423
5425
5426
5428
5429
5432 bool IgnoreSubsumingPositions = false);
5433
5434
5436
5437
5439
5440
5443
5444
5446
5447
5449
5450
5452 return (AA->getIdAddr() == &ID);
5453 }
5454
5455
5457};
5458
5461 Attribute::NoFPClass,
5462 StateWrapper<BitIntegerState<uint32_t, fcAllFlags, fcNone>,
5463 AbstractAttribute>,
5464 AANoFPClass> {
5467
5469
5470
5473 do {
5474 if (Ty->isFPOrFPVectorTy())
5475 return IRAttribute::isValidIRPositionForInit(A, IRP);
5476 if (!Ty->isArrayTy())
5477 break;
5478 Ty = Ty->getArrayElementType();
5479 } while (true);
5480 return false;
5481 }
5482
5483
5487
5491
5492
5495
5496
5498
5499
5501
5502
5504 return (AA->getIdAddr() == &ID);
5505 }
5506
5507
5509};
5510
5513
5514
5515
5516
5517class AACallEdgeIterator
5519 SetVector<Function *>::iterator> {
5522
5523public:
5525
5526private:
5528 friend AACallEdges;
5529 friend AttributorCallGraph;
5530};
5531
5535
5538
5539
5544
5545protected:
5546
5548};
5549
5550
5551
5552
5556
5559
5560
5562
5563
5565
5566
5568
5569
5571
5572
5576
5577
5581
5582
5585
5586
5588
5589
5591
5592
5594 return (AA->getIdAddr() == &ID);
5595 }
5596
5597
5599};
5600
5601
5605
5609
5613
5614
5617
5618 (void)AA;
5619 }
5620 }
5621
5623};
5624
5628
5630 return Node->optimisticEdgesBegin();
5631 }
5632
5634 return Node->optimisticEdgesEnd();
5635 }
5636};
5637
5638template <>
5642
5646
5648 return G->optimisticEdgesBegin();
5649 }
5650
5652 return G->optimisticEdgesEnd();
5653 }
5654};
5655
5656template <>
5672
5674 : public StateWrapper<BooleanState, AbstractAttribute> {
5677
5678
5682
5686
5690
5695
5702 };
5703
5704
5707
5708
5710
5711
5713
5714
5718
5719
5721
5722
5723
5724
5727
5729
5730
5731 virtual std::pair<ExecutionDomainTy, ExecutionDomainTy>
5734
5735
5736
5738
5739
5740
5742 return (AA->getIdAddr() == &ID);
5743 }
5744
5745
5747};
5748
5749
5751 : public StateWrapper<BooleanState, AbstractAttribute> {
5753
5755
5756
5759 if (!Scope || Scope->isDeclaration())
5760 return true;
5762 }
5763
5764
5765
5769
5770
5773
5774
5776
5777
5779
5780
5782 return (AA->getIdAddr() == &ID);
5783 }
5784
5785
5787};
5788
5789
5790
5793
5795
5796
5799
5800
5802
5803
5805
5806
5808
5809
5811
5812
5813
5815 return (AA->getIdAddr() == &ID);
5816 }
5817
5818
5820};
5821
5822
5825
5826
5829 return false;
5831 }
5832
5834
5837
5838
5842
5843
5844
5845
5847
5848
5855 };
5856
5857
5858
5859
5864
5867
5871
5873
5876
5879 return false;
5880 if (Offsets.size() == 1)
5882 return false;
5883 }
5884
5889
5891 VecTy NewOffsets;
5894 Offsets = std::move(NewOffsets);
5895 }
5896
5897
5898
5899
5900
5902 };
5903
5904
5906
5907
5908
5909
5915
5918 Ranges.reserve(Offsets.size());
5919 for (unsigned i = 0, e = Offsets.size(); i != e; ++i) {
5920 assert(((i + 1 == e) || Offsets[i] < Offsets[i + 1]) &&
5921 "Expected strictly ascending offsets.");
5922 Ranges.emplace_back(Offsets[i], Size);
5923 }
5924 }
5926
5931
5932
5936 "Ensure the last element is the greatest.");
5937 Ranges.push_back(R);
5938 }
5939
5940
5943 std::set_difference(L.begin(), L.end(), R.begin(), R.end(),
5945 }
5946
5948
5950
5951
5952
5953
5954
5957 return false;
5958 if (RHS.isUnknown()) {
5960 return true;
5961 }
5962
5963 if (Ranges.empty()) {
5965 return true;
5966 }
5967
5969 auto LPos = Ranges.begin();
5970 for (auto &R : RHS.Ranges) {
5971 auto Result = insert(LPos, R);
5973 return true;
5974 LPos = Result.first;
5975 Changed |= Result.second;
5976 }
5978 }
5979
5980
5981
5982
5983
5984
5985
5988 return std::make_pair(Ranges.begin(), false);
5989 if (R.offsetOrSizeAreUnknown()) {
5990 return std::make_pair(setUnknown(), true);
5991 }
5992
5993
5995 if (LB == Ranges.end() || LB->Offset != R.Offset)
5996 return std::make_pair(Ranges.insert(LB, R), true);
5997 bool Changed = *LB != R;
5998 *LB &= R;
5999 if (LB->offsetOrSizeAreUnknown())
6000 return std::make_pair(setUnknown(), true);
6001 return std::make_pair(LB, Changed);
6002 }
6003
6004
6005
6006
6010
6011
6014 "Cannot increment if the offset is not yet computed!");
6016 return;
6017 for (auto &R : Ranges) {
6018 R.Offset += Inc;
6019 }
6020 }
6021
6022
6024 return Ranges.size() == 1 && .front().offsetOrSizeAreUnknown();
6025 }
6026
6027
6030 return Ranges.front();
6031 }
6032
6033
6036 return false;
6037 if (Ranges.front().offsetOrSizeAreUnknown()) {
6038 assert(Ranges.size() == 1 && "Unknown is a singleton range.");
6039 return true;
6040 }
6041 return false;
6042 }
6043
6044
6048 return Ranges.begin();
6049 }
6050
6051
6053 };
6054
6055
6058 std::optional<Value *> Content, AccessKind Kind, Type *Ty)
6059 : LocalI(I), RemoteI(I), Content(Content), Ranges(Offset, Size),
6060 Kind(Kind), Ty(Ty) {
6062 }
6064 std::optional<Value *> Content, AccessKind K, Type *Ty)
6065 : LocalI(LocalI), RemoteI(RemoteI), Content(Content), Ranges(Ranges),
6066 Kind(K), Ty(Ty) {
6067 if (Ranges.size() > 1) {
6068 Kind = AccessKind(Kind | AK_MAY);
6069 Kind = AccessKind(Kind & ~AK_MUST);
6070 }
6072 }
6074 int64_t Size, std::optional<Value *> Content, AccessKind Kind,
6076 : LocalI(LocalI), RemoteI(RemoteI), Content(Content),
6077 Ranges(Offset, Size), Kind(Kind), Ty(Ty) {
6079 }
6081
6084 return LocalI == R.LocalI && RemoteI == R.RemoteI && Ranges == R.Ranges &&
6085 Content == R.Content && Kind == R.Kind;
6086 }
6088
6090 assert(RemoteI == R.RemoteI && "Expected same instruction!");
6091 assert(LocalI == R.LocalI && "Expected same instruction!");
6092
6093
6094
6095
6096
6097 Ranges.merge(R.Ranges);
6098 Content =
6100
6101
6102
6103
6105 if ((Kind & AK_MAY) || Ranges.size() > 1) {
6108 }
6110 return *this;
6111 }
6112
6115 "Expect must or may access, not both.");
6117 "Expect assumption access or write access, never both.");
6119 "Cannot be a must access if there are multiple ranges.");
6120 }
6121
6122
6124
6125
6127
6128
6130
6131
6133
6134
6136
6138 bool MustAccess = Kind & AK_MUST;
6139 assert((!MustAccess || Ranges.size() < 2) &&
6140 "Cannot be a must access if there are multiple ranges.");
6141 return MustAccess;
6142 }
6143
6145 bool MayAccess = Kind & AK_MAY;
6146 assert((MayAccess || Ranges.size() < 2) &&
6147 "Cannot be a must access if there are multiple ranges.");
6148 return MayAccess;
6149 }
6150
6151
6152
6154
6155
6157
6158
6160
6161
6163 return Content.has_value() && !*Content;
6164 }
6165
6166
6168
6169
6171
6172
6175 "Value needs to be determined before accessing it.");
6176 return *Content;
6177 }
6178
6179
6180
6181 std::optional<Value *> getContent() const { return Content; }
6182
6185
6186
6187
6188
6196
6198
6202
6203 private:
6204
6205
6207
6208
6210
6211
6212
6213 std::optional<Value *> Content;
6214
6215
6217
6218
6220
6221
6222
6224 };
6225
6226
6229
6230
6232
6233
6235
6243
6244
6245
6246
6247
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6262 bool FindInterferingWrites, bool FindInterferingReads,
6263 function_ref<bool(const Access &, bool)> CB, bool &HasBeenWrittenTo,
6266
6267
6269 return (AA->getIdAddr() == &ID);
6270 }
6271
6272
6274};
6275
6277
6278
6280 : public StateWrapper<SetState, AbstractAttribute,
6281 DenseSet> {
6284
6287 : Base(IRP, Known) {}
6288
6289
6291
6292
6295
6296
6298
6299
6301
6302
6303
6305 return (AA->getIdAddr() == &ID);
6306 }
6307
6308
6310};
6311
6312
6315
6316
6319 return false;
6321 }
6322
6323
6325
6326
6329
6330
6332
6333
6335
6336
6337
6339 return (AA->getIdAddr() == &ID);
6340 }
6341
6342
6344
6345
6346
6347
6348
6349 virtual bool
6352};
6353
6354
6355
6358
6359
6362 return false;
6363
6365 }
6366
6367
6370
6371
6374
6375
6378
6379
6381
6382
6384
6385
6386
6388 return (AA->getIdAddr() == &ID);
6389 }
6390
6391
6393};
6394
6395
6399
6400
6403 return false;
6405 }
6406
6407
6409
6410
6411
6412
6414
6415
6418
6419
6421
6422
6424
6425
6426
6428 return (AA->getIdAddr() == &ID);
6429 }
6430
6431
6433
6434protected:
6435
6437};
6438
6439
6441 : public StateWrapper<BooleanState, AbstractAttribute> {
6446
6447
6450 return false;
6452 }
6453
6454
6456
6457
6460
6462
6463
6465
6466
6467
6469 return (AA->getIdAddr() == &ID);
6470 }
6471
6472
6474
6475protected:
6478};
6479
6483
6484
6487 return false;
6489 }
6490
6491
6494
6496
6497
6499
6500
6502
6503
6504
6506 return (AA->getIdAddr() == &ID);
6507 }
6508
6510 std::make_optional(-1, true);
6511
6513};
6514
6515
6517 : public StateWrapper<BooleanState, AbstractAttribute> {
6520
6521
6524 return false;
6526 if (!GV)
6527 return false;
6528 return GV->hasLocalLinkage();
6529 }
6530
6531
6534
6535
6537
6538
6540
6541
6543
6544
6545
6547 return (AA->getIdAddr() == &ID);
6548 }
6549
6550
6552};
6553
6554
6556 : public StateWrapper<BooleanState, AbstractAttribute> {
6559
6560
6563 return false;
6565 return CB->getOpcode() == Instruction::Call && CB->isIndirectCall() &&
6566 !CB->isMustTailCall();
6567 }
6568
6569
6572
6573
6574
6576
6577
6579
6580
6582
6583
6584
6585
6586
6588 return (AA->getIdAddr() == &ID);
6589 }
6590
6591
6593};
6594
6595
6596
6598 : public StateWrapper<DenormalFPMathState, AbstractAttribute> {
6600
6602
6603
6606
6607
6609
6610
6612
6613
6614
6616 return (AA->getIdAddr() == &ID);
6617 }
6618
6619
6621};
6622
6623
6630
6631namespace AA {
6632
6633template <Attribute::AttrKind AK, typename AAType = AbstractAttribute>
6636 bool IgnoreSubsumingPositions = false,
6637 const AAType **AAPtr = nullptr) {
6638 IsKnown = false;
6639 switch (AK) {
6640#define CASE(ATTRNAME, AANAME, ...) \
6641 case Attribute::ATTRNAME: { \
6642 if (AANAME::isImpliedByIR(A, IRP, AK, IgnoreSubsumingPositions)) \
6643 return IsKnown = true; \
6644 if (!QueryingAA) \
6645 return false; \
6646 const auto *AA = A.getAAFor(*QueryingAA, IRP, DepClass); \
6647 if (AAPtr) \
6648 *AAPtr = reinterpret_cast<const AAType *>(AA); \
6649 if (!AA || !AA->isAssumed(__VA_ARGS__)) \
6650 return false; \
6651 IsKnown = AA->isKnown(__VA_ARGS__); \
6652 return true; \
6653 }
6668#undef CASE
6669 default:
6670 llvm_unreachable("hasAssumedIRAttr not available for this attribute kind");
6671 };
6672}
6673}
6674
6675}
6676
6677#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the BumpPtrAllocator interface.
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
This file contains the simple types necessary to represent the attributes associated with functions a...
static cl::opt< unsigned, true > MaxPotentialValues("attributor-max-potential-values", cl::Hidden, cl::desc("Maximum number of potential values to be " "tracked for each position."), cl::location(llvm::PotentialConstantIntValuesState::MaxPotentialValues), cl::init(7))
#define CASE(ATTRNAME, AANAME,...)
static const Function * getParent(const Value *V)
block Block Frequency Analysis
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This header provides classes for managing passes over SCCs of the call graph.
This file provides interfaces used to manipulate a call graph, regardless if it is a "old style" Call...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This file provides an implementation of debug counters.
#define DEBUG_COUNTER(VARNAME, COUNTERNAME, DESC)
This file defines the DenseSet and SmallDenseSet classes.
This file defines the little GraphTraits template class that should be specialized by classes that...
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
This file implements a coalescing interval map for small objects.
Implements a lazy call graph analysis and related passes for the new pass manager.
This file implements a map that provides insertion order iteration.
This file provides utility analysis objects describing memory locations.
Contains a collection of routines for determining if a given instruction is guaranteed to execute if ...
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
This file defines generic set operations that may be used on set's of different types,...
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallSet class.
static SymbolRef::Type getType(const Symbol *Sym)
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
An Iterator for call edges, creates AACallEdges attributes in a lazy way.
Definition Attributor.h:5519
LLVM_ABI AACallGraphNode * operator*() const
Class for arbitrary precision integers.
CallBase * getInstruction() const
Return the underlying instruction.
int getCallArgOperandNo(Argument &Arg) const
Return the operand index of the underlying instruction associated with Arg.
unsigned getNumArgOperands() const
Return the number of parameters of the callee.
This class represents an incoming formal argument to a Function.
const Function * getParent() const
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This represents the llvm.assume intrinsic.
This class stores enough information to efficiently remove some attributes from an existing AttrBuild...
This class holds the attributes for a particular argument, parameter, function, or return value.
Functions, function parameters, and return types can have attributes to indicate how they should be t...
static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)
Return a uniquified Attribute object.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
@ None
No attributes have been set.
static bool isEnumAttrKind(AttrKind Kind)
LLVM Basic Block Representation.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
const Use & getArgOperandUse(unsigned i) const
Wrappers for getting the Use of a call argument.
Wrapper to unify "old style" CallGraph and "new style" LazyCallGraph.
This class represents a range of values.
const APInt * getSingleElement() const
If this set contains a single element, return it, otherwise return null.
LLVM_ABI bool isEmptySet() const
Return true if this set contains no members.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
static bool shouldExecute(CounterInfo &Counter)
Implements a dense probed hash-table based set.
Analysis pass which computes a DominatorTree.
An instruction for ordering other memory operations.
AttributeList getAttributes() const
Return the attribute list for this Function.
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
Type * getReturnType() const
Returns the type of the ret val.
Argument * getArg(unsigned i) const
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
bool hasLocalLinkage() const
typename Sizer::Allocator Allocator
This is an important class for using LLVM in a threaded context.
An SCC of the call graph.
A lazily constructed view of the call graph of a module.
An instruction for reading from memory.
Analysis pass that exposes the LoopInfo for a function.
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
static MemoryEffectsBase unknown()
A Module instance is used to store all the information related to an LLVM module.
Pass interface - Implemented by all 'passes'.
PointerIntPair - This class implements a pair of a pointer and small integer.
PointerTy getPointer() const
void setFromOpaqueValue(void *Val) &
Analysis pass which computes a PostDominatorTree.
A set of analyses that are preserved following a run of a transformation pass.
A vector that has set insertion semantics.
size_type size() const
Determine the number of elements in the SetVector.
typename vector_type::const_iterator iterator
bool empty() const
Determine if the SetVector is empty or not.
iterator begin()
Get an iterator to the beginning of the SetVector.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
iterator find(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
SmallSetIterator< int64_t, N, std::less< int64_t > > const_iterator
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
iterator begin()
Definition Attributor.h:1129
LLVM_ABI SubsumingPositionIterator(const IRPosition &IRP)
iterator end()
Definition Attributor.h:1130
Analysis pass providing the TargetLibraryInfo.
Provides information about what library functions are available for the current target.
The TimeTraceScope is a helper class to call the begin and end functions of the time trace profiler.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isPointerTy() const
True if this is an instance of PointerType.
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
bool isIntegerTy() const
True if this is an instance of IntegerType.
static LLVM_ABI UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
LLVM_ABI LLVMContext & getContext() const
All values hold a context through their type.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
An efficient, type-erasing, non-owning reference to a callable.
iterator_adaptor_base()=default
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Abstract Attribute helper functions.
Definition Attributor.h:165
GPUAddressSpace
Definition Attributor.h:168
@ Global
Definition Attributor.h:170
@ Local
Definition Attributor.h:173
@ Generic
Definition Attributor.h:169
@ Shared
Definition Attributor.h:171
@ Constant
Definition Attributor.h:172
LLVM_ABI bool isAssumedReadNone(Attributor &A, const IRPosition &IRP, const AbstractAttribute &QueryingAA, bool &IsKnown)
Return true if IRP is readnone.
LLVM_ABI bool isAssumedReadOnly(Attributor &A, const IRPosition &IRP, const AbstractAttribute &QueryingAA, bool &IsKnown)
Return true if IRP is readonly.
raw_ostream & operator<<(raw_ostream &OS, const RangeTy &R)
Definition Attributor.h:323
LLVM_ABI std::optional< Value * > combineOptionalValuesInAAValueLatice(const std::optional< Value * > &A, const std::optional< Value * > &B, Type *Ty)
Return the combination of A and B such that the result is a possible value of both.
LLVM_ABI bool isValidAtPosition(const ValueAndContext &VAC, InformationCache &InfoCache)
Return true if the value of VAC is a valid at the position of VAC, that is a constant,...
LLVM_ABI bool isAssumedThreadLocalObject(Attributor &A, Value &Obj, const AbstractAttribute &QueryingAA)
Return true if Obj is assumed to be a thread local object.
LLVM_ABI bool isDynamicallyUnique(Attributor &A, const AbstractAttribute &QueryingAA, const Value &V, bool ForAnalysisOnly=true)
Return true if V is dynamically unique, that is, there are no two "instances" of V at runtime with di...
LLVM_ABI bool getPotentialCopiesOfStoredValue(Attributor &A, StoreInst &SI, SmallSetVector< Value *, 4 > &PotentialCopies, const AbstractAttribute &QueryingAA, bool &UsedAssumedInformation, bool OnlyExact=false)
Collect all potential values of the one stored by SI into PotentialCopies.
bool operator!=(const RangeTy &A, const RangeTy &B)
Definition Attributor.h:332
LLVM_ABI bool isPotentiallyAffectedByBarrier(Attributor &A, const Instruction &I, const AbstractAttribute &QueryingAA)
Return true if I is potentially affected by a barrier.
SmallPtrSet< Instruction *, 4 > InstExclusionSetTy
Definition Attributor.h:166
LLVM_ABI bool isGPU(const Module &M)
Return true iff M target a GPU (and we can use GPU AS reasoning).
LLVM_ABI Constant * getInitialValueForObj(Attributor &A, const AbstractAttribute &QueryingAA, Value &Obj, Type &Ty, const TargetLibraryInfo *TLI, const DataLayout &DL, RangeTy *RangePtr=nullptr)
Return the initial value of Obj with type Ty if that is a constant.
bool operator==(const RangeTy &A, const RangeTy &B)
Definition Attributor.h:328
ValueScope
Flags to distinguish intra-procedural queries from potentially inter-procedural queries.
Definition Attributor.h:182
@ Intraprocedural
Definition Attributor.h:183
@ AnyScope
Definition Attributor.h:185
@ Interprocedural
Definition Attributor.h:184
LLVM_ABI bool isValidInScope(const Value &V, const Function *Scope)
Return true if V is a valid value in Scope, that is a constant or an instruction/argument of Scope.
LLVM_ABI bool isPotentiallyReachable(Attributor &A, const Instruction &FromI, const Instruction &ToI, const AbstractAttribute &QueryingAA, const AA::InstExclusionSetTy *ExclusionSet=nullptr, std::function< bool(const Function &F)> GoBackwardsCB=nullptr)
Return true if ToI is potentially reachable from FromI without running into any instruction in Exclus...
LLVM_ABI bool isNoSyncInst(Attributor &A, const Instruction &I, const AbstractAttribute &QueryingAA)
Return true if I is a nosync instruction.
bool hasAssumedIRAttr(Attributor &A, const AbstractAttribute *QueryingAA, const IRPosition &IRP, DepClassTy DepClass, bool &IsKnown, bool IgnoreSubsumingPositions=false, const AAType **AAPtr=nullptr)
Helper to avoid creating an AA for IR Attributes that might already be set.
Definition Attributor.h:6634
LLVM_ABI bool getPotentiallyLoadedValues(Attributor &A, LoadInst &LI, SmallSetVector< Value *, 4 > &PotentialValues, SmallSetVector< Instruction *, 4 > &PotentialValueOrigins, const AbstractAttribute &QueryingAA, bool &UsedAssumedInformation, bool OnlyExact=false)
Collect all potential values LI could read into PotentialValues.
LLVM_ABI Value * getWithType(Value &V, Type &Ty)
Try to convert V to type Ty without introducing new instructions.
E & operator^=(E &LHS, E RHS)
@ C
The default llvm calling convention, compatible with C.
NodeAddr< UseNode * > Use
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
LLVM_ABI unsigned MaxInitializationChainLength
The value passed to the line option that defines the maximal initialization chain length.
APInt operator&(APInt a, const APInt &b)
void set_intersect(S1Ty &S1, const S2Ty &S2)
set_intersect(A, B) - Compute A := A ^ B Identical to set_intersection, except that it works on set<>...
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
bool operator!=(uint64_t V1, const APInt &V2)
auto dyn_cast_if_present(const Y &Val)
dyn_cast_if_present - Functionally identical to dyn_cast, except that a null (or none in the case ...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ATTRIBUTE_ALWAYS_INLINE DynamicAPInt & operator+=(DynamicAPInt &A, int64_t B)
bool set_is_subset(const S1Ty &S1, const S2Ty &S2)
set_is_subset(A, B) - Return true iff A in B
auto cast_or_null(const Y &Val)
@ NONE
Definition Attributor.h:6625
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
bool isa_and_nonnull(const Y &Val)
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
AttributorRunOption
Run options, used by the pass manager.
Definition Attributor.h:6624
@ MODULE
Definition Attributor.h:6626
@ ALL
Definition Attributor.h:6628
@ CGSCC
Definition Attributor.h:6627
AnalysisManager< LazyCallGraph::SCC, LazyCallGraph & > CGSCCAnalysisManager
The CGSCC analysis manager.
LLVM_ABI bool canSimplifyInvokeNoUnwind(const Function *F)
DenseMap< RetainedKnowledgeKey, Assume2KnowledgeMap > RetainedKnowledgeMap
PotentialValuesState< std::pair< AA::ValueAndContext, AA::ValueScope > > PotentialLLVMValuesState
Definition Attributor.h:5274
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool set_union(S1Ty &S1, const S2Ty &S2)
set_union(A, B) - Compute A := A u B, return whether A changed.
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...
@ Success
The lock was released successfully.
iterator_range(Container &&) -> iterator_range< llvm::detail::IterOfRange< Container > >
PotentialValuesState< APInt > PotentialConstantIntValuesState
Definition Attributor.h:5273
bool operator&=(SparseBitVector< ElementSize > *LHS, const SparseBitVector< ElementSize > &RHS)
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
ChangeStatus clampStateAndIndicateChange(StateType &S, const StateType &R)
Helper function to clamp a state S of type StateType with the information in R and indicate/return if...
Definition Attributor.h:3505
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
ChangeStatus
{
Definition Attributor.h:496
@ UNCHANGED
Definition Attributor.h:498
@ CHANGED
Definition Attributor.h:497
bool operator|=(SparseBitVector< ElementSize > &LHS, const SparseBitVector< ElementSize > *RHS)
DepClassTy
Definition Attributor.h:506
@ OPTIONAL
The target may be valid if the source is not.
Definition Attributor.h:508
@ NONE
Do not track a dependence between source and target.
Definition Attributor.h:509
@ REQUIRED
The target cannot be valid if the source is not.
Definition Attributor.h:507
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
APInt operator|(APInt a, const APInt &b)
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
IncIntegerState< uint64_t, Value::MaximumAlignment, 1 > AAAlignmentStateType
Definition Attributor.h:4317
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Implement std::hash so that hash_code can be used in STL containers.
static LLVM_ABI AAAddressSpace & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:6423
static bool requiresCallersForArgOrFunction()
See AbstractAttribute::requiresCallersForArgOrFunction.
Definition Attributor.h:6408
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:6420
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAAssumptionInfo.
Definition Attributor.h:6427
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:6401
virtual uint32_t getAddressSpace() const =0
Return the address space of the associated value.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:6432
AAAddressSpace(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:6397
static const uint32_t InvalidAddressSpace
Definition Attributor.h:6436
AAAlign(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:4324
static LLVM_ABI AAAlign & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:4355
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:4343
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:4327
Align getAssumedAlign() const
Return assumed alignment.
Definition Attributor.h:4334
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAAlign.
Definition Attributor.h:4346
Align getKnownAlign() const
Return known alignment.
Definition Attributor.h:4337
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:4340
static LLVM_ABI const char ID
Definition Attributor.h:6512
virtual std::optional< TypeSize > getAllocatedSize() const =0
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:6485
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:6501
static LLVM_ABI AAAllocationInfo & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:6498
AAAllocationInfo(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:6481
static constexpr const std::optional< TypeSize > HasNoAllocationSize
Definition Attributor.h:6509
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAAllocationInfo.
Definition Attributor.h:6505
AAAssumptionInfo(const IRPosition &IRP, Attributor &A, const DenseSet< StringRef > &Known)
Definition Attributor.h:6285
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:6309
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:6297
static LLVM_ABI AAAssumptionInfo & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
StateWrapper< SetState< StringRef >, AbstractAttribute, DenseSet< StringRef > > Base
Definition Attributor.h:6282
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:6300
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAAssumptionInfo.
Definition Attributor.h:6304
virtual bool hasAssumption(const StringRef Assumption) const =0
Returns true if the assumption set contains the assumption Assumption.
An abstract state for querying live call edges.
Definition Attributor.h:5554
AACallEdges(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:5557
virtual const SetVector< Function * > & getOptimisticEdges() const =0
Get the optimistic edges.
static bool requiresNonAsmForCallBase()
See AbstractAttribute::requiresNonAsmForCallBase.
Definition Attributor.h:5561
StateWrapper< BooleanState, AbstractAttribute > Base
Definition Attributor.h:5555
AACallEdgeIterator optimisticEdgesBegin() const override
Iterator for exploring the call graph.
Definition Attributor.h:5573
virtual bool hasUnknownCallee() const =0
Is there any call with a unknown callee.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:5598
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:5587
virtual bool hasNonAsmUnknownCallee() const =0
Is there any call with a unknown callee, excluding any inline asm.
AACallEdgeIterator optimisticEdgesEnd() const override
Iterator for exploring the call graph.
Definition Attributor.h:5578
static LLVM_ABI AACallEdges & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AACallEdges.
Definition Attributor.h:5593
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:5590
Definition Attributor.h:5532
iterator_range< AACallEdgeIterator > optimisticEdgesRange() const
Iterator range for exploring the call graph.
Definition Attributor.h:5540
virtual AACallEdgeIterator optimisticEdgesBegin() const =0
AACallGraphNode(Attributor &A)
Definition Attributor.h:5533
virtual AACallEdgeIterator optimisticEdgesEnd() const =0
virtual ~AACallGraphNode()=default
Attributor & A
Reference to Attributor needed for GraphTraits implementation.
Definition Attributor.h:5547
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:6611
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:6608
AADenormalFPMath(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:6601
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:6620
StateWrapper< DenormalFPMathState, AbstractAttribute > Base
Definition Attributor.h:6599
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AADenormalFPMath.
Definition Attributor.h:6615
static LLVM_ABI AADenormalFPMath & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
}
Definition Attributor.h:514
static AbstractAttribute * DepGetValAA(const DepTy &DT)
Definition Attributor.h:526
friend struct Attributor
Definition Attributor.h:548
mapped_iterator< DepSetTy::iterator, decltype(&DepGetVal)> iterator
Definition Attributor.h:533
mapped_iterator< DepSetTy::iterator, decltype(&DepGetValAA)> aaiterator
Definition Attributor.h:534
virtual ~AADepGraphNode()=default
iterator child_end()
Definition Attributor.h:540
SmallSetVector< DepTy, 2 > DepSetTy
Definition Attributor.h:518
static AADepGraphNode * DepGetVal(const DepTy &DT)
Definition Attributor.h:525
DepSetTy & getDeps()
Definition Attributor.h:546
iterator child_begin()
Definition Attributor.h:539
DepSetTy Deps
Set of dependency graph nodes which should be updated if this one is updated.
Definition Attributor.h:523
friend struct AADepGraph
Definition Attributor.h:549
virtual void print(Attributor *, raw_ostream &OS) const
Definition Attributor.h:543
aaiterator begin()
Definition Attributor.h:537
aaiterator end()
Definition Attributor.h:538
PointerIntPair< AADepGraphNode *, 1 > DepTy
Definition Attributor.h:517
void print(raw_ostream &OS) const
Definition Attributor.h:542
The data structure for the dependency graph.
Definition Attributor.h:557
iterator begin()
Definition Attributor.h:572
mapped_iterator< AADepGraphNode::DepSetTy::iterator, decltype(&DepGetVal)> iterator
Definition Attributor.h:563
LLVM_ABI void viewGraph()
AADepGraphNode SyntheticRoot
There is no root node for the dependency graph.
Definition Attributor.h:569
LLVM_ABI void print()
Print dependency graph.
static AADepGraphNode * DepGetVal(const DepTy &DT)
Definition Attributor.h:562
iterator end()
Definition Attributor.h:573
LLVM_ABI void dumpGraph()
Dump graph to file.
AADepGraphNode * GetEntryNode()
Definition Attributor.h:570
AADepGraphNode::DepTy DepTy
Definition Attributor.h:561
uint32_t getKnownDereferenceableBytes() const
Return known dereferenceable bytes.
Definition Attributor.h:4293
bool isAssumedGlobal() const
Return true if we assume that underlying value is dereferenceable(_or_null) globally.
Definition Attributor.h:4281
bool isKnownGlobal() const
Return true if we know that underlying value is dereferenceable(_or_null) globally.
Definition Attributor.h:4285
AADereferenceable(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:4270
uint32_t getAssumedDereferenceableBytes() const
Return assumed dereferenceable bytes.
Definition Attributor.h:4288
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:4302
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:4314
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AADereferenceable.
Definition Attributor.h:4309
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:4305
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:4273
static LLVM_ABI AADereferenceable & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
Summary about the execution domain of a block or instruction.
Definition Attributor.h:5679
bool IsExecutedByInitialThreadOnly
Definition Attributor.h:5696
BarriersSetTy AlignedBarriers
Definition Attributor.h:5700
void addAssumeInst(Attributor &A, AssumeInst &AI)
Definition Attributor.h:5683
SmallPtrSet< AssumeInst *, 4 > AssumesSetTy
Definition Attributor.h:5681
bool EncounteredNonLocalSideEffect
Definition Attributor.h:5699
void addAlignedBarrier(Attributor &A, CallBase &CB)
Definition Attributor.h:5687
SmallPtrSet< CallBase *, 2 > BarriersSetTy
Definition Attributor.h:5680
void clearAssumeInstAndAlignedBarriers()
Definition Attributor.h:5691
bool IsReachedFromAlignedBarrierOnly
Definition Attributor.h:5697
bool IsReachingAlignedBarrierOnly
Definition Attributor.h:5698
AssumesSetTy EncounteredAssumes
Definition Attributor.h:5701
virtual bool isExecutedByInitialThreadOnly(const BasicBlock &) const =0
Check if a basic block is executed only by the initial thread.
StateWrapper< BooleanState, AbstractAttribute > Base
Definition Attributor.h:5675
bool isExecutedByInitialThreadOnly(const Instruction &I) const
Check if an instruction is executed only by the initial thread.
Definition Attributor.h:5715
static LLVM_ABI AAExecutionDomain & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAExecutionDomain.
Definition Attributor.h:5741
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr().
Definition Attributor.h:5712
virtual ExecutionDomainTy getFunctionExecutionDomain() const =0
virtual ExecutionDomainTy getExecutionDomain(const BasicBlock &) const =0
virtual bool isExecutedInAlignedRegion(Attributor &A, const Instruction &I) const =0
Check if the instruction I is executed in an aligned region, that is, the synchronizing effects befor...
AAExecutionDomain(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:5676
virtual bool isNoOpFence(const FenceInst &FI) const =0
Helper function to determine if FI is a no-op given the information about its execution from ExecDoma...
StringRef getName() const override
See AbstractAttribute::getName().
Definition Attributor.h:5709
virtual std::pair< ExecutionDomainTy, ExecutionDomainTy > getExecutionDomain(const CallBase &CB) const =0
Return the execution domain with which the call CB is entered and the one with which it is left.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:5746
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAGlobalValueInfo.
Definition Attributor.h:6546
AAGlobalValueInfo(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:6518
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:6539
static LLVM_ABI AAGlobalValueInfo & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:6522
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:6542
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:6551
virtual bool isPotentialUse(const Use &U) const =0
Return true iff U is a potential use of the associated global value.
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:4608
StateWrapper< BooleanState, AbstractAttribute > Base
Definition Attributor.h:4593
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:4611
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAHeapToStack.
Definition Attributor.h:4614
virtual bool isAssumedHeapToStack(const CallBase &CB) const =0
Returns true if HeapToStack conversion is assumed to be possible.
virtual bool isAssumedHeapToStackRemovedFree(CallBase &CB) const =0
Returns true if HeapToStack conversion is assumed and the CB is a callsite to a free operation to be ...
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:4619
static LLVM_ABI AAHeapToStack & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AAHeapToStack(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:4594
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:6578
virtual bool foreachCallee(function_ref< bool(Function *)> CB) const =0
Call \CB on each potential callee value and return true if all were known and CB returned true on all...
AAIndirectCallInfo(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:6557
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:6581
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAIndirectCallInfo This function should ret...
Definition Attributor.h:6587
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:6592
static LLVM_ABI AAIndirectCallInfo & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:6561
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:4395
bool isKnownUniqueForAnalysis() const
Return true if we know that the underlying value is unique in its scope wrt.
Definition Attributor.h:4370
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:4383
AAInstanceInfo(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:4363
bool isAssumedUniqueForAnalysis() const
Return true if we assume that the underlying value is unique in its scope wrt.
Definition Attributor.h:4376
static LLVM_ABI AAInstanceInfo & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAInstanceInfo.
Definition Attributor.h:4390
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:4386
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AACallEdges.
Definition Attributor.h:5781
static LLVM_ABI AAInterFnReachability & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:5786
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:5778
bool canReach(Attributor &A, const Function &Fn) const
If the function represented by this possition can reach Fn.
Definition Attributor.h:5757
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:5775
virtual bool instructionCanReach(Attributor &A, const Instruction &Inst, const Function &Fn, const AA::InstExclusionSetTy *ExclusionSet=nullptr) const =0
Can Inst reach Fn.
AAInterFnReachability(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:5754
StateWrapper< BooleanState, AbstractAttribute > Base
Definition Attributor.h:5752
static LLVM_ABI AAIntraFnReachability & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAIntraFnReachability.
Definition Attributor.h:3886
AAIntraFnReachability(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:3865
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:3879
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:3891
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:3882
virtual bool isAssumedReachable(Attributor &A, const Instruction &From, const Instruction &To, const AA::InstExclusionSetTy *ExclusionSet=nullptr) const =0
Returns true if 'From' instruction is assumed to reach, 'To' instruction.
StateWrapper< BooleanState, AbstractAttribute > Base
Definition Attributor.h:3864
An abstract interface for identifying pointers from which loads can be marked invariant.
Definition Attributor.h:6356
virtual bool isAssumedInvariant() const =0
Return true if the pointer's contents are assumed to remain invariant.
static LLVM_ABI AAInvariantLoadPointer & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
virtual bool isAssumedLocallyInvariant() const =0
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAInvariantLoadPointer.
Definition Attributor.h:6387
static LLVM_ABI const char ID
Unique ID (due to the unique address).
Definition Attributor.h:6392
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr().
Definition Attributor.h:6383
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:6360
StringRef getName() const override
See AbstractAttribute::getName().
Definition Attributor.h:6380
virtual bool isKnownInvariant() const =0
Return true if the pointer's contents are known to remain invariant.
AAInvariantLoadPointer(const IRPosition &IRP)
Definition Attributor.h:6357
virtual bool isKnownLocallyInvariant() const =0
An abstract interface for liveness abstract attribute.
Definition Attributor.h:4026
friend struct Attributor
Definition Attributor.h:4119
virtual bool isKnownDead(const BasicBlock *BB) const =0
Returns true if BB is known dead.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAIsDead.
Definition Attributor.h:4112
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:4117
bool isLiveInstSet(T begin, T end) const
This method is used to check if at least one instruction in a collection of instructions is live.
Definition Attributor.h:4074
virtual bool isKnownDead() const =0
Returns true if the underlying value is known dead.
virtual bool isEdgeDead(const BasicBlock *From, const BasicBlock *To) const
Return if the edge from From BB to To BB is assumed dead.
Definition Attributor.h:4101
virtual bool isAssumedDead(const Instruction *I) const =0
Returns true if I is assumed dead.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:4031
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:4106
virtual bool isAssumedDead() const =0
The query functions are protected such that other attributes need to go through the Attributor interf...
virtual bool isRemovableStore() const
Return true if the underlying value is a store that is known to be removable.
Definition Attributor.h:4070
@ IS_REMOVABLE
Definition Attributor.h:4041
@ IS_DEAD
Definition Attributor.h:4043
@ HAS_NO_EFFECT
Definition Attributor.h:4040
virtual bool isAssumedDead(const BasicBlock *BB) const =0
Returns true if BB is assumed dead.
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:4109
StateWrapper< BitIntegerState< uint8_t, 3, 0 >, AbstractAttribute > Base
Definition Attributor.h:4027
static LLVM_ABI AAIsDead & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool mayCatchAsynchronousExceptions(const Function &F)
Determine if F might catch asynchronous exceptions.
Definition Attributor.h:4092
AAIsDead(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:4028
virtual bool isKnownDead(const Instruction *I) const =0
Returns true if I is known dead.
An abstract interface for memory access kind related attributes (readnone/readonly/writeonly).
Definition Attributor.h:4684
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:4737
bool isAssumedReadOnly() const
Return true if we assume that the underlying value is not accessed (=written) in its respective scope...
Definition Attributor.h:4722
static LLVM_ABI AAMemoryBehavior & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool hasTrivialInitializer()
See AbstractAttribute::hasTrivialInitializer.
Definition Attributor.h:4688
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAMemoryBehavior.
Definition Attributor.h:4744
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:4691
bool isKnownReadNone() const
Return true if we know that the underlying value is not read or accessed in its respective scope.
Definition Attributor.h:4710
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:4749
@ BEST_STATE
Definition Attributor.h:4704
@ NO_WRITES
Definition Attributor.h:4701
@ NO_READS
Definition Attributor.h:4700
@ NO_ACCESSES
Definition Attributor.h:4702
bool isKnownWriteOnly() const
Return true if we know that the underlying value is not read in its respective scope.
Definition Attributor.h:4726
bool isAssumedReadNone() const
Return true if we assume that the underlying value is not read or accessed in its respective scope.
Definition Attributor.h:4714
bool isAssumedWriteOnly() const
Return true if we assume that the underlying value is not read in its respective scope.
Definition Attributor.h:4730
AAMemoryBehavior(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:4685
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:4740
bool isKnownReadOnly() const
Return true if we know that the underlying value is not accessed (=written) in its respective scope.
Definition Attributor.h:4718
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:4922
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:4925
bool isAssumedStackOnly() const
Return true if we assume that the associated functions has at most local/stack accesses.
Definition Attributor.h:4819
static LLVM_ABI std::string getMemoryLocationsAsStr(MemoryLocationsKind MLK)
Return the locations encoded by MLK as a readable string.
bool isKnownArgMemOnly() const
Return true if we know that the underlying value will only access argument pointees (see Attribute::A...
Definition Attributor.h:4837
bool isKnownInaccessibleOrArgMemOnly() const
Return true if we know that the underlying value will only access inaccesible memory or argument poin...
Definition Attributor.h:4850
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:4934
AAMemoryLocation(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:4761
bool isKnownReadNone() const
Return true if we know that the associated functions has no observable accesses.
Definition Attributor.h:4803
bool isAssumedSpecifiedMemOnly(MemoryLocationsKind MLK) const
Return true if only the memory locations specififed by MLK are assumed to be accessed by the associat...
Definition Attributor.h:4869
@ ALL_LOCATIONS
Definition Attributor.h:4780
@ NO_LOCAL_MEM
Definition Attributor.h:4781
@ BEST_STATE
Definition Attributor.h:4797
@ NO_MALLOCED_MEM
Definition Attributor.h:4788
@ NO_GLOBAL_INTERNAL_MEM
Definition Attributor.h:4783
@ NO_INACCESSIBLE_MEM
Definition Attributor.h:4787
@ NO_GLOBAL_MEM
Definition Attributor.h:4785
@ VALID_STATE
Definition Attributor.h:4795
@ NO_CONST_MEM
Definition Attributor.h:4782
@ NO_LOCATIONS
Definition Attributor.h:4790
@ NO_ARGUMENT_MEM
Definition Attributor.h:4786
@ NO_GLOBAL_EXTERNAL_MEM
Definition Attributor.h:4784
@ NO_UNKOWN_MEM
Definition Attributor.h:4789
bool isAssumedInaccessibleMemOnly() const
Return true if we assume that the underlying value will only access inaccesible memory only (see Attr...
Definition Attributor.h:4831
bool isKnownInaccessibleMemOnly() const
Return true if we know that the underlying value will only access inaccesible memory only (see Attrib...
Definition Attributor.h:4825
static LLVM_ABI AAMemoryLocation & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
bool isAssumedInaccessibleOrArgMemOnly() const
Return true if we assume that the underlying value will only access inaccesible memory or argument po...
Definition Attributor.h:4858
bool isKnowStackOnly() const
Return true if we know that the associated functions has at most local/stack accesses.
Definition Attributor.h:4813
static bool requiresCalleeForCallBase()
See AbstractAttribute::requiresCalleeForCallBase.
Definition Attributor.h:4764
AccessKind
Simple enum to distinguish read/write/read-write accesses.
Definition Attributor.h:4894
@ READ_WRITE
Definition Attributor.h:4898
@ WRITE
Definition Attributor.h:4897
@ NONE
Definition Attributor.h:4895
@ READ
Definition Attributor.h:4896
StateType::base_t MemoryLocationsKind
Definition Attributor.h:4759
MemoryLocationsKind getAssumedNotAccessedLocation() const
Return the locations that are assumed to be not accessed by the associated function,...
Definition Attributor.h:4875
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAMemoryLocation.
Definition Attributor.h:4929
static bool hasTrivialInitializer()
See AbstractAttribute::hasTrivialInitializer.
Definition Attributor.h:4767
bool isAssumedReadNone() const
Return true if we assume that the associated functions has no observable accesses.
Definition Attributor.h:4807
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:4770
virtual bool checkForAllAccessesToMemoryKind(function_ref< bool(const Instruction *, const Value *, AccessKind, MemoryLocationsKind)> Pred, MemoryLocationsKind MLK) const =0
Check Pred on all accesses to the memory kinds specified by MLK.
const std::string getAsStr(Attributor *A) const override
See AbstractState::getAsStr(Attributor).
Definition Attributor.h:4917
bool mayAccessArgMem() const
Return true if the underlying value may access memory through arguement pointers of the associated fu...
Definition Attributor.h:4865
bool isAssumedArgMemOnly() const
Return true if we assume that the underlying value will only access argument pointees (see Attribute:...
Definition Attributor.h:4843
static MemoryLocationsKind inverseLocation(MemoryLocationsKind Loc, bool AndLocalMem, bool AndConstMem)
Return the inverse of location Loc, thus for NO_XXX the return describes ONLY_XXX.
Definition Attributor.h:4885
An abstract interface for all nonnull attributes.
Definition Attributor.h:3636
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:3659
bool isKnownMustProgress() const
Return true if we know that underlying value is nonnull.
Definition Attributor.h:3652
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAMustProgress.
Definition Attributor.h:3666
bool isAssumedMustProgress() const
Return true if we assume that the underlying value is nonnull.
Definition Attributor.h:3649
static bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
Definition Attributor.h:3639
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:3662
static LLVM_ABI AAMustProgress & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:3671
AAMustProgress(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:3637
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAAssumptionInfo.
Definition Attributor.h:6468
static bool requiresCallersForArgOrFunction()
See AbstractAttribute::requiresCallersForArgOrFunction.
Definition Attributor.h:6455
IntervalMap< unsigned, bool > RangeMap
Definition Attributor.h:6443
static LLVM_ABI AANoAliasAddrSpace & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
RangeMap Map
Definition Attributor.h:6477
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:6448
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:6473
AANoAliasAddrSpace(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:6444
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:6464
StateWrapper< BooleanState, AbstractAttribute > Base
Definition Attributor.h:6442
RangeMap::Allocator Allocator
Definition Attributor.h:6476
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:6461
An abstract interface for all noalias attributes.
Definition Attributor.h:3898
static LLVM_ABI bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
See IRAttribute::isImpliedByIR.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoAlias.
Definition Attributor.h:3933
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:3927
static bool requiresCallersForArgOrFunction()
See AbstractAttribute::requiresCallersForArgOrFunction.
Definition Attributor.h:3914
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:3930
bool isKnownNoAlias() const
Return true if we know that underlying value is noalias.
Definition Attributor.h:3920
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:3938
bool isAssumedNoAlias() const
Return true if we assume that the underlying value is alias.
Definition Attributor.h:3917
static LLVM_ABI AANoAlias & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AANoAlias(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:3899
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:3902
An abstract interface for all nocapture attributes.
Definition Attributor.h:4403
static LLVM_ABI AANoCapture & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:4418
@ NOT_CAPTURED_IN_RET
Definition Attributor.h:4429
@ NO_CAPTURE_MAYBE_RETURNED
If we do not capture the value in memory or through integers we can only communicate it back as a der...
Definition Attributor.h:4433
@ NOT_CAPTURED_IN_INT
Definition Attributor.h:4428
@ NO_CAPTURE
If we do not capture the value in memory, through integers, or as a derived pointer we know it is not...
Definition Attributor.h:4437
@ NOT_CAPTURED_IN_MEM
Definition Attributor.h:4427
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:4469
AANoCapture(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:4404
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:4466
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:4477
bool isAssumedNoCaptureMaybeReturned() const
Return true if we assume that the underlying value is not captured in its respective scope but we all...
Definition Attributor.h:4457
bool isKnownNoCapture() const
Return true if we know that the underlying value is not captured in its respective scope.
Definition Attributor.h:4443
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoCapture.
Definition Attributor.h:4472
bool isKnownNoCaptureMaybeReturned() const
Return true if we know that the underlying value is not captured in its respective scope but we allow...
Definition Attributor.h:4451
static LLVM_ABI bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
See IRAttribute::isImpliedByIR.
bool isAssumedNoCapture() const
Return true if we assume that the underlying value is not captured in its respective scope.
Definition Attributor.h:4447
static LLVM_ABI void determineFunctionCaptureCapabilities(const IRPosition &IRP, const Function &F, BitIntegerState &State)
Update State according to the capture capabilities of F for position IRP.
FPClassTest getAssumedNoFPClass() const
Return the underlying assumed nofpclass.
Definition Attributor.h:5484
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:5471
AANoFPClass(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:5468
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:5497
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoFPClass.
Definition Attributor.h:5503
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:5508
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:5500
FPClassTest getKnownNoFPClass() const
Return the underlying known nofpclass.
Definition Attributor.h:5488
StateWrapper< BitIntegerState< uint32_t, fcAllFlags, fcNone >, AbstractAttribute > Base
Definition Attributor.h:5465
static LLVM_ABI AANoFPClass & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
An AbstractAttribute for nofree.
Definition Attributor.h:3945
bool isKnownNoFree() const
Return true if "nofree" is known.
Definition Attributor.h:3971
static LLVM_ABI AANoFree & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AANoFree(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:3946
static bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
See IRAttribute::isImpliedByIR.
Definition Attributor.h:3949
bool isAssumedNoFree() const
Return true if "nofree" is assumed.
Definition Attributor.h:3968
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:3989
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:3960
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoFree.
Definition Attributor.h:3984
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:3978
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:3981
An abstract attribute for norecurse.
Definition Attributor.h:3730
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:3744
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoRecurse.
Definition Attributor.h:3750
AANoRecurse(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:3731
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:3747
bool isAssumedNoRecurse() const
Return true if "norecurse" is assumed.
Definition Attributor.h:3734
static LLVM_ABI AANoRecurse & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
bool isKnownNoRecurse() const
Return true if "norecurse" is known.
Definition Attributor.h:3737
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:3755
An AbstractAttribute for noreturn.
Definition Attributor.h:3996
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoReturn.
Definition Attributor.h:4016
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:4021
bool isAssumedNoReturn() const
Return true if the underlying object is assumed to never return.
Definition Attributor.h:4000
static LLVM_ABI AANoReturn & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:4010
AANoReturn(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:3997
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:4013
bool isKnownNoReturn() const
Return true if the underlying object is known to never return.
Definition Attributor.h:4003
Definition Attributor.h:3550
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:3584
AANoSync(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:3551
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:3621
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:3618
static bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
Definition Attributor.h:3553
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:3629
static LLVM_ABI bool isAlignedBarrier(const CallBase &CB, bool ExecutedAligned)
Helper function to determine if CB is an aligned (GPU) barrier.
bool isAssumedNoSync() const
Returns true if "nosync" is assumed.
Definition Attributor.h:3592
static LLVM_ABI bool isNonRelaxedAtomic(const Instruction *I)
Helper function used to determine whether an instruction is non-relaxed atomic.
bool isKnownNoSync() const
Returns true if "nosync" is known.
Definition Attributor.h:3595
static LLVM_ABI AANoSync & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static LLVM_ABI bool isNoSyncIntrinsic(const Instruction *I)
Helper function specific for intrinsics which are potentially volatile.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoSync.
Definition Attributor.h:3624
An abstract interface for all noundef attributes.
Definition Attributor.h:5420
bool isKnownNoUndef() const
Return true if we know that underlying value is noundef.
Definition Attributor.h:5438
static bool isImpliedByUndef()
See IRAttribute::isImpliedByUndef.
Definition Attributor.h:5424
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:5445
bool isAssumedNoUndef() const
Return true if we assume that the underlying value is noundef.
Definition Attributor.h:5435
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoUndef.
Definition Attributor.h:5451
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:5448
static LLVM_ABI AANoUndef & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AANoUndef(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:5421
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:5456
static bool isImpliedByPoison()
See IRAttribute::isImpliedByPoison.
Definition Attributor.h:5427
static LLVM_ABI bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
See IRAttribute::isImpliedByIR.
Definition Attributor.h:3519
AANoUnwind(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:3520
bool isAssumedNoUnwind() const
Returns true if nounwind is assumed.
Definition Attributor.h:3523
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANoUnwind.
Definition Attributor.h:3539
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:3533
static LLVM_ABI AANoUnwind & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:3544
bool isKnownNoUnwind() const
Returns true if nounwind is known.
Definition Attributor.h:3526
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:3536
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:5819
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:5810
StateWrapper< BooleanState, AbstractAttribute > Base
Definition Attributor.h:5792
static LLVM_ABI AANonConvergent & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:5807
bool isAssumedNotConvergent() const
Return true if "non-convergent" is assumed.
Definition Attributor.h:5801
bool isKnownNotConvergent() const
Return true if "non-convergent" is known.
Definition Attributor.h:5804
AANonConvergent(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:5794
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANonConvergent.
Definition Attributor.h:5814
An abstract interface for all nonnull attributes.
Definition Attributor.h:3678
static bool isImpliedByUndef()
See IRAttribute::isImpliedByUndef.
Definition Attributor.h:3687
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:3690
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:3723
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:3715
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AANonNull.
Definition Attributor.h:3718
static LLVM_ABI AANonNull & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AANonNull(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:3679
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:3712
static LLVM_ABI bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
See AbstractAttribute::isImpliedByIR(...).
bool isAssumedNonNull() const
Return true if we assume that the underlying value is nonnull.
Definition Attributor.h:3702
bool isKnownNonNull() const
Return true if we know that underlying value is nonnull.
Definition Attributor.h:3705
static bool hasTrivialInitializer()
See AbstractAttribute::hasTrivialInitializer.
Definition Attributor.h:3682
An access description.
Definition Attributor.h:6056
bool isWrittenValueUnknown() const
Return true if the value written cannot be determined at all.
Definition Attributor.h:6162
const_iterator end() const
Definition Attributor.h:6201
bool operator!=(const Access &R) const
Definition Attributor.h:6087
std::optional< Value * > getContent() const
Return the written value which can be llvm::null if it is not yet determined.
Definition Attributor.h:6181
Access & operator=(const Access &Other)=default
bool isAssumption() const
Return true if this is an assumption access.
Definition Attributor.h:6135
void setWrittenValueUnknown()
Set the value written to nullptr, i.e., unknown.
Definition Attributor.h:6167
const RangeList & getRanges() const
Definition Attributor.h:6197
void verify()
Definition Attributor.h:6113
bool isWriteOrAssumption() const
Return true if this is a write access.
Definition Attributor.h:6132
bool isRead() const
Return true if this is a read access.
Definition Attributor.h:6126
bool isWrite() const
Return true if this is a write access.
Definition Attributor.h:6129
Value * getWrittenValue() const
Return the value writen, if any.
Definition Attributor.h:6173
Instruction * getLocalInst() const
Return the instruction that causes the access with respect to the local scope of the associated attri...
Definition Attributor.h:6153
Access(Instruction *LocalI, Instruction *RemoteI, const RangeList &Ranges, std::optional< Value * > Content, AccessKind K, Type *Ty)
Definition Attributor.h:6063
bool hasUniqueRange() const
Definition Attributor.h:6183
bool isMayAccess() const
Definition Attributor.h:6144
Access(Instruction *LocalI, Instruction *RemoteI, int64_t Offset, int64_t Size, std::optional< Value * > Content, AccessKind Kind, Type *Ty)
Definition Attributor.h:6073
Access(Instruction *I, int64_t Offset, int64_t Size, std::optional< Value * > Content, AccessKind Kind, Type *Ty)
Definition Attributor.h:6057
Access(const Access &Other)=default
Type * getType() const
Return the type associated with the access, if known.
Definition Attributor.h:6170
Access & operator&=(const Access &R)
Definition Attributor.h:6089
const_iterator begin() const
Definition Attributor.h:6200
void addRange(int64_t Offset, int64_t Size)
Add a range accessed by this Access.
Definition Attributor.h:6189
RangeList::const_iterator const_iterator
Definition Attributor.h:6199
Instruction * getRemoteInst() const
Return the actual instruction that causes the access.
Definition Attributor.h:6156
const AA::RangeTy & getUniqueRange() const
Definition Attributor.h:6184
bool operator==(const Access &R) const
Definition Attributor.h:6083
bool isMustAccess() const
Definition Attributor.h:6137
bool isWrittenValueYetUndetermined() const
Return true if the value written is not known yet.
Definition Attributor.h:6159
AccessKind getKind() const
Return the access kind.
Definition Attributor.h:6123
A helper containing a list of offsets computed for a Use.
Definition Attributor.h:5860
SmallSet< int64_t, 4 > VecTy
Definition Attributor.h:5861
void setUnknown()
Definition Attributor.h:5885
VecTy::const_iterator const_iterator
Definition Attributor.h:5862
bool isUnassigned() const
Definition Attributor.h:5875
bool operator==(const OffsetInfo &RHS) const
Definition Attributor.h:5868
bool insert(int64_t Offset)
Definition Attributor.h:5874
bool operator!=(const OffsetInfo &RHS) const
Definition Attributor.h:5872
bool isUnknown() const
Definition Attributor.h:5877
const_iterator begin() const
Definition Attributor.h:5865
const_iterator end() const
Definition Attributor.h:5866
VecTy Offsets
Definition Attributor.h:5863
bool merge(const OffsetInfo &R)
Copy offsets from R into the current list.
Definition Attributor.h:5901
void addToAll(int64_t Inc)
Definition Attributor.h:5890
A container for a list of ranges.
Definition Attributor.h:5905
const_iterator end() const
Definition Attributor.h:5930
SmallVector< RangeTy > VecTy
Definition Attributor.h:5911
void addToAllOffsets(int64_t Inc)
Add the increment Inc to the offset of every range.
Definition Attributor.h:6012
bool operator==(const RangeList &OI) const
Definition Attributor.h:5949
RangeList(ArrayRef< int64_t > Offsets, int64_t Size)
Definition Attributor.h:5917
iterator begin()
Definition Attributor.h:5927
bool isUnique() const
Return true iff there is exactly one range and it is known.
Definition Attributor.h:6023
std::pair< iterator, bool > insert(iterator Pos, const RangeTy &R)
Insert R at the given iterator Pos, and merge if necessary.
Definition Attributor.h:5986
RangeList(const RangeTy &R)
Definition Attributor.h:5916
RangeTy value_type
Definition Attributor.h:5933
VecTy::iterator iterator
Definition Attributor.h:5912
AA::RangeTy RangeTy
Definition Attributor.h:5910
bool isUnknown() const
Return true iff the list contains an unknown range.
Definition Attributor.h:6034
VecTy::const_iterator const_iterator
Definition Attributor.h:5913
const_iterator begin() const
Definition Attributor.h:5929
unsigned size() const
Definition Attributor.h:5947
bool isUnassigned() const
Return true if no ranges have been inserted.
Definition Attributor.h:6052
static void set_difference(const RangeList &L, const RangeList &R, RangeList &D)
Copy ranges from L that are not in R, into D.
Definition Attributor.h:5941
const RangeTy & getUnique() const
Return the unique range, assuming it exists.
Definition Attributor.h:6028
bool merge(const RangeList &RHS)
Merge the ranges in RHS into the current ranges.
Definition Attributor.h:5955
std::pair< iterator, bool > insert(const RangeTy &R)
Insert the given range R, maintaining sorted order.
Definition Attributor.h:6007
iterator setUnknown()
Discard all ranges and insert a single unknown range.
Definition Attributor.h:6045
void push_back(const RangeTy &R)
Definition Attributor.h:5934
VecTy Ranges
Definition Attributor.h:5914
iterator end()
Definition Attributor.h:5928
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:5827
virtual bool reachesReturn() const =0
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:6231
virtual bool forallInterferingAccesses(Attributor &A, const AbstractAttribute &QueryingAA, Instruction &I, bool FindInterferingWrites, bool FindInterferingReads, function_ref< bool(const Access &, bool)> CB, bool &HasBeenWrittenTo, AA::RangeTy &Range, function_ref< bool(const Access &)> SkipCB=nullptr) const =0
Call CB on all accesses that might interfere with I and return true if all such accesses were known a...
virtual void addReturnedOffsetsTo(OffsetInfo &) const =0
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAPointerInfo.
Definition Attributor.h:6268
OffsetBinsTy::const_iterator const_bin_iterator
Definition Attributor.h:6237
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:6234
virtual const_bin_iterator begin() const =0
DenseMap< AA::RangeTy, SmallSet< unsigned, 4 > > OffsetBinsTy
Definition Attributor.h:6236
AccessKind
Definition Attributor.h:5833
@ AK_MAY_READ
Definition Attributor.h:5849
@ AK_MAY
Definition Attributor.h:5836
@ AK_R
Definition Attributor.h:5839
@ AK_MUST
Definition Attributor.h:5835
@ AK_MUST_READ_WRITE
Definition Attributor.h:5854
@ AK_W
Definition Attributor.h:5840
@ AK_MAY_WRITE
Definition Attributor.h:5850
@ AK_MUST_READ
Definition Attributor.h:5852
@ AK_MAY_READ_WRITE
Definition Attributor.h:5851
@ AK_RW
Definition Attributor.h:5841
@ AK_ASSUMPTION
Definition Attributor.h:5846
@ AK_MUST_WRITE
Definition Attributor.h:5853
virtual bool forallInterferingAccesses(AA::RangeTy Range, function_ref< bool(const Access &, bool)> CB) const =0
Call CB on all accesses that might interfere with Range and return true if all such accesses were kno...
virtual const_bin_iterator end() const =0
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:6273
static LLVM_ABI AAPointerInfo & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AAPointerInfo(const IRPosition &IRP)
Definition Attributor.h:5824
virtual int64_t numOffsetBins() const =0
An abstract interface for potential values analysis.
Definition Attributor.h:5298
PotentialConstantIntValuesState & getState() override
See AbstractAttribute::getState(...).
Definition Attributor.h:5313
const PotentialConstantIntValuesState & getState() const override
Definition Attributor.h:5314
AAPotentialConstantValues(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:5300
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:5368
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAPotentialConstantValues.
Definition Attributor.h:5363
static bool requiresCallersForArgOrFunction()
See AbstractAttribute::requiresCallersForArgOrFunction.
Definition Attributor.h:5310
unsigned getAssumedMinTrailingZeros() const
Return the minimum trailing zeros of potential constants.
Definition Attributor.h:5343
std::optional< Constant * > getAssumedConstant(Attributor &A, const Instruction *CtxI=nullptr) const
Return assumed constant for the associated value.
Definition Attributor.h:5324
StateWrapper< PotentialConstantIntValuesState, AbstractAttribute > Base
Definition Attributor.h:5299
static LLVM_ABI AAPotentialConstantValues & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:5359
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:5356
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:5303
friend struct Attributor
Definition Attributor.h:5413
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAPotentialValues.
Definition Attributor.h:5401
PotentialLLVMValuesState & getState() override
See AbstractAttribute::getState(...).
Definition Attributor.h:5380
AAPotentialValues(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:5374
static LLVM_ABI AAPotentialValues & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
static bool requiresCallersForArgOrFunction()
See AbstractAttribute::requiresCallersForArgOrFunction.
Definition Attributor.h:5377
StateWrapper< PotentialLLVMValuesState, AbstractAttribute > Base
Definition Attributor.h:5373
const PotentialLLVMValuesState & getState() const override
Definition Attributor.h:5381
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:5397
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:5406
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:5394
static LLVM_ABI Value * getSingleValue(Attributor &A, const AbstractAttribute &AA, const IRPosition &IRP, SmallVectorImpl< AA::ValueAndContext > &Values)
Extract the single value in Values if any.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:4638
bool isAssumedPrivatizablePtr() const
Returns true if pointer privatization is assumed to be possible.
Definition Attributor.h:4645
virtual std::optional< Type * > getPrivatizableType() const =0
Return the type we can choose for a private copy of the underlying value.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:4675
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:4663
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAPricatizablePtr.
Definition Attributor.h:4670
static bool requiresCallersForArgOrFunction()
See AbstractAttribute::requiresCallersForArgOrFunction.
Definition Attributor.h:4651
static LLVM_ABI AAPrivatizablePtr & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AAPrivatizablePtr(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:4635
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:4666
bool isKnownPrivatizablePtr() const
Returns true if pointer privatization is known to be possible.
Definition Attributor.h:4648
StateWrapper< BooleanState, AbstractAttribute > Base
Definition Attributor.h:4634
static LLVM_ABI AAUndefinedBehavior & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
bool isKnownToCauseUB() const
Return true if "undefined behavior" is known.
Definition Attributor.h:3836
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:3849
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:3858
virtual bool isAssumedToCauseUB(Instruction *I) const =0
Return true if "undefined behavior" is assumed for a specific instruction.
StateWrapper< BooleanState, AbstractAttribute > Base
Definition Attributor.h:3826
AAUndefinedBehavior(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:3827
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAUndefineBehavior.
Definition Attributor.h:3853
bool isAssumedToCauseUB() const
Return true if "undefined behavior" is assumed.
Definition Attributor.h:3830
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:3846
virtual bool isKnownToCauseUB(Instruction *I) const =0
Return true if "undefined behavior" is known for a specific instruction.
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:6317
virtual bool forallUnderlyingObjects(function_ref< bool(Value &)> Pred, AA::ValueScope Scope=AA::Interprocedural) const =0
Check Pred on all underlying objects in Scope collected so far.
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:6334
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAUnderlyingObjects.
Definition Attributor.h:6338
static LLVM_ABI AAUnderlyingObjects & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute biew for the position IRP.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:6343
AAUnderlyingObjects(const IRPosition &IRP)
Definition Attributor.h:6314
static bool requiresCallersForArgOrFunction()
See AbstractAttribute::requiresCallersForArgOrFunction.
Definition Attributor.h:6324
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:6331
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
See AbstractAttribute::isValidIRPositionForInit.
Definition Attributor.h:4945
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:4990
std::optional< Constant * > getAssumedConstant(Attributor &A, const Instruction *CtxI=nullptr) const
Return an assumed constant for the associated value a program point CtxI.
Definition Attributor.h:4977
virtual ConstantRange getAssumedConstantRange(Attributor &A, const Instruction *CtxI=nullptr) const =0
Return an assumed range for the associated value a program point CtxI.
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:5002
static bool requiresCallersForArgOrFunction()
See AbstractAttribute::requiresCallersForArgOrFunction.
Definition Attributor.h:4952
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAValueConstantRange.
Definition Attributor.h:4997
AAValueConstantRange(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:4941
static LLVM_ABI AAValueConstantRange & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
StateWrapper< IntegerRangeState, AbstractAttribute, uint32_t > Base
Definition Attributor.h:4940
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:4993
IntegerRangeState & getState() override
See AbstractAttribute::getState(...).
Definition Attributor.h:4955
const IntegerRangeState & getState() const override
Definition Attributor.h:4956
virtual ConstantRange getKnownConstantRange(Attributor &A, const Instruction *CtxI=nullptr) const =0
Return a known range for the associated value at a program point CtxI.
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAValueSimplify.
Definition Attributor.h:4573
friend struct Attributor
Definition Attributor.h:4589
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:4566
StateWrapper< ValueSimplifyStateType, AbstractAttribute, Type * > Base
Definition Attributor.h:4557
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:4578
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:4569
static LLVM_ABI AAValueSimplify & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
AAValueSimplify(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:4558
An abstract attribute for willreturn.
Definition Attributor.h:3762
bool isKnownWillReturn() const
Return true if "willreturn" is known.
Definition Attributor.h:3802
const char * getIdAddr() const override
See AbstractAttribute::getIdAddr()
Definition Attributor.h:3812
static LLVM_ABI const char ID
Unique ID (due to the unique address)
Definition Attributor.h:3820
static LLVM_ABI AAWillReturn & createForPosition(const IRPosition &IRP, Attributor &A)
Create an abstract attribute view for the position IRP.
StringRef getName() const override
See AbstractAttribute::getName()
Definition Attributor.h:3809
static bool classof(const AbstractAttribute *AA)
This function should return true if the type of the AA is AAWillReturn.
Definition Attributor.h:3815
AAWillReturn(const IRPosition &IRP, Attributor &A)
Definition Attributor.h:3763
static bool isImpliedByMustprogressAndReadonly(Attributor &A, const IRPosition &IRP)
Check for mustprogress and readonly as they imply willreturn.
Definition Attributor.h:3781
static bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind, bool IgnoreSubsumingPositions=false)
Definition Attributor.h:3765
bool isAssumedWillReturn() const
Return true if "willreturn" is assumed.
Definition Attributor.h:3799
Helper to represent an access offset and size, with logic to deal with uncertainty and check for over...
Definition Attributor.h:241
bool offsetAndSizeAreUnknown() const
Return true if offset and size are unknown, thus this is the default unknown object.
Definition Attributor.h:256
static constexpr int64_t Unknown
Definition Attributor.h:320
bool offsetOrSizeAreUnknown() const
Return true if offset or size are unknown.
Definition Attributor.h:250
static constexpr int64_t Unassigned
Constants used to represent special offsets or sizes.
Definition Attributor.h:319
RangeTy & operator&=(const RangeTy &R)
Definition Attributor.h:279
static RangeTy getUnknown()
Definition Attributor.h:247
bool isUnassigned() const
Return true if the offset and size are unassigned.
Definition Attributor.h:261
static bool LessThan(const RangeTy &L, const RangeTy &R)
Comparison for sorting ranges.
Definition Attributor.h:305
bool mayOverlap(const RangeTy &Range) const
Return true if this offset and size pair might describe an address that overlaps with Range.
Definition Attributor.h:269
RangeTy(int64_t Offset, int64_t Size)
Definition Attributor.h:245
int64_t Size
Definition Attributor.h:243
int64_t Offset
Definition Attributor.h:242
Definition Attributor.h:188
Value * getValue() const
Definition Attributor.h:194
std::pair< Value *, const Instruction * > Base
Definition Attributor.h:189
ValueAndContext(Value &V, const Instruction *CtxI)
Definition Attributor.h:191
const Instruction * getCtxI() const
Definition Attributor.h:195
ValueAndContext(Value &V, const Instruction &CtxI)
Definition Attributor.h:192
ValueAndContext(const Base &B)
Definition Attributor.h:190
Base struct for all "concrete attribute" deductions.
Definition Attributor.h:3322
ChangeStatus update(Attributor &A)
Hook for the Attributor to trigger an update of the internal state.
friend struct Attributor
}
Definition Attributor.h:3422
static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP)
Return false if an AA should not be created for IRP.
Definition Attributor.h:3357
virtual ChangeStatus manifest(Attributor &A)
Hook for the Attributor to trigger the manifestation of the information represented by the abstract a...
Definition Attributor.h:3437
static bool classof(const AADepGraphNode *DGN)
This function is used to identify if an DGN is of type AbstractAttribute so that the dyn_cast and cas...
Definition Attributor.h:3339
static bool requiresCalleeForCallBase()
Return true if this AA requires a "callee" (or an associted function) for a call site positon.
Definition Attributor.h:3347
void print(raw_ostream &OS) const
Helper functions, for debug purposes only.
Definition Attributor.h:3406
IRPosition & getIRPosition()
Definition Attributor.h:3402
virtual StateType & getState()=0
Return the internal abstract state for inspection.
virtual void initialize(Attributor &A)
Initialize the state with the information in the Attributor A.
Definition Attributor.h:3386
static bool isValidIRPositionForUpdate(Attributor &A, const IRPosition &IRP)
Return false if an AA should not be updated for IRP.
Definition Attributor.h:3362
AbstractState StateType
Definition Attributor.h:3323
void dump() const
Definition Attributor.h:3409
virtual const std::string getAsStr(Attributor *A) const =0
This function should return the "summarized" assumed state as string.
~AbstractAttribute() override=default
Virtual destructor.
static constexpr Attribute::AttrKind IRAttributeKind
Compile time access to the IR attribute kind.
Definition Attributor.h:3331
virtual bool isQueryAA() const
A query AA is always scheduled as long as we do updates because it does lazy computation that cannot ...
Definition Attributor.h:3394
virtual const StateType & getState() const =0
AbstractAttribute(const IRPosition &IRP)
Definition Attributor.h:3325
static bool requiresNonAsmForCallBase()
Return true if this AA requires non-asm "callee" for a call site positon.
Definition Attributor.h:3350
virtual ChangeStatus updateImpl(Attributor &A)=0
The actual update/transfer function which has to be implemented by the derived classes.
virtual void trackStatistics() const =0
Hook to enable custom statistic tracking, called after manifest that resulted in a change if statisti...
static bool requiresCallersForArgOrFunction()
Return true if this AA requires all callees for an argument or function positon.
Definition Attributor.h:3354
virtual StringRef getName() const =0
This function should return the name of the AbstractAttribute.
const IRPosition & getIRPosition() const
Return an IR position, see struct IRPosition.
Definition Attributor.h:3401
virtual const char * getIdAddr() const =0
This function should return the address of the ID of the AbstractAttribute.
static bool hasTrivialInitializer()
Return false if this AA does anything non-trivial (hence not done by default) in its initializer.
Definition Attributor.h:3343
An interface to query the internal state of an abstract attribute.
Definition Attributor.h:2642
virtual ~AbstractState()=default
virtual ChangeStatus indicatePessimisticFixpoint()=0
Indicate that the abstract state should converge to the pessimistic state.
virtual bool isAtFixpoint() const =0
Return if this abstract state is fixed, thus does not need to be updated if information changes as it...
virtual bool isValidState() const =0
Return if this abstract state is in a valid state.
virtual ChangeStatus indicateOptimisticFixpoint()=0
Indicate that the abstract state should converge to the optimistic state.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Wrapper for FunctionAnalysisManager.
Definition Attributor.h:1134
static constexpr bool HasLegacyWrapper
Definition Attributor.h:1147
Analysis::Result * getAnalysis(const Function &F, bool RequestCachedOnly=false)
Definition Attributor.h:1150
AnalysisGetter(FunctionAnalysisManager &FAM, bool CachedOnly=false)
Definition Attributor.h:1179
void invalidateAnalyses()
Invalidates the analyses. Valid only when using the new pass manager.
Definition Attributor.h:1174
AnalysisGetter(Pass *P, bool CachedOnly=false)
Definition Attributor.h:1181
Definition Attributor.h:3480
LLVM_ABI PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR)
Definition Attributor.h:5602
~AttributorCallGraph() override=default
AACallEdgeIterator optimisticEdgesEnd() const override
Definition Attributor.h:5610
AttributorCallGraph(Attributor &A)
Definition Attributor.h:5603
AACallEdgeIterator optimisticEdgesBegin() const override
Definition Attributor.h:5606
void populateAll() const
Force populate the entire call graph.
Definition Attributor.h:5615
Configuration for the Attributor.
Definition Attributor.h:1439
bool UseLiveness
Flag to determine if we should skip all liveness checks early on.
Definition Attributor.h:1463
std::function< void(Attributor &A, const Function &F)> InitializationCallback
Callback function to be invoked on internal functions marked live.
Definition Attributor.h:1470
std::optional< unsigned > MaxFixpointIterations
Maximum number of iterations to run until fixpoint.
Definition Attributor.h:1486
DenseSet< const char * > * Allowed
If not null, a set limiting the attribute opportunities.
Definition Attributor.h:1483
bool RewriteSignatures
Flag to determine if we rewrite function signatures.
Definition Attributor.h:1456
const char * PassName
}
Definition Attributor.h:1496
OptimizationRemarkGetter OREGetter
Definition Attributor.h:1492
bool DeleteFns
Flag to determine if we can delete functions or keep dead ones around.
Definition Attributor.h:1453
std::function< bool(const Function &F)> IPOAmendableCBTy
Definition Attributor.h:1498
bool IsClosedWorldModule
Flag to indicate if the entire world is contained in this module, that is, no outside functions exist...
Definition Attributor.h:1467
function_ref< OptimizationRemarkEmitter &(Function *)> OptimizationRemarkGetter
A callback function that returns an ORE object from a Function pointer.
Definition Attributor.h:1490
CallGraphUpdater & CGUpdater
Helper to update an underlying call graph and to delete functions.
Definition Attributor.h:1480
IPOAmendableCBTy IPOAmendableCB
Definition Attributor.h:1499
bool IsModulePass
Is the user of the Attributor a module pass or not.
Definition Attributor.h:1450
std::function< bool(Attributor &A, const AbstractAttribute &AA, CallBase &CB, Function &AssumedCallee, unsigned NumAssumedCallees)> IndirectCalleeSpecializationCallback
Callback function to determine if an indirect call targets should be made direct call targets (with a...
Definition Attributor.h:1477
bool DefaultInitializeLiveInternals
Flag to determine if we want to initialize all default AAs for an internal function marked live.
Definition Attributor.h:1460
AttributorConfig(CallGraphUpdater &CGUpdater)
Definition Attributor.h:1441
A more lightweight version of the Attributor which only runs attribute inference but no simplificatio...
Definition Attributor.h:3495
LLVM_ABI PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR)
A more lightweight version of the Attributor which only runs attribute inference but no simplificatio...
Definition Attributor.h:3488
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
}
Definition Attributor.h:3477
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Helper struct used in the communication between an abstract attribute (AA) that wants to change the s...
Definition Attributor.h:2245
friend struct Attributor
Allow access to the private members from the Attributor.
Definition Attributor.h:2315
std::function< void( const ArgumentReplacementInfo &, Function &, Function::arg_iterator)> CalleeRepairCBTy
Callee repair callback type.
Definition Attributor.h:2253
unsigned getNumReplacementArgs() const
Definition Attributor.h:2276
const SmallVectorImpl< Type * > & getReplacementTypes() const
Definition Attributor.h:2277
const Argument & getReplacedArg() const
Definition Attributor.h:2275
Attributor & getAttributor() const
Simple getters, see the corresponding members for details.
Definition Attributor.h:2273
const Function & getReplacedFn() const
Definition Attributor.h:2274
std::function< void(const ArgumentReplacementInfo &, AbstractCallSite, SmallVectorImpl< Value * > &)> ACSRepairCBTy
Abstract call site (ACS) repair callback type.
Definition Attributor.h:2266
The fixpoint analysis framework that orchestrates the attribute deduction.
Definition Attributor.h:1533
LLVM_ABI bool registerFunctionSignatureRewrite(Argument &Arg, ArrayRef< Type * > ReplacementTypes, ArgumentReplacementInfo::CalleeRepairCBTy &&CalleeRepairCB, ArgumentReplacementInfo::ACSRepairCBTy &&ACSRepairCB)
Register a rewrite for a function signature.
AAType & registerAA(AAType &AA)
Introduce a new abstract attribute into the fixpoint analysis.
Definition Attributor.h:1719
LLVM_ABI bool checkForAllCallees(function_ref< bool(ArrayRef< const Function * > Callees)> Pred, const AbstractAttribute &QueryingAA, const CallBase &CB)
Check Pred on all potential Callees of CB.
bool isModulePass() const
Return true if this is a module pass, false otherwise.
Definition Attributor.h:1743
void registerInvokeWithDeadSuccessor(InvokeInst &II)
Record that II has at least one dead successor block.
Definition Attributor.h:1903
void registerSimplificationCallback(const IRPosition &IRP, const SimplifictionCallbackTy &CB)
Definition Attributor.h:2043
bool changeAfterManifest(const IRPosition IRP, Value &NV, bool ChangeDroppable=true)
Helper function to replace all uses associated with IRP with NV.
Definition Attributor.h:1875
LLVM_ABI bool isValidFunctionSignatureRewrite(Argument &Arg, ArrayRef< Type * > ReplacementTypes)
Check if we can rewrite a function signature.
static LLVM_ABI bool isInternalizable(Function &F)
Returns true if the function F can be internalized.
LLVM_ABI ChangeStatus removeAttrs(const IRPosition &IRP, ArrayRef< Attribute::AttrKind > AttrKinds)
Remove all AttrKinds attached to IRP.
void emitRemark(Instruction *I, StringRef RemarkName, RemarkCallBack &&RemarkCB) const
Emit a remark generically.
Definition Attributor.h:2201
bool isRunOn(Function &Fn) const
Return true if we derive attributes for Fn.
Definition Attributor.h:1761
LLVM_ABI bool isAssumedDead(const AbstractAttribute &AA, const AAIsDead *LivenessAA, bool &UsedAssumedInformation, bool CheckBBLivenessOnly=false, DepClassTy DepClass=DepClassTy::OPTIONAL)
Return true if AA (or its context instruction) is assumed dead.
LLVM_ABI bool checkForAllInstructions(function_ref< bool(Instruction &)> Pred, const Function *Fn, const AbstractAttribute *QueryingAA, ArrayRef< unsigned > Opcodes, bool &UsedAssumedInformation, bool CheckBBLivenessOnly=false, bool CheckPotentiallyDead=false)
Check Pred on all instructions in Fn with an opcode present in Opcodes.
LLVM_ABI void recordDependence(const AbstractAttribute &FromAA, const AbstractAttribute &ToAA, DepClassTy DepClass)
Explicitly record a dependence from FromAA to ToAA, that is if FromAA changes ToAA should be updated ...
static LLVM_ABI void createShallowWrapper(Function &F)
Create a shallow wrapper for F such that F has internal linkage afterwards.
bool isRunOn(Function *Fn) const
Definition Attributor.h:1762
const AAType * getAAFor(const AbstractAttribute &QueryingAA, const IRPosition &IRP, DepClassTy DepClass)
Lookup an abstract attribute of type AAType at position IRP.
Definition Attributor.h:1577
std::function< std::optional< Value * >( const IRPosition &, const AbstractAttribute *, bool &)> SimplifictionCallbackTy
Register CB as a simplification callback.
Definition Attributor.h:2041
std::optional< Constant * > getAssumedInitializerFromCallBack(const GlobalVariable &GV, const AbstractAttribute *AA, bool &UsedAssumedInformation)
Return std::nullopt if there is no call back registered for GV or the call back is still not sure if ...
Definition Attributor.h:2074
void deleteAfterManifest(Function &F)
Record that F is deleted after information was manifested.
Definition Attributor.h:1922
std::optional< Value * > getAssumedSimplified(const IRPosition &IRP, const AbstractAttribute &AA, bool &UsedAssumedInformation, AA::ValueScope S)
If V is assumed simplified, return it, if it is unclear yet, return std::nullopt, otherwise return nu...
Definition Attributor.h:2002
void emitRemark(Function *F, StringRef RemarkName, RemarkCallBack &&RemarkCB) const
Emit a remark on a function.
Definition Attributor.h:2222
static LLVM_ABI Function * internalizeFunction(Function &F, bool Force=false)
Make another copy of the function F such that the copied version has internal linkage afterwards and ...
bool isFunctionIPOAmendable(const Function &F)
Determine whether the function F is IPO amendable.
Definition Attributor.h:1840
const AAType * getOrCreateAAFor(IRPosition IRP, const AbstractAttribute *QueryingAA, DepClassTy DepClass, bool ForceUpdate=false, bool UpdateAfterInit=true)
The version of getAAFor that allows to omit a querying abstract attribute.
Definition Attributor.h:1589
const SmallSetVector< Function *, 8 > & getModifiedFunctions()
Definition Attributor.h:2486
LLVM_ABI bool checkForAllReadWriteInstructions(function_ref< bool(Instruction &)> Pred, AbstractAttribute &QueryingAA, bool &UsedAssumedInformation)
Check Pred on all Read/Write instructions.
void changeToUnreachableAfterManifest(Instruction *I)
Record that I is to be replaced with unreachable after information was manifested.
Definition Attributor.h:1896
bool hasGlobalVariableSimplificationCallback(const GlobalVariable &GV)
Return true if there is a simplification callback for GV.
Definition Attributor.h:2066
std::optional< Constant * > getAssumedConstant(const Value &V, const AbstractAttribute &AA, bool &UsedAssumedInformation)
Definition Attributor.h:1994
LLVM_ABI bool checkForAllReturnedValues(function_ref< bool(Value &)> Pred, const AbstractAttribute &QueryingAA, AA::ValueScope S=AA::ValueScope::Intraprocedural, bool RecurseForSelectAndPHI=true)
Check Pred on all values potentially returned by the function associated with QueryingAA.
bool hasSimplificationCallback(const IRPosition &IRP)
Return true if there is a simplification callback for IRP.
Definition Attributor.h:2049
std::function< std::optional< Constant * >( const GlobalVariable &, const AbstractAttribute *, bool &)> GlobalVariableSimplifictionCallbackTy
Register CB as a simplification callback.
Definition Attributor.h:2056
LLVM_ABI bool isClosedWorldModule() const
Return true if the module contains the whole world, thus, no outside functions exist.
LLVM_ABI std::optional< Constant * > getAssumedConstant(const IRPosition &IRP, const AbstractAttribute &AA, bool &UsedAssumedInformation)
If IRP is assumed to be a constant, return it, if it is unclear yet, return std::nullopt,...
const AAType * getOrCreateAAFor(const IRPosition &IRP)
Definition Attributor.h:1659
LLVM_ABI Attributor(SetVector< Function * > &Functions, InformationCache &InfoCache, AttributorConfig Configuration)
Constructor.
void registerGlobalVariableSimplificationCallback(const GlobalVariable &GV, const GlobalVariableSimplifictionCallbackTy &CB)
Definition Attributor.h:2059
const DataLayout & getDataLayout() const
Return the data layout associated with the anchor scope.
Definition Attributor.h:2481
LLVM_ABI void getAttrs(const IRPosition &IRP, ArrayRef< Attribute::AttrKind > AKs, SmallVectorImpl< Attribute > &Attrs, bool IgnoreSubsumingPositions=false)
Return the attributes of any kind in AKs existing in the IR at a position that will affect this one.
InformationCache & getInfoCache()
Return the internal information cache.
Definition Attributor.h:1740
bool changeUseAfterManifest(Use &U, Value &NV)
Record that U is to be replaces with NV after information was manifested.
Definition Attributor.h:1861
LLVM_ABI std::optional< Value * > translateArgumentToCallSiteContent(std::optional< Value * > V, CallBase &CB, const AbstractAttribute &AA, bool &UsedAssumedInformation)
Translate V from the callee context into the call site context.
AAType * lookupAAFor(const IRPosition &IRP, const AbstractAttribute *QueryingAA=nullptr, DepClassTy DepClass=DepClassTy::OPTIONAL, bool AllowInvalidState=false)
Return the attribute of AAType for IRP if existing and valid.
Definition Attributor.h:1667
void markLiveInternalFunction(const Function &F)
Mark the internal function F as live.
Definition Attributor.h:1849
void registerManifestAddedBasicBlock(BasicBlock &BB)
Definition Attributor.h:1917
void registerVirtualUseCallback(const Value &V, const VirtualUseCallbackTy &CB)
Definition Attributor.h:2089
LLVM_ABI bool checkForAllUses(function_ref< bool(const Use &, bool &)> Pred, const AbstractAttribute &QueryingAA, const Value &V, bool CheckBBLivenessOnly=false, DepClassTy LivenessDepClass=DepClassTy::OPTIONAL, bool IgnoreDroppableUses=true, function_ref< bool(const Use &OldU, const Use &NewU)> EquivalentUseCB=nullptr)
Check Pred on all (transitive) uses of V.
LLVM_ABI ChangeStatus manifestAttrs(const IRPosition &IRP, ArrayRef< Attribute > DeducedAttrs, bool ForceReplace=false)
Attach DeducedAttrs to IRP, if ForceReplace is set we do this even if the same attribute kind was alr...
LLVM_ABI bool hasAttr(const IRPosition &IRP, ArrayRef< Attribute::AttrKind > AKs, bool IgnoreSubsumingPositions=false, Attribute::AttrKind ImpliedAttributeKind=Attribute::None)
Return true if any kind in AKs existing in the IR at a position that will affect this one.
LLVM_ABI void registerForUpdate(AbstractAttribute &AA)
Allows a query AA to request an update if a new query was received.
void deleteAfterManifest(Instruction &I)
Record that I is deleted after information was manifested.
Definition Attributor.h:1909
std::function< bool(Attributor &, const AbstractAttribute *)> VirtualUseCallbackTy
Definition Attributor.h:2087
void deleteAfterManifest(BasicBlock &BB)
Record that BB is deleted after information was manifested.
Definition Attributor.h:1913
LLVM_ABI void identifyDefaultAbstractAttributes(Function &F)
Determine opportunities to derive 'default' attributes in F and create abstract attribute objects for...
bool shouldInitialize(const IRPosition &IRP, bool &ShouldUpdateAA)
Definition Attributor.h:1802
LLVM_ABI bool getAssumedSimplifiedValues(const IRPosition &IRP, const AbstractAttribute *AA, SmallVectorImpl< AA::ValueAndContext > &Values, AA::ValueScope S, bool &UsedAssumedInformation, bool RecurseForSelectAndPHI=true)
Try to simplify IRP and in the scope S.
BumpPtrAllocator & Allocator
The allocator used to allocate memory, e.g. for AbstractAttributes.
Definition Attributor.h:2484
bool checkForAllCallLikeInstructions(function_ref< bool(Instruction &)> Pred, const AbstractAttribute &QueryingAA, bool &UsedAssumedInformation, bool CheckBBLivenessOnly=false, bool CheckPotentiallyDead=false)
Check Pred on all call-like instructions (=CallBased derived).
Definition Attributor.h:2405
bool shouldSpecializeCallSiteForCallee(const AbstractAttribute &AA, CallBase &CB, Function &Callee, unsigned NumAssumedCallees)
Return true if we should specialize the call site CB for the potential callee Fn.
Definition Attributor.h:1747
LLVM_ABI ChangeStatus run()
Run the analyses until a fixpoint is reached or enforced (timeout).
static LLVM_ABI bool internalizeFunctions(SmallPtrSetImpl< Function * > &FnSet, DenseMap< Function *, Function * > &FnMap)
Make copies of each function in the set FnSet such that the copied version has internal linkage after...
std::optional< Value * > getAssumedSimplified(const Value &V, const AbstractAttribute &AA, bool &UsedAssumedInformation, AA::ValueScope S)
Definition Attributor.h:2008
bool shouldUpdateAA(const IRPosition &IRP)
Definition Attributor.h:1766
LLVM_ABI bool checkForAllCallSites(function_ref< bool(AbstractCallSite)> Pred, const AbstractAttribute &QueryingAA, bool RequireAllCallSites, bool &UsedAssumedInformation)
Check Pred on all function call sites.
LLVM_ABI bool getAttrsFromAssumes(const IRPosition &IRP, Attribute::AttrKind AK, SmallVectorImpl< Attribute > &Attrs)
Return the attributes of kind AK existing in the IR as operand bundles of an llvm....
Specialization of the integer state for a bit-wise encoding.
Definition Attributor.h:2783
BitIntegerState & removeKnownBits(base_t BitsEncoding)
Remove the bits in BitsEncoding from the "known bits".
Definition Attributor.h:2813
BitIntegerState()=default
bool isAssumed(base_t BitsEncoding=BestState) const
Return true if the bits set in BitsEncoding are "assumed bits".
Definition Attributor.h:2795
IntegerStateBase< base_ty, BestState, WorstState > super
Definition Attributor.h:2784
BitIntegerState(base_t Assumed)
Definition Attributor.h:2787
BitIntegerState & removeAssumedBits(base_t BitsEncoding)
Remove the bits in BitsEncoding from the "assumed bits" if not known.
Definition Attributor.h:2808
BitIntegerState & intersectAssumedBits(base_t BitsEncoding)
Keep only "assumed bits" also set in BitsEncoding but all known ones.
Definition Attributor.h:2819
base_ty base_t
Definition Attributor.h:2785
bool isKnown(base_t BitsEncoding=BestState) const
Return true if the bits set in BitsEncoding are "known bits".
Definition Attributor.h:2790
BitIntegerState & addKnownBits(base_t Bits)
Add the bits in BitsEncoding to the "known bits".
Definition Attributor.h:2800
Simple wrapper for a single bit (boolean) state.
Definition Attributor.h:2926
IntegerStateBase< bool, true, false > super
Definition Attributor.h:2927
bool isKnown() const
Return true if the state is known to hold.
Definition Attributor.h:2946
void setKnown(bool Value)
Set the known and asssumed value to Value.
Definition Attributor.h:2937
IntegerStateBase::base_t base_t
Definition Attributor.h:2928
BooleanState(base_t Assumed)
Definition Attributor.h:2931
void setAssumed(bool Value)
Set the assumed value to Value but never below the known one.
Definition Attributor.h:2934
bool isAssumed() const
Return true if the state is assumed to hold.
Definition Attributor.h:2943
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
static bool isNodeHidden(const AACallGraphNode *Node, const AttributorCallGraph *Graph)
Definition Attributor.h:5666
DOTGraphTraits(bool Simple=false)
Definition Attributor.h:5658
std::string getNodeLabel(const AACallGraphNode *Node, const AttributorCallGraph *Graph)
Definition Attributor.h:5660
DefaultDOTGraphTraits(bool simple=false)
Specialization of the integer state for a decreasing value, hence 0 is the best state and ~0u the wor...
Definition Attributor.h:2892
base_ty base_t
Definition Attributor.h:2893
DecIntegerState & takeKnownMinimum(base_t Value)
Take minimum of known and Value.
Definition Attributor.h:2903
DecIntegerState & takeAssumedMaximum(base_t Value)
Take maximum of assumed and Value.
Definition Attributor.h:2896
Definition Attributor.h:5188
static DenormalMode unionAssumed(DenormalMode Callee, DenormalMode Caller)
Definition Attributor.h:5214
DenormalState unionWith(DenormalState Caller) const
Definition Attributor.h:5219
bool operator!=(const DenormalState Other) const
Definition Attributor.h:5196
DenormalMode ModeF32
Definition Attributor.h:5190
DenormalMode Mode
Definition Attributor.h:5189
bool operator==(const DenormalState Other) const
Definition Attributor.h:5192
bool isValid() const
Definition Attributor.h:5200
static DenormalMode::DenormalModeKind unionDenormalKind(DenormalMode::DenormalModeKind Callee, DenormalMode::DenormalModeKind Caller)
Definition Attributor.h:5203
bool IsAtFixedpoint
Explicitly track whether we've hit a fixed point.
Definition Attributor.h:5230
ChangeStatus indicateOptimisticFixpoint() override
Indicate that the abstract state should converge to the optimistic state.
Definition Attributor.h:5259
DenormalState getKnown() const
Definition Attributor.h:5234
DenormalState getAssumed() const
Definition Attributor.h:5238
DenormalState Known
Definition Attributor.h:5227
bool isValidState() const override
Return if this abstract state is in a valid state.
Definition Attributor.h:5240
ChangeStatus indicatePessimisticFixpoint() override
Indicate that the abstract state should converge to the pessimistic state.
Definition Attributor.h:5263
DenormalFPMathState operator^=(const DenormalFPMathState &Caller)
Definition Attributor.h:5267
ChangeStatus indicateFixpoint()
Definition Attributor.h:5253
bool isModeFixed() const
Return true if there are no dynamic components to the denormal mode worth specializing.
Definition Attributor.h:5244
bool isAtFixpoint() const override
Return if this abstract state is fixed, thus does not need to be updated if information changes as it...
Definition Attributor.h:5251
DenormalFPMathState()=default
Represent subnormal handling kind for floating point instruction inputs and outputs.
DenormalModeKind
Represent handled modes for denormal (aka subnormal) modes in the floating point environment.
@ Dynamic
Denormals have unknown treatment.
static constexpr DenormalMode getInvalid()
static bool isEqual(const AA::ValueAndContext &LHS, const AA::ValueAndContext &RHS)
Definition Attributor.h:432
static AA::ValueAndContext getEmptyKey()
Definition Attributor.h:422
static unsigned getHashValue(const AA::ValueAndContext &VAC)
Definition Attributor.h:428
DenseMapInfo< AA::ValueAndContext::Base > Base
Definition Attributor.h:421
static AA::ValueAndContext getTombstoneKey()
Definition Attributor.h:425
static AA::ValueScope getTombstoneKey()
Definition Attributor.h:444
static AA::ValueScope getEmptyKey()
Definition Attributor.h:441
static bool isEqual(const AA::ValueScope &LHS, const AA::ValueScope &RHS)
Definition Attributor.h:451
DenseMapInfo< unsigned char > Base
Definition Attributor.h:440
static unsigned getHashValue(const AA::ValueScope &S)
Definition Attributor.h:447
static IRPosition getEmptyKey()
Definition Attributor.h:1085
static IRPosition getTombstoneKey()
Definition Attributor.h:1086
static bool isEqual(const IRPosition &a, const IRPosition &b)
Definition Attributor.h:1094
static unsigned getHashValue(const IRPosition &IRP)
Definition Attributor.h:1089
An information struct used to provide DenseMap with the various necessary components for a given valu...
State for dereferenceable attribute.
Definition Attributor.h:4123
IncIntegerState DerefBytesState
State representing for dereferenceable bytes.
Definition Attributor.h:4139
static DerefState getBestState(const DerefState &)
Definition Attributor.h:4126
static DerefState getWorstState()
Return the worst possible representable state.
Definition Attributor.h:4129
static DerefState getBestState()
Definition Attributor.h:4125
static DerefState getWorstState(const DerefState &)
Definition Attributor.h:4134
std::map< int64_t, uint64_t > AccessedBytesMap
Map representing for accessed memory offsets and sizes.
Definition Attributor.h:4147
static AACallEdgeIterator child_end(AACallGraphNode *Node)
Definition Attributor.h:5633
AACallEdgeIterator ChildIteratorType
Definition Attributor.h:5627
AACallGraphNode * NodeRef
Definition Attributor.h:5626
static AACallEdgeIterator child_begin(AACallGraphNode *Node)
Definition Attributor.h:5629
static AACallGraphNode * getEntryNode(AttributorCallGraph *G)
Definition Attributor.h:5643
static AACallEdgeIterator nodes_begin(const AttributorCallGraph *G)
Definition Attributor.h:5647
static AACallEdgeIterator nodes_end(const AttributorCallGraph *G)
Definition Attributor.h:5651
AACallEdgeIterator nodes_iterator
Definition Attributor.h:5641
Attribute::AttrKind getAttrKind() const
Return the kind that identifies the abstract attribute implementation.
Definition Attributor.h:3270
static constexpr Attribute::AttrKind IRAttributeKind
Compile time access to the IR attribute kind.
Definition Attributor.h:3236
static bool hasTrivialInitializer()
Most boolean IRAttribute AAs don't do anything non-trivial in their initializers while non-boolean on...
Definition Attributor.h:3233
static bool isImpliedByUndef()
Return true if the IR attribute(s) associated with this AA are implied for an undef value.
Definition Attributor.h:3240
ChangeStatus manifest(Attributor &A) override
See AbstractAttribute::manifest(...).
Definition Attributor.h:3259
static bool isImpliedByPoison()
Return true if the IR attribute(s) associated with this AA are implied for an poison value.
Definition Attributor.h:3244
static bool isImpliedByIR(Attributor &A, const IRPosition &IRP, Attribute::AttrKind ImpliedAttributeKind=AK, bool IgnoreSubsumingPositions=false)
Definition Attributor.h:3246
IRAttribute(const IRPosition &IRP)
Definition Attributor.h:3228
virtual void getDeducedAttributes(Attributor &A, LLVMContext &Ctx, SmallVectorImpl< Attribute > &Attrs) const
Return the deduced attributes in Attrs.
Definition Attributor.h:3273
Helper to describe and deal with positions in the LLVM-IR.
Definition Attributor.h:593
Function * getAssociatedFunction() const
Return the associated function, if any.
Definition Attributor.h:724
void setAttrList(const AttributeList &AttrList) const
Update the attributes associated with this function or call site scope.
Definition Attributor.h:860
unsigned getAttrIdx() const
Return the index in the attribute list for this position.
Definition Attributor.h:825
bool hasCallBaseContext() const
Check if the position has any call base context.
Definition Attributor.h:942
static const IRPosition callsite_returned(const CallBase &CB)
Create a position describing the returned value of CB.
Definition Attributor.h:661
static const IRPosition returned(const Function &F, const CallBaseContext *CBContext=nullptr)
Create a position describing the returned value of F.
Definition Attributor.h:643
LLVM_ABI Argument * getAssociatedArgument() const
Return the associated argument, if any.
bool isAnyCallSitePosition() const
Definition Attributor.h:909
bool operator!=(const IRPosition &RHS) const
Definition Attributor.h:702
static const IRPosition value(const Value &V, const CallBaseContext *CBContext=nullptr)
Create a position describing the value of V.
Definition Attributor.h:617
CallBase CallBaseContext
Definition Attributor.h:596
AttributeList getAttrList() const
Return the attributes associated with this function or call site scope.
Definition Attributor.h:853
int getCalleeArgNo() const
Return the callee argument number of the associated value if it is an argument or call site argument,...
Definition Attributor.h:811
static const IRPosition inst(const Instruction &I, const CallBaseContext *CBContext=nullptr)
Create a position describing the instruction I.
Definition Attributor.h:629
static const IRPosition callsite_argument(const CallBase &CB, unsigned ArgNo)
Create a position describing the argument of CB at position ArgNo.
Definition Attributor.h:666
static LLVM_ABI const IRPosition TombstoneKey
Definition Attributor.h:948
Kind
The positions we distinguish in the IR.
Definition Attributor.h:599
@ IRP_ARGUMENT
An attribute for a function argument.
Definition Attributor.h:607
@ IRP_RETURNED
An attribute for the function return value.
Definition Attributor.h:603
@ IRP_CALL_SITE
An attribute for a call site (function scope).
Definition Attributor.h:606
@ IRP_CALL_SITE_RETURNED
An attribute for a call site return value.
Definition Attributor.h:604
@ IRP_FUNCTION
An attribute for a function (scope).
Definition Attributor.h:605
@ IRP_FLOAT
A position that is not associated with a spot suitable for attributes.
Definition Attributor.h:601
@ IRP_CALL_SITE_ARGUMENT
An attribute for a call site argument.
Definition Attributor.h:608
@ IRP_INVALID
An invalid position.
Definition Attributor.h:600
Instruction * getCtxI() const
Return the context instruction, if any.
Definition Attributor.h:777
static const IRPosition argument(const Argument &Arg, const CallBaseContext *CBContext=nullptr)
Create a position describing the argument Arg.
Definition Attributor.h:650
Type * getAssociatedType() const
Return the type this abstract attribute is associated with.
Definition Attributor.h:800
static LLVM_ABI const IRPosition EmptyKey
Special DenseMap key values.
Definition Attributor.h:947
bool isFunctionScope() const
Return true if this is a function or call site position.
Definition Attributor.h:754
bool operator==(const IRPosition &RHS) const
Definition Attributor.h:699
static const IRPosition callsite_argument(AbstractCallSite ACS, unsigned ArgNo)
Create a position describing the argument of ACS at position ArgNo.
Definition Attributor.h:673
static const IRPosition function(const Function &F, const CallBaseContext *CBContext=nullptr)
Create a position describing the function scope of F.
Definition Attributor.h:636
const CallBaseContext * getCallBaseContext() const
Get the call base context from the position.
Definition Attributor.h:939
Value & getAssociatedValue() const
Return the value this abstract attribute is associated with.
Definition Attributor.h:791
Value * getArg(unsigned ArgNo) const
Return theargument ArgNo associated with this function or call site scope.
Definition Attributor.h:879
Value & getAnchorValue() const
Return the value this abstract attribute is anchored with.
Definition Attributor.h:710
Value * getAttrListAnchor() const
Return the value attributes are attached to.
Definition Attributor.h:846
int getCallSiteArgNo() const
Return the call site argument number of the associated value if it is an argument or call site argume...
Definition Attributor.h:820
bool isFnInterfaceKind() const
Return true if the position refers to a function interface, that is the function scope,...
Definition Attributor.h:742
static const IRPosition function_scope(const IRPosition &IRP, const CallBaseContext *CBContext=nullptr)
Create a position with function scope matching the "context" of IRP.
Definition Attributor.h:689
IRPosition stripCallBaseContext() const
Return the same position without the call base context.
Definition Attributor.h:932
unsigned getNumArgs() const
Return the number of arguments associated with this function or call site scope.
Definition Attributor.h:868
Kind getPositionKind() const
Return the associated position kind.
Definition Attributor.h:889
bool isArgumentPosition() const
Return true if the position is an argument or call site argument.
Definition Attributor.h:921
static const IRPosition callsite_function(const CallBase &CB)
Create a position describing the function scope of CB.
Definition Attributor.h:656
IRPosition()
Default constructor available to create invalid positions implicitly.
Definition Attributor.h:614
Function * getAnchorScope() const
Return the Function surrounding the anchor value.
Definition Attributor.h:765
Specialization of the integer state for an increasing value, hence ~0u is the best state and 0 the wo...
Definition Attributor.h:2845
IntegerStateBase< base_ty, BestState, WorstState > super
Definition Attributor.h:2846
static constexpr base_t getBestState(const IncIntegerState< base_ty, BestState, WorstState > &)
Definition Attributor.h:2855
IncIntegerState(base_t Assumed)
Definition Attributor.h:2850
static constexpr base_t getBestState()
Return the best possible representable state.
Definition Attributor.h:2853
IncIntegerState()
Definition Attributor.h:2849
IncIntegerState & takeAssumedMinimum(base_t Value)
Take minimum of assumed and Value.
Definition Attributor.h:2860
IncIntegerState & takeKnownMaximum(base_t Value)
Take maximum of known and Value.
Definition Attributor.h:2867
base_ty base_t
Definition Attributor.h:2847
Data structure to hold cached (LLVM-IR) information.
Definition Attributor.h:1210
friend struct Attributor
Give the Attributor access to the members so Attributor::identifyDefaultAbstractAttributes(....
Definition Attributor.h:1435
const SetVector< Function * > *const CGSCC
The CG-SCC the pass is run on, or nullptr if it is a module pass.
Definition Attributor.h:1269
bool stackIsAccessibleByOtherThreads()
Return true if the stack (llvm::Alloca) can be accessed by other threads.
Definition Attributor.h:1346
bool targetIsGPU()
Return true if the target is a GPU.
Definition Attributor.h:1349
bool isInvolvedInMustTailCall(const Argument &Arg)
Return true if Arg is involved in a must-tail call, thus the argument of the caller or callee.
Definition Attributor.h:1306
const DataLayout & getDL()
Return datalayout used in the module.
Definition Attributor.h:1327
MustBeExecutedContextExplorer * getMustBeExecutedContextExplorer()
Return MustBeExecutedContextExplorer.
Definition Attributor.h:1289
void invalidateAnalyses()
Invalidates the cached analyses.
Definition Attributor.h:1317
virtual ~InformationCache()
Definition Attributor.h:1233
virtual unsigned getMaxAddrSpace() const
Definition Attributor.h:1359
const AA::InstExclusionSetTy * getOrCreateUniqueBlockExecutionSet(const AA::InstExclusionSetTy *BES)
Given BES, return a uniqued version.
Definition Attributor.h:1334
static void foreachUse(Function &F, CBTy CB, bool LookThroughConstantExprUses=true)
Apply CB to all uses of F.
Definition Attributor.h:1250
TargetLibraryInfo * getTargetLibraryInfoForFunction(const Function &F)
Return TargetLibraryInfo for function F.
Definition Attributor.h:1294
InformationCache(const Module &M, AnalysisGetter &AG, BumpPtrAllocator &Allocator, SetVector< Function * > *CGSCC, bool UseExplorer=true)
Definition Attributor.h:1211
LLVM_ABI std::optional< unsigned > getFlatAddressSpace() const
Return the flat address space if the associated target has.
OpcodeInstMapTy & getOpcodeInstMapForFunction(const Function &F)
Return the map that relates "interesting" opcodes with all instructions with that opcode in F.
Definition Attributor.h:1279
DenseMap< unsigned, InstructionVectorTy * > OpcodeInstMapTy
A map type from opcodes to instructions with this opcode.
Definition Attributor.h:1275
const RetainedKnowledgeMap & getKnowledgeMap() const
Return the map conaining all the knowledge we have from llvm.assumes.
Definition Attributor.h:1330
LLVM_ABI ArrayRef< Function * > getIndirectlyCallableFunctions(Attributor &A) const
Return all functions that might be called indirectly, only valid for closed world modules (see isClos...
SmallVector< Instruction *, 8 > InstructionVectorTy
A vector type to hold instructions.
Definition Attributor.h:1272
InstructionVectorTy & getReadOrWriteInstsForFunction(const Function &F)
Return the instructions in F that may read or write memory.
Definition Attributor.h:1284
bool isOnlyUsedByAssume(const Instruction &I) const
Definition Attributor.h:1311
bool isKernel(const Function &F)
Return true if F has the "kernel" function attribute.
Definition Attributor.h:1299
AP::Result * getAnalysisResultForFunction(const Function &F, bool CachedOnly=false)
Return the analysis result from a pass AP for function F.
Definition Attributor.h:1321
State for an integer range.
Definition Attributor.h:2968
IntegerRangeState operator^=(const IntegerRangeState &R)
"Clamp" this state with R.
Definition Attributor.h:3059
IntegerRangeState operator&=(const IntegerRangeState &R)
Definition Attributor.h:3066
bool isAtFixpoint() const override
See AbstractState::isAtFixpoint()
Definition Attributor.h:3009
void unionAssumed(const IntegerRangeState &R)
See IntegerRangeState::unionAssumed(..).
Definition Attributor.h:3036
ConstantRange Assumed
State representing assumed range, initially set to empty.
Definition Attributor.h:2974
IntegerRangeState(const ConstantRange &CR)
Definition Attributor.h:2983
IntegerRangeState(uint32_t BitWidth)
Definition Attributor.h:2979
bool operator==(const IntegerRangeState &R) const
Equality for IntegerRangeState.
Definition Attributor.h:3052
void intersectKnown(const IntegerRangeState &R)
See IntegerRangeState::intersectKnown(..).
Definition Attributor.h:3047
static ConstantRange getBestState(const IntegerRangeState &IRS)
Definition Attributor.h:2996
bool isValidState() const override
See AbstractState::isValidState()
Definition Attributor.h:3004
uint32_t BitWidth
Bitwidth of the associated value.
Definition Attributor.h:2971
ConstantRange Known
State representing known range, initially set to [-inf, inf].
Definition Attributor.h:2977
void unionAssumed(const ConstantRange &R)
Unite assumed range with the passed state.
Definition Attributor.h:3030
ChangeStatus indicatePessimisticFixpoint() override
See AbstractState::indicatePessimisticFixpoint(...)
Definition Attributor.h:3018
ConstantRange getKnown() const
Return the known state encoding.
Definition Attributor.h:3024
void intersectKnown(const ConstantRange &R)
Intersect known range with the passed state.
Definition Attributor.h:3041
ConstantRange getAssumed() const
Return the assumed state encoding.
Definition Attributor.h:3027
uint32_t getBitWidth() const
Return associated values' bit width.
Definition Attributor.h:3001
ChangeStatus indicateOptimisticFixpoint() override
See AbstractState::indicateOptimisticFixpoint(...)
Definition Attributor.h:3012
static ConstantRange getWorstState(uint32_t BitWidth)
Return the worst possible representable state.
Definition Attributor.h:2988
static ConstantRange getBestState(uint32_t BitWidth)
Return the best possible representable state.
Definition Attributor.h:2993
Simple state with integers encoding.
Definition Attributor.h:2681
base_ty base_t
Definition Attributor.h:2682
bool isValidState() const override
See AbstractState::isValidState() NOTE: For now we simply pretend that the worst possible state is in...
Definition Attributor.h:2701
virtual void handleNewAssumedValue(base_t Value)=0
Handle a new assumed value Value. Subtype dependent.
bool isAtFixpoint() const override
See AbstractState::isAtFixpoint()
Definition Attributor.h:2704
void operator|=(const IntegerStateBase< base_t, BestState, WorstState > &R)
Definition Attributor.h:2751
virtual void handleNewKnownValue(base_t Value)=0
Handle a new known value Value. Subtype dependent.
base_t getKnown() const
Return the known state encoding.
Definition Attributor.h:2719
ChangeStatus indicateOptimisticFixpoint() override
See AbstractState::indicateOptimisticFixpoint(...)
Definition Attributor.h:2707
void operator^=(const IntegerStateBase< base_t, BestState, WorstState > &R)
"Clamp" this state with R.
Definition Attributor.h:2740
virtual void joinOR(base_t AssumedValue, base_t KnownValue)=0
Handle a value Value. Subtype dependent.
virtual void joinAND(base_t AssumedValue, base_t KnownValue)=0
Handle a new assumed value Value. Subtype dependent.
IntegerStateBase(base_t Assumed)
Definition Attributor.h:2685
void operator+=(const IntegerStateBase< base_t, BestState, WorstState > &R)
"Clamp" this state with R.
Definition Attributor.h:2747
base_t getAssumed() const
Return the assumed state encoding.
Definition Attributor.h:2722
static constexpr base_t getWorstState()
Return the worst possible representable state.
Definition Attributor.h:2694
static constexpr base_t getBestState()
Return the best possible representable state.
Definition Attributor.h:2688
ChangeStatus indicatePessimisticFixpoint() override
See AbstractState::indicatePessimisticFixpoint(...)
Definition Attributor.h:2713
IntegerStateBase()=default
base_t Known
Definition Attributor.h:2773
static constexpr base_t getWorstState(const IntegerStateBase &)
Definition Attributor.h:2695
bool operator!=(const IntegerStateBase< base_t, BestState, WorstState > &R) const
Inequality for IntegerStateBase.
Definition Attributor.h:2733
bool operator==(const IntegerStateBase< base_t, BestState, WorstState > &R) const
Equality for IntegerStateBase.
Definition Attributor.h:2726
void operator&=(const IntegerStateBase< base_t, BestState, WorstState > &R)
Definition Attributor.h:2755
base_t Assumed
Definition Attributor.h:2776
static constexpr base_t getBestState(const IntegerStateBase &)
Definition Attributor.h:2689
A "must be executed context" for a given program point PP is the set of instructions,...
A CRTP mix-in to automatically provide informational APIs needed for passes.
static constexpr int NumLowBitsAvailable
Note, we assume here that void* is related to raw malloc'ed memory and that malloc returns objects at...
A class for a set state.
Definition Attributor.h:5013
static PotentialValuesState getBestState(const PotentialValuesState &PVS)
Definition Attributor.h:5073
PotentialValuesState & getAssumed()
Return the assumed state.
Definition Attributor.h:5038
SetTy & getAssumedSet()
Definition Attributor.h:5109
bool undefIsContained() const
Returns whether this state contains an undef value or not.
Definition Attributor.h:5049
bool contains(const MemberTy &V) const
Definition Attributor.h:5104
bool isAtFixpoint() const override
See AbstractState::isAtFixpoint(...)
Definition Attributor.h:5025
PotentialValuesState()
Definition Attributor.h:5016
void unionAssumed(const MemberTy &C)
Union assumed set with the passed value.
Definition Attributor.h:5083
static PotentialValuesState getBestState()
Return empty set as the best state of potential values.
Definition Attributor.h:5069
SmallSetVector< MemberTy, 8 > SetTy
Definition Attributor.h:5014
ChangeStatus indicatePessimisticFixpoint() override
See AbstractState::indicatePessimisticFixpoint(...)
Definition Attributor.h:5028
void unionAssumed(const PotentialValuesState &PVS)
Union assumed set with assumed set of the passed state PVS.
Definition Attributor.h:5086
PotentialValuesState(bool IsValid)
Definition Attributor.h:5018
bool operator==(const PotentialValuesState &RHS) const
Definition Attributor.h:5054
bool isValidState() const override
See AbstractState::isValidState(...)
Definition Attributor.h:5022
PotentialValuesState operator&=(const PotentialValuesState &PVS)
Definition Attributor.h:5098
static unsigned MaxPotentialValues
Definition Attributor.h:5066
static PotentialValuesState getWorstState()
Return full set as the worst state of potential values.
Definition Attributor.h:5078
const PotentialValuesState & getAssumed() const
Definition Attributor.h:5039
ChangeStatus indicateOptimisticFixpoint() override
See AbstractState::indicateOptimisticFixpoint(...)
Definition Attributor.h:5033
PotentialValuesState operator^=(const PotentialValuesState &PVS)
"Clamp" this state with PVS.
Definition Attributor.h:5092
void unionAssumedWithUndef()
Union assumed set with an undef value.
Definition Attributor.h:5089
const SetTy & getAssumedSet() const
Return this set.
Definition Attributor.h:5043
A wrapper around a set that has semantics for handling unions and intersections with a "universal" se...
Definition Attributor.h:3083
SetContents(bool Universal)
Creates a universal set with no concrete elements or an empty set.
Definition Attributor.h:3085
SetContents(bool Universal, const DenseSet< BaseTy > &Assumptions)
Definition Attributor.h:3091
bool getIntersection(const SetContents &RHS)
Finds A := A ^ B where A or B could be the "Universal" set which contains every possible attribute.
Definition Attributor.h:3102
bool isUniversal() const
Definition Attributor.h:3096
bool getUnion(const SetContents &RHS)
Finds A := A u B where A or B could be the "Universal" set which contains every possible attribute.
Definition Attributor.h:3122
const DenseSet< BaseTy > & getSet() const
Definition Attributor.h:3094
bool empty() const
Definition Attributor.h:3098
SetContents(const DenseSet< BaseTy > &Assumptions)
Creates a non-universal set with concrete values.
Definition Attributor.h:3088
bool setContains(const BaseTy &Elem) const
Returns if the set state contains the element.
Definition Attributor.h:3176
bool getIntersection(const SetContents &RHS)
Performs the set intersection between this set and RHS.
Definition Attributor.h:3182
bool isValidState() const override
See AbstractState::isValidState()
Definition Attributor.h:3150
bool isAtFixpoint() const override
See AbstractState::isAtFixpoint()
Definition Attributor.h:3153
SetState()
Definition Attributor.h:3142
const SetContents & getAssumed() const
Return the assumed state encoding.
Definition Attributor.h:3173
const SetContents & getKnown() const
Return the known state encoding.
Definition Attributor.h:3170
ChangeStatus indicateOptimisticFixpoint() override
See AbstractState::indicateOptimisticFixpoint(...)
Definition Attributor.h:3156
bool getUnion(const SetContents &RHS)
Performs the set union between this set and RHS.
Definition Attributor.h:3197
SetState(const DenseSet< BaseTy > &Known)
Initializes the known state with an initial set and initializes the assumed state as universal.
Definition Attributor.h:3146
ChangeStatus indicatePessimisticFixpoint() override
See AbstractState::indicatePessimisticFixpoint(...)
Definition Attributor.h:3163
Helper to tie a abstract state implementation to an abstract attribute.
Definition Attributor.h:3211
StateType & getState() override
See AbstractAttribute::getState(...).
Definition Attributor.h:3219
StateTy StateType
Provide static access to the type of the state.
Definition Attributor.h:3213
StateWrapper(const IRPosition &IRP, Ts... Args)
Definition Attributor.h:3215
const StateType & getState() const override
See AbstractAttribute::getState(...).
Definition Attributor.h:3222
Definition Attributor.h:4480
static ValueSimplifyStateType getWorstState(Type *Ty)
Return the worst possible representable state.
Definition Attributor.h:4492
static ValueSimplifyStateType getBestState(const ValueSimplifyStateType &VS)
Definition Attributor.h:4487
LLVM_ABI bool unionAssumed(std::optional< Value * > Other)
Merge Other into the currently assumed simplified value.
ChangeStatus indicateOptimisticFixpoint() override
See AbstractState::indicateOptimisticFixpoint(...)
Definition Attributor.h:4518
ValueSimplifyStateType operator^=(const ValueSimplifyStateType &VS)
"Clamp" this state with PVS.
Definition Attributor.h:4523
ChangeStatus indicatePessimisticFixpoint() override
See AbstractState::indicatePessimisticFixpoint(...)
Definition Attributor.h:4513
ValueSimplifyStateType(Type *Ty)
Definition Attributor.h:4482
static ValueSimplifyStateType getBestState(Type *Ty)
Definition Attributor.h:4484
bool isAtFixpoint() const override
See AbstractState::isAtFixpoint(...)
Definition Attributor.h:4506
bool isValidState() const override
See AbstractState::isValidState(...)
Definition Attributor.h:4503
std::optional< Value * > SimplifiedAssociatedValue
An assumed simplified value.
Definition Attributor.h:4551
static ValueSimplifyStateType getWorstState(const ValueSimplifyStateType &VS)
Definition Attributor.h:4498
BooleanState BS
Helper to track validity and fixpoint.
Definition Attributor.h:4545
Type * Ty
The type of the original value.
Definition Attributor.h:4539
bool operator==(const ValueSimplifyStateType &RHS) const
Definition Attributor.h:4529
ValueSimplifyStateType getAssumed()
Return the assumed state encoding.
Definition Attributor.h:4509
const ValueSimplifyStateType & getAssumed() const
Definition Attributor.h:4510