30#include "llvm/Config/llvm-config.h"
61#define DEBUG_TYPE "memoryssa"
71#ifdef EXPENSIVE_CHECKS
91 MemorySSAAnnotatedWriter(
const MemorySSA *M) : MSSA(M) {}
93 void emitBasicBlockStartAnnot(
const BasicBlock *BB,
96 OS <<
"; " << *MA <<
"\n";
102 OS <<
"; " << *MA <<
"\n";
114 MemorySSAWalkerAnnotatedWriter(
MemorySSA *M)
115 : MSSA(M), Walker(M->getWalker()), BAA(M->getAA()) {}
117 void emitBasicBlockStartAnnot(
const BasicBlock *BB,
120 OS <<
"; " << *MA <<
"\n";
129 OS <<
" - clobbered by ";
150 bool VolatileUse =
Use->isVolatile();
151 bool VolatileClobber = MayClobber->
isVolatile();
153 if (VolatileUse && VolatileClobber)
169 return !(SeqCstUse || MayClobberIsAcquire);
172template <
typename AliasAnalysisType>
177 assert(DefInst &&
"Defining instruction not actually an instruction");
187 switch (
II->getIntrinsicID()) {
188 case Intrinsic::allow_runtime_check:
189 case Intrinsic::allow_ubsan_check:
190 case Intrinsic::invariant_start:
191 case Intrinsic::invariant_end:
192 case Intrinsic::assume:
193 case Intrinsic::experimental_noalias_scope_decl:
194 case Intrinsic::pseudoprobe:
225struct UpwardsMemoryQuery {
235 bool SkipSelfAccess =
false;
237 UpwardsMemoryQuery() =
default;
248template <
typename AliasAnalysisType>
253 if (
I->hasMetadata(LLVMContext::MD_invariant_load))
274[[maybe_unused]]
static void
278 bool AllowImpreciseClobber =
false) {
279 assert(MSSA.
dominates(ClobberAt, Start) &&
"Clobber doesn't dominate start?");
283 "liveOnEntry must clobber itself");
287 bool FoundClobber =
false;
290 Worklist.
push_back({Start, StartLoc,
false});
293 while (!Worklist.
empty()) {
301 if (MA == ClobberAt) {
328 "Found clobber before reaching ClobberAt!");
335 "Can only find use in def chain if Start is a use");
356 if (AllowImpreciseClobber)
362 "ClobberAt never acted as a clobber");
371 using ListIndex = unsigned;
381 std::optional<ListIndex> Previous;
382 bool MayBeCrossIteration;
384 DefPath(
const MemoryLocation &Loc, MemoryAccess *
First, MemoryAccess *
Last,
385 bool MayBeCrossIteration, std::optional<ListIndex> Previous)
387 MayBeCrossIteration(MayBeCrossIteration) {}
389 DefPath(
const MemoryLocation &Loc, MemoryAccess *Init,
390 bool MayBeCrossIteration, std::optional<ListIndex> Previous)
391 : DefPath(Loc,
Init,
Init, MayBeCrossIteration, Previous) {}
397 UpwardsMemoryQuery *Query;
398 unsigned *UpwardWalkLimit;
405 DenseSet<UpwardDefsElem> VisitedPhis;
408 const MemoryAccess *getWalkTarget(
const MemoryPhi *From)
const {
414 while ((Node =
Node->getIDom())) {
423 struct UpwardsWalkResult {
436 walkToPhiOrClobber(DefPath &
Desc,
const MemoryAccess *StopAt =
nullptr,
437 const MemoryAccess *SkipStopAt =
nullptr)
const {
439 assert(UpwardWalkLimit &&
"Need a valid walk limit");
440 bool LimitAlreadyReached =
false;
445 if (!*UpwardWalkLimit) {
446 *UpwardWalkLimit = 1;
447 LimitAlreadyReached =
true;
452 if (Current == StopAt || Current == SkipStopAt)
453 return {Current,
false};
459 if (!--*UpwardWalkLimit)
460 return {Current,
true};
462 BatchAACrossIterationScope
_(*AA,
Desc.MayBeCrossIteration);
468 if (LimitAlreadyReached)
469 *UpwardWalkLimit = 0;
472 "Ended at a non-clobber that's not a phi?");
473 return {
Desc.Last,
false};
476 void addSearches(MemoryPhi *Phi, SmallVectorImpl<ListIndex> &PausedSearches,
477 ListIndex PriorNode,
bool MayBeCrossIteration) {
478 auto UpwardDefsBegin =
481 for (
const UpwardDefsElem &
E : UpwardDefs) {
490 struct TerminatedPath {
491 MemoryAccess *Clobber;
504 std::optional<TerminatedPath>
505 getBlockingAccess(
const MemoryAccess *StopWhere,
506 SmallVectorImpl<ListIndex> &PausedSearches,
507 SmallVectorImpl<ListIndex> &NewPaused,
508 SmallVectorImpl<TerminatedPath> &Terminated) {
509 assert(!PausedSearches.
empty() &&
"No searches to continue?");
513 while (!PausedSearches.
empty()) {
515 DefPath &
Node = Paths[PathIndex];
535 if (!VisitedPhis.
insert({Node.Last, Node.Loc, Node.MayBeCrossIteration})
539 const MemoryAccess *SkipStopWhere =
nullptr;
540 if (Query->SkipSelfAccess &&
Node.Loc == Query->StartingLoc) {
542 SkipStopWhere = Query->OriginalAccess;
545 UpwardsWalkResult Res = walkToPhiOrClobber(Node,
548 if (Res.IsKnownClobber) {
549 assert(Res.Result != StopWhere && Res.Result != SkipStopWhere);
553 TerminatedPath
Term{Res.Result, PathIndex};
554 if (!MSSA.
dominates(Res.Result, StopWhere))
562 if (Res.Result == StopWhere || Res.Result == SkipStopWhere) {
567 if (Res.Result != SkipStopWhere)
574 Node.MayBeCrossIteration);
580 template <
typename T,
typename Walker>
581 struct generic_def_path_iterator
582 :
public iterator_facade_base<generic_def_path_iterator<T, Walker>,
583 std::forward_iterator_tag, T *> {
584 generic_def_path_iterator() =
default;
585 generic_def_path_iterator(Walker *W, ListIndex
N) :
W(
W),
N(
N) {}
589 generic_def_path_iterator &operator++() {
590 N = curNode().Previous;
594 bool operator==(
const generic_def_path_iterator &O)
const {
595 if (
N.has_value() !=
O.N.has_value())
597 return !
N || *
N == *
O.N;
601 T &curNode()
const {
return W->Paths[*
N]; }
604 std::optional<ListIndex>
N;
607 using def_path_iterator = generic_def_path_iterator<DefPath, ClobberWalker>;
610 return make_range(def_path_iterator(
this, From), def_path_iterator());
615 TerminatedPath PrimaryClobber;
621 ListIndex defPathIndex(
const DefPath &
N)
const {
623 const DefPath *NP = &
N;
625 "Out of bounds DefPath!");
626 return NP - &Paths.
front();
642 OptznResult tryOptimizePhi(MemoryPhi *Phi, MemoryAccess *Start,
643 const MemoryLocation &Loc) {
645 "Reset the optimization state.");
651 auto PriorPathsSize = Paths.
size();
657 addSearches(Phi, PausedSearches, 0,
false);
661 auto MoveDominatedPathToEnd = [&](SmallVectorImpl<TerminatedPath> &Paths) {
663 auto Dom = Paths.
begin();
664 for (
auto I = std::next(Dom),
E = Paths.
end();
I !=
E; ++
I)
665 if (!MSSA.
dominates(
I->Clobber, Dom->Clobber))
669 std::iter_swap(
Last, Dom);
672 MemoryPhi *Current =
Phi;
675 "liveOnEntry wasn't treated as a clobber?");
677 const auto *
Target = getWalkTarget(Current);
680 assert(
all_of(TerminatedPaths, [&](
const TerminatedPath &
P) {
687 if (std::optional<TerminatedPath> Blocker = getBlockingAccess(
688 Target, PausedSearches, NewPaused, TerminatedPaths)) {
692 auto Iter =
find_if(def_path(Blocker->LastNode), [&](
const DefPath &
N) {
693 return defPathIndex(N) < PriorPathsSize;
695 assert(Iter != def_path_iterator());
697 DefPath &CurNode = *Iter;
698 assert(CurNode.Last == Current);
725 TerminatedPath
Result{CurNode.Last, defPathIndex(CurNode)};
732 if (NewPaused.
empty()) {
733 MoveDominatedPathToEnd(TerminatedPaths);
735 return {
Result, std::move(TerminatedPaths)};
738 MemoryAccess *DefChainEnd =
nullptr;
740 for (ListIndex Paused : NewPaused) {
741 UpwardsWalkResult WR = walkToPhiOrClobber(Paths[Paused]);
742 if (WR.IsKnownClobber)
746 DefChainEnd = WR.Result;
749 if (!TerminatedPaths.
empty()) {
753 for (
auto *MA :
def_chain(
const_cast<MemoryAccess *
>(Target)))
755 assert(DefChainEnd &&
"Failed to find dominating phi/liveOnEntry");
760 for (
const TerminatedPath &TP : TerminatedPaths) {
763 if (DT.
dominates(ChainBB, TP.Clobber->getBlock()))
770 if (!Clobbers.
empty()) {
771 MoveDominatedPathToEnd(Clobbers);
773 return {
Result, std::move(Clobbers)};
777 [&](ListIndex
I) {
return Paths[
I].Last == DefChainEnd; }));
782 PriorPathsSize = Paths.
size();
783 PausedSearches.
clear();
784 for (ListIndex
I : NewPaused)
785 addSearches(DefChainPhi, PausedSearches,
I,
786 Paths[
I].MayBeCrossIteration);
789 Current = DefChainPhi;
793 void verifyOptResult(
const OptznResult &R)
const {
795 return MSSA.dominates(P.Clobber, R.PrimaryClobber.Clobber);
799 void resetPhiOptznState() {
805 ClobberWalker(
const MemorySSA &MSSA, DominatorTree &DT)
806 : MSSA(MSSA), DT(DT) {}
810 MemoryAccess *findClobber(BatchAAResults &BAA, MemoryAccess *Start,
811 UpwardsMemoryQuery &Q,
unsigned &UpWalkLimit) {
814 UpwardWalkLimit = &UpWalkLimit;
819 MemoryAccess *Current =
Start;
823 Current = MU->getDefiningAccess();
825 DefPath FirstDesc(Q.StartingLoc, Current, Current,
826 false, std::nullopt);
829 UpwardsWalkResult WalkResult = walkToPhiOrClobber(FirstDesc);
831 if (WalkResult.IsKnownClobber) {
832 Result = WalkResult.Result;
835 Current, Q.StartingLoc);
836 verifyOptResult(OptRes);
837 resetPhiOptznState();
838 Result = OptRes.PrimaryClobber.Clobber;
841#ifdef EXPENSIVE_CHECKS
842 if (!Q.SkipSelfAccess && *UpwardWalkLimit > 0)
849struct RenamePassData {
851 DomTreeNode::const_iterator ChildIt;
852 MemoryAccess *IncomingVal;
854 RenamePassData(
DomTreeNode *
D, DomTreeNode::const_iterator It,
856 : DTN(
D), ChildIt(It), IncomingVal(
M) {}
858 void swap(RenamePassData &
RHS) {
870 ClobberWalker Walker;
904 return Walker->getClobberingMemoryAccessBase(MA, BAA, UWL,
false);
909 return Walker->getClobberingMemoryAccessBase(MA,
Loc, BAA, UWL);
914 unsigned UpwardWalkLimit =
MSSA->Opts.memssa_check_limit;
920 unsigned UpwardWalkLimit =
MSSA->Opts.memssa_check_limit;
926 MUD->resetOptimized();
942 return Walker->getClobberingMemoryAccessBase(MA, BAA, UWL,
true);
947 return Walker->getClobberingMemoryAccessBase(MA,
Loc, BAA, UWL);
952 unsigned UpwardWalkLimit =
MSSA->Opts.memssa_check_limit;
958 unsigned UpwardWalkLimit =
MSSA->Opts.memssa_check_limit;
964 MUD->resetOptimized();
971 bool RenameAllUses) {
980 bool ReplacementDone =
false;
981 for (
unsigned I = 0,
E = Phi->getNumIncomingValues();
I !=
E; ++
I)
982 if (Phi->getIncomingBlock(
I) == BB) {
983 Phi->setIncomingValue(
I, IncomingVal);
984 ReplacementDone =
true;
986 (void) ReplacementDone;
987 assert(ReplacementDone &&
"Incomplete phi during partial rename");
989 Phi->addIncoming(IncomingVal, BB);
997 bool RenameAllUses) {
1000 for (MemoryAccess &L : *
Accesses) {
1002 if (MUD->getDefiningAccess() ==
nullptr || RenameAllUses)
1003 MUD->setDefiningAccess(IncomingVal);
1020 bool SkipVisited,
bool RenameAllUses) {
1021 assert(Root &&
"Trying to rename accesses in an unreachable block");
1028 if (SkipVisited && AlreadyVisited)
1031 IncomingVal = renameBlock(Root->
getBlock(), IncomingVal, RenameAllUses);
1032 renameSuccessorPhis(Root->
getBlock(), IncomingVal, RenameAllUses);
1035 while (!WorkStack.
empty()) {
1037 DomTreeNode::const_iterator ChildIt = WorkStack.
back().ChildIt;
1038 IncomingVal = WorkStack.
back().IncomingVal;
1040 if (ChildIt ==
Node->end()) {
1044 ++WorkStack.
back().ChildIt;
1048 AlreadyVisited = !Visited.
insert(BB).second;
1049 if (SkipVisited && AlreadyVisited) {
1056 IncomingVal = &*BlockDefs->rbegin();
1058 IncomingVal = renameBlock(BB, IncomingVal, RenameAllUses);
1059 renameSuccessorPhis(BB, IncomingVal, RenameAllUses);
1068void MemorySSA::markUnreachableAsLiveOnEntry(
BasicBlock *BB) {
1069 assert(!DT->isReachableFromEntry(BB) &&
1070 "Reachable block found while handling unreachable blocks");
1077 if (!DT->isReachableFromEntry(S))
1084 Phi->addIncoming(LiveOnEntryDef.get(), BB);
1092 auto Next = std::next(AI);
1096 UseOrDef->setDefiningAccess(LiveOnEntryDef.get());
1105 BlockNumberEpoch(Func.getBlockNumberEpoch()), LiveOnEntryDef(nullptr),
1106 Walker(nullptr), SkipWalker(nullptr) {
1112 assert(AA &&
"No alias analysis?");
1124 BlockNumberEpoch(L.getHeader()->
getParent()->getBlockNumberEpoch()),
1125 LiveOnEntryDef(nullptr), Walker(nullptr), SkipWalker(nullptr) {
1131 assert(AA &&
"No alias analysis?");
1135 return *const_cast<BasicBlock *>(BB);
1146 for (
const BlockInfo &Info : PerBlock)
1152MemorySSA::BlockInfo &MemorySSA::getOrCreateBlockInfo(
const BasicBlock *BB) {
1153 unsigned N = getBlockIndex(BB);
1154 if (
N >= PerBlock.
size())
1159template <
typename ListT>
1160ListT *MemorySSA::getOrCreateList(ListPtr<ListT> &List) {
1162 List.reset(
new (UseOrDefAllocator) ListT());
1166void MemorySSA::placePHINodes(
1170 IDFs.setDefiningBlocks(DefiningBlocks);
1172 IDFs.calculate(IDFBlocks);
1175 for (
auto &BB : IDFBlocks)
1176 createMemoryPhi(BB);
1181template <
typename AccessT,
typename AllocatorT,
typename... ArgTs>
1184 char *Mem =
static_cast<char *
>(
1185 Allocator.Allocate(OpsSize +
sizeof(AccessT),
alignof(AccessT)));
1186 return ::new (Mem + OpsSize) AccessT(std::forward<ArgTs>(Args)...);
1189template <
typename IterT>
1190void MemorySSA::buildMemorySSA(
BatchAAResults &BAA, IterT Blocks) {
1198 LiveOnEntryDef.reset(
1200 nullptr,
nullptr, &StartingPoint, NextID++));
1205 SmallPtrSet<BasicBlock *, 32> DefiningBlocks;
1208 for (BasicBlock &
B : Blocks) {
1209 bool InsertIntoDef =
false;
1212 for (Instruction &
I :
B) {
1213 MemoryUseOrDef *MUD = createNewAccess(&
I, &BAA);
1221 InsertIntoDef =
true;
1223 Defs = getOrCreateList(getOrCreateBlockInfo(&
B).Defs);
1224 Defs->push_back(*MUD);
1230 placePHINodes(DefiningBlocks);
1234 SmallPtrSet<BasicBlock *, 16> Visited;
1241 U.set(LiveOnEntryDef.get());
1247 L->getExitBlocks(ExitBlocks);
1249 renamePass(DT->getNode(L->getLoopPreheader()), LiveOnEntryDef.get(),
1252 renamePass(DT->getRootNode(), LiveOnEntryDef.get(), Visited);
1257 for (
auto &BB : Blocks)
1258 if (!Visited.
count(&BB))
1259 markUnreachableAsLiveOnEntry(&BB);
1266 return Walker.get();
1269 WalkerBase = std::make_unique<ClobberWalkerBase>(
this, DT);
1271 Walker = std::make_unique<CachingWalker>(
this, WalkerBase.get());
1272 return Walker.get();
1277 return SkipWalker.get();
1280 WalkerBase = std::make_unique<ClobberWalkerBase>(
this, DT);
1282 SkipWalker = std::make_unique<SkipSelfWalker>(
this, WalkerBase.get());
1283 return SkipWalker.get();
1293 BlockInfo &Info = getOrCreateBlockInfo(BB);
1300 getOrCreateList(Info.Defs)->push_front(*NewAccess);
1306 DefsList *Defs = getOrCreateList(Info.Defs);
1309 Defs->
insert(DI, *NewAccess);
1315 getOrCreateList(Info.Defs)->push_back(*NewAccess);
1317 BlockNumberingValid.erase(BB);
1322 BlockInfo &Info = PerBlock[getBlockIndex(BB)];
1327 DefsList *Defs = getOrCreateList(Info.Defs);
1346 BlockNumberingValid.erase(BB);
1357 MD->resetOptimized();
1367 prepareForMoveTo(What, BB);
1375 "Can only move a Phi at the beginning of the block");
1377 ValueToMemoryAccess.erase(What->
getBlock());
1378 bool Inserted = ValueToMemoryAccess.insert({BB, What}).second;
1380 assert(Inserted &&
"Cannot move a Phi to a block that already has one");
1383 prepareForMoveTo(What, BB);
1392 ValueToMemoryAccess[BB] = Phi;
1399 bool CreationMustSucceed) {
1402 if (CreationMustSucceed)
1403 assert(NewAccess !=
nullptr &&
"Tried to create a memory access for a "
1404 "non-memory touching instruction");
1407 "A use cannot be a defining access");
1418 if (!
SI->isUnordered())
1421 if (!LI->isUnordered())
1428template <
typename AliasAnalysisType>
1430 AliasAnalysisType *AAP,
1439 switch (
II->getIntrinsicID()) {
1442 case Intrinsic::allow_runtime_check:
1443 case Intrinsic::allow_ubsan_check:
1444 case Intrinsic::assume:
1445 case Intrinsic::experimental_noalias_scope_decl:
1446 case Intrinsic::pseudoprobe:
1454 if (!
I->mayReadFromMemory() && !
I->mayWriteToMemory())
1463 bool DefCheck, UseCheck;
1468 assert((Def == DefCheck || !DefCheck) &&
1469 "Memory accesses should only be reduced");
1470 if (!Def && Use != UseCheck) {
1472 assert(!UseCheck &&
"Invalid template");
1495 MemoryUseOrDef *MUD;
1498 nullptr,
I,
I->getParent(), NextID++);
1501 nullptr,
I,
I->getParent());
1507 ValueToMemoryAccess[
I] = MUD;
1514 "Trying to remove memory access that still has uses");
1515 BlockNumbering.erase(MA);
1528 auto VMA = ValueToMemoryAccess.find(MemoryInst);
1529 if (VMA->second == MA)
1530 ValueToMemoryAccess.
erase(VMA);
1541 BlockInfo &Info = PerBlock[getBlockIndex(BB)];
1545 Info.Defs->remove(*MA);
1546 if (Info.Defs->empty())
1553 Info.Accesses->
erase(MA);
1555 Info.Accesses->remove(MA);
1557 if (Info.Accesses->empty()) {
1558 Info.Accesses.reset();
1559 BlockNumberingValid.erase(BB);
1564 MemorySSAAnnotatedWriter Writer(
this);
1568 F->
print(OS, &Writer);
1571#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1576#if !defined(NDEBUG) && defined(EXPENSIVE_CHECKS)
1588 assert(L &&
"must either have loop or function");
1591 return *const_cast<BasicBlock *>(BB);
1611template <
typename IterT>
1615 for (
unsigned I = 0, E = Phi->getNumIncomingValues();
I != E; ++
I) {
1616 auto *Pred = Phi->getIncomingBlock(
I);
1617 auto *IncAcc = Phi->getIncomingValue(
I);
1621 if (
auto *DTNode = DT->getNode(Pred)) {
1623 if (
auto *DefList =
getBlockDefs(DTNode->getBlock())) {
1624 auto *LastAcc = &*(--DefList->end());
1625 assert(LastAcc == IncAcc &&
1626 "Incorrect incoming access into phi.");
1631 DTNode = DTNode->getIDom();
1648template <
typename IterT>
1650 if (BlockNumberingValid.empty())
1655 if (!ValidBlocks.
count(&BB))
1658 ValidBlocks.
erase(&BB);
1666 unsigned long LastNumber = 0;
1668 auto ThisNumberIter = BlockNumbering.find(&MA);
1669 assert(ThisNumberIter != BlockNumbering.end() &&
1670 "MemoryAccess has no domination number in a valid block!");
1672 unsigned long ThisNumber = ThisNumberIter->second;
1673 assert(ThisNumber > LastNumber &&
1674 "Domination numbers should be strictly increasing!");
1676 LastNumber = ThisNumber;
1681 "All valid BasicBlocks should exist in F -- dangling pointers?");
1690template <
typename IterT>
1707 for (
const Use &U : Phi->uses()) {
1708 assert(
dominates(Phi, U) &&
"Memory PHI does not dominate it's uses");
1714 "Incomplete MemoryPhi Node");
1715 for (
unsigned I = 0, E = Phi->getNumIncomingValues();
I != E; ++
I) {
1716 verifyUseInDefs(Phi->getIncomingValue(
I), Phi);
1718 "Incoming phi block not a block predecessor");
1726 "We have memory affecting instructions "
1727 "in this block but they are not in the "
1728 "access list or defs list");
1736 for (
const Use &U : MD->
uses()) {
1738 "Memory Def does not dominate it's uses");
1752 assert(AL->size() == ActualAccesses.
size() &&
1753 "We don't have the same number of accesses in the block as on the "
1756 "Either we should have a defs list, or we should have no defs");
1758 "We don't have the same number of defs in the block as on the "
1760 auto ALI = AL->begin();
1761 auto AAI = ActualAccesses.
begin();
1762 while (ALI != AL->end() && AAI != ActualAccesses.
end()) {
1763 assert(&*ALI == *AAI &&
"Not the same accesses in the same order");
1767 ActualAccesses.
clear();
1769 auto DLI =
DL->begin();
1770 auto ADI = ActualDefs.
begin();
1771 while (DLI !=
DL->end() && ADI != ActualDefs.
end()) {
1772 assert(&*DLI == *ADI &&
"Not the same defs in the same order");
1787 "Null def but use not point to live on entry def");
1790 "Did not find use in def's use list");
1799void MemorySSA::renumberBlock(
const BasicBlock *
B)
const {
1801 unsigned long CurrentNumber = 0;
1803 assert(AL !=
nullptr &&
"Asking to renumber an empty block");
1804 for (
const auto &
I : *AL)
1805 BlockNumbering[&
I] = ++CurrentNumber;
1806 BlockNumberingValid.insert(
B);
1817 "Asking for local domination when accesses are in different blocks!");
1819 if (Dominatee == Dominator)
1832 if (!BlockNumberingValid.count(DominatorBlock))
1833 renumberBlock(DominatorBlock);
1835 unsigned long DominatorNum = BlockNumbering.lookup(Dominator);
1837 assert(DominatorNum != 0 &&
"Block was not numbered properly");
1838 unsigned long DominateeNum = BlockNumbering.lookup(Dominatee);
1839 assert(DominateeNum != 0 &&
"Block was not numbered properly");
1840 return DominatorNum < DominateeNum;
1845 if (Dominator == Dominatee)
1857 const Use &Dominatee)
const {
1859 BasicBlock *UseBB = MP->getIncomingBlock(Dominatee);
1861 if (UseBB != Dominator->
getBlock())
1862 return DT->dominates(Dominator->
getBlock(), UseBB);
1872 case MemoryPhiVal:
return static_cast<const MemoryPhi *
>(
this)->
print(OS);
1873 case MemoryDefVal:
return static_cast<const MemoryDef *
>(
this)->
print(OS);
1874 case MemoryUseVal:
return static_cast<const MemoryUse *
>(
this)->
print(OS);
1883 if (
A &&
A->getID())
1889 OS <<
getID() <<
" = MemoryDef(";
1901 OS <<
getID() <<
" = MemoryPhi(";
1912 if (
unsigned ID = MA->
getID())
1924 if (UO && UO->
getID())
1933#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1942 MemorySSAAnnotatedWriter MSSAWriter;
1946 : F(F), MSSAWriter(&MSSA) {}
1949 MemorySSAAnnotatedWriter &
getWriter() {
return MSSAWriter; }
1957 return &(CFGInfo->
getFunction()->getEntryBlock());
1992 [](std::string &S,
unsigned &
I,
unsigned Idx) ->
void {
1993 std::string Str = S.substr(
I, Idx -
I);
1995 if (SR.
count(
" = MemoryDef(") || SR.
count(
" = MemoryPhi(") ||
1996 SR.
count(
"MemoryUse("))
2016 ?
"style=filled, fillcolor=lightpink"
2034 FunctionAnalysisManager::Invalidator &Inv) {
2045 if (!DotCFGMSSA.
empty()) {
2049 OS <<
"MemorySSA for function: " <<
F.getName() <<
"\n";
2059 OS <<
"MemorySSA (walker) for function: " <<
F.getName() <<
"\n";
2060 MemorySSAWalkerAnnotatedWriter Writer(&MSSA);
2061 F.print(OS, &Writer);
2094 MSSA->verifyMemorySSA();
2113 if (
Loc.Ptr ==
nullptr)
2114 return StartingAccess;
2119 return StartingUseOrDef;
2121 I = StartingUseOrDef->getMemoryInst();
2126 return StartingUseOrDef;
2129 UpwardsMemoryQuery Q;
2130 Q.OriginalAccess = StartingAccess;
2131 Q.StartingLoc =
Loc;
2139 Walker.findClobber(BAA, StartingAccess, Q, UpwardWalkLimit);
2141 dbgs() <<
"Clobber starting at access " << *StartingAccess <<
"\n";
2143 dbgs() <<
" for instruction " << *
I <<
"\n";
2144 dbgs() <<
" is " << *Clobber <<
"\n";
2151 if (!
I.hasMetadata(LLVMContext::MD_invariant_group) ||
I.isVolatile())
2168 for (
const User *Us : PointerOperand->
users()) {
2170 if (!U || U == &
I || !DT.
dominates(U, MostDominatingInstruction))
2176 if (U->hasMetadata(LLVMContext::MD_invariant_group) &&
2178 MostDominatingInstruction = U;
2182 return MostDominatingInstruction == &
I ? nullptr : MostDominatingInstruction;
2186 MemoryAccess *MA, BatchAAResults &BAA,
unsigned &UpwardWalkLimit,
2190 if (!StartingAccess)
2194 *StartingAccess->getMemoryInst(), MSSA->
getDomTree())) {
2200 return ClobberMA->getDefiningAccess();
2204 bool IsOptimized =
false;
2209 if (StartingAccess->isOptimized()) {
2211 return StartingAccess->getOptimized();
2215 const Instruction *
I = StartingAccess->getMemoryInst();
2220 return StartingAccess;
2222 UpwardsMemoryQuery Q(
I, StartingAccess);
2226 StartingAccess->setOptimized(LiveOnEntry);
2230 MemoryAccess *OptimizedAccess;
2233 MemoryAccess *DefiningAccess = StartingAccess->getDefiningAccess();
2238 StartingAccess->setOptimized(DefiningAccess);
2239 return DefiningAccess;
2243 Walker.findClobber(BAA, DefiningAccess, Q, UpwardWalkLimit);
2244 StartingAccess->setOptimized(OptimizedAccess);
2246 OptimizedAccess = StartingAccess->getOptimized();
2248 LLVM_DEBUG(
dbgs() <<
"Starting Memory SSA clobber for " << *
I <<
" is ");
2250 LLVM_DEBUG(
dbgs() <<
"Optimized Memory SSA clobber for " << *
I <<
" is ");
2257 Q.SkipSelfAccess =
true;
2258 Result = Walker.findClobber(BAA, OptimizedAccess, Q, UpwardWalkLimit);
2260 Result = OptimizedAccess;
2262 LLVM_DEBUG(
dbgs() <<
"Result Memory SSA clobber [SkipSelf = " << SkipSelf);
2272 return Use->getDefiningAccess();
2279 return Use->getDefiningAccess();
2280 return StartingAccess;
2291void MemoryUse::deleteMe(DerivedUser *Self) {
2292 static_cast<MemoryUse *
>(Self)->~MemoryUse();
2295bool upward_defs_iterator::IsGuaranteedLoopInvariant(
const Value *Ptr)
const {
2296 auto IsGuaranteedLoopInvariantBase = [](
const Value *Ptr) {
2305 if (
I->getParent()->isEntryBlock())
2309 return IsGuaranteedLoopInvariantBase(
GEP->getPointerOperand()) &&
2310 GEP->hasAllConstantIndices();
2312 return IsGuaranteedLoopInvariantBase(Ptr);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const AArch64InstrInfo MachineBasicBlock::iterator InsertPt
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Atomic ordering constants.
static const Function * getParent(const Value *V)
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< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
DXIL Forward Handle Accesses
This file defines DenseMapInfo traits for DenseMap.
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
early cse Early CSE w MemorySSA
This header defines various interfaces for pass management in LLVM.
This defines the Use class.
This file provides utility analysis objects describing memory locations.
static bool instructionClobbersQuery(const MemoryDef *MD, const MemoryLocation &UseLoc, const Instruction *UseInst, AliasAnalysisType &AA)
static void checkClobberSanity(MemoryAccess *Start, MemoryAccess *ClobberAt, const MemoryLocation &StartLoc, const MemorySSA &MSSA, const UpwardsMemoryQuery &Query, BatchAAResults &AA, bool AllowImpreciseClobber=false)
Verifies that Start is clobbered by ClobberAt, and that nothing inbetween Start and ClobberAt can clo...
static AccessT * allocateUseOrDef(AllocatorT &Allocator, ArgTs &&...Args)
Allocate a MemoryUse or MemoryDef from Allocator, with its operands in front of it like User::operato...
static cl::opt< bool, true > VerifyMemorySSAX("verify-memoryssa", cl::location(VerifyMemorySSA), cl::Hidden, cl::desc("Enable verification of MemorySSA."))
static const char LiveOnEntryStr[]
static bool isUseTriviallyOptimizableToLiveOnEntry(AliasAnalysisType &AA, const Instruction *I)
static bool areLoadsReorderable(const LoadInst *Use, const LoadInst *MayClobber)
This does one-way checks to see if Use could theoretically be hoisted above MayClobber.
static const Instruction * getInvariantGroupClobberingInstruction(Instruction &I, DominatorTree &DT)
static bool isOrdered(const Instruction *I)
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
static std::string getNodeLabel(const ValueInfo &VI, GlobalValueSummary *GVS)
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
DOTFuncMSSAInfo(const Function &F, MemorySSA &MSSA)
const Function * getFunction()
MemorySSAAnnotatedWriter & getWriter()
A manager for alias analyses.
A wrapper pass to provide the legacy pass manager access to a suitably prepared AAResults object.
This templated class represents "all analyses that operate over <aparticular IR unit>" (e....
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
AnalysisUsage & addRequiredTransitive()
LLVM Basic Block Representation.
LLVM_ABI BasicBlock::iterator erase(BasicBlock::iterator FromIt, BasicBlock::iterator ToIt)
Erases a range of instructions from FromIt to (not including) ToIt.
const Function * getParent() const
Return the enclosing method, or null if none.
LLVM_ABI void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW=nullptr, bool ShouldPreserveUseListOrder=false, bool IsForDebug=false) const
Print the basic block to an output stream with an optional AssemblyAnnotationWriter.
LLVM_ABI LLVMContext & getContext() const
Get the context in which this basic block lives.
Temporarily set the cross iteration mode on a BatchAA instance.
This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Implements a dense probed hash-table based set.
Extension point for the Value hierarchy.
MemoryAccess * getClobberingMemoryAccess(MemoryAccess *, BatchAAResults &) override
Does the same thing as getClobberingMemoryAccess(const Instruction *I), but takes a MemoryAccess inst...
Analysis pass which computes a DominatorTree.
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
Legacy analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
LLVM_ABI bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
unsigned getMaxBlockNumber() const
Return a value larger than the largest block number.
Module * getParent()
Get the module that this global value is contained inside of...
A wrapper class for inspecting calls to intrinsic functions.
A helper class to return the specified delimiter string after the first invocation of operator String...
An instruction for reading from memory.
bool isVolatile() const
Return true if this is a load from a volatile memory location.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
Represents a single loop in the control flow graph.
LLVM_ABI void dump() const
MemoryAccess(const MemoryAccess &)=delete
BasicBlock * getBlock() const
LLVM_ABI void print(raw_ostream &OS) const
unsigned getID() const
Used for debugging and tracking things about MemoryAccesses.
void setBlock(BasicBlock *BB)
Used by MemorySSA to change the block of a MemoryAccess when it is moved.
Represents a read-write access to memory, whether it is a must-alias, or a may-alias.
LLVM_ABI void print(raw_ostream &OS) const
MemoryAccess * getOptimized() const
Representation for a specific memory location.
static LLVM_ABI MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
static LLVM_ABI std::optional< MemoryLocation > getOrNone(const Instruction *Inst)
Represents phi nodes for memory accesses.
BasicBlock * getIncomingBlock(unsigned I) const
Return incoming basic block number i.
LLVM_ABI void print(raw_ostream &OS) const
An analysis that produces MemorySSA for a function.
LLVM_ABI Result run(Function &F, FunctionAnalysisManager &AM)
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static LLVM_ABI bool defClobbersUseOrDef(MemoryDef *MD, const MemoryUseOrDef *MU, AliasAnalysis &AA)
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
This is the generic walker interface for walkers of MemorySSA.
MemoryAccess * getClobberingMemoryAccess(const Instruction *I, BatchAAResults &AA)
Given a memory Mod/Ref/ModRef'ing instruction, calling this will give you the nearest dominating Memo...
LLVM_ABI MemorySSAWalker(MemorySSA *)
virtual void invalidateInfo(MemoryAccess *)
Given a memory access, invalidate anything this walker knows about that access.
Legacy analysis pass which computes MemorySSA.
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
bool runOnFunction(Function &) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
A MemorySSAWalker that does AA walks to disambiguate accesses.
MemoryAccess * getClobberingMemoryAccess(MemoryAccess *MA, BatchAAResults &BAA) override
Does the same thing as getClobberingMemoryAccess(const Instruction *I), but takes a MemoryAccess inst...
MemoryAccess * getClobberingMemoryAccess(MemoryAccess *MA, const MemoryLocation &Loc, BatchAAResults &BAA, unsigned &UWL)
void invalidateInfo(MemoryAccess *MA) override
Given a memory access, invalidate anything this walker knows about that access.
~CachingWalker() override=default
MemoryAccess * getClobberingMemoryAccess(MemoryAccess *MA, BatchAAResults &BAA, unsigned &UWL)
CachingWalker(MemorySSA *M, ClobberWalkerBase *W)
MemoryAccess * getClobberingMemoryAccess(MemoryAccess *MA, const MemoryLocation &Loc, BatchAAResults &BAA) override
Given a potentially clobbering memory access and a new location, calling this will give you the neare...
ClobberWalkerBase(MemorySSA *M, DominatorTree *D)
MemoryAccess * getClobberingMemoryAccessBase(MemoryAccess *, BatchAAResults &, unsigned &, bool)
MemoryAccess * getClobberingMemoryAccessBase(MemoryAccess *, const MemoryLocation &, BatchAAResults &, unsigned &)
MemoryAccess * getClobberingMemoryAccess(MemoryAccess *MA, const MemoryLocation &Loc, BatchAAResults &BAA) override
Given a potentially clobbering memory access and a new location, calling this will give you the neare...
MemoryAccess * getClobberingMemoryAccess(MemoryAccess *MA, const MemoryLocation &Loc, BatchAAResults &BAA, unsigned &UWL)
~SkipSelfWalker() override=default
MemoryAccess * getClobberingMemoryAccess(MemoryAccess *MA, BatchAAResults &BAA, unsigned &UWL)
SkipSelfWalker(MemorySSA *M, ClobberWalkerBase *W)
MemoryAccess * getClobberingMemoryAccess(MemoryAccess *MA, BatchAAResults &BAA) override
Does the same thing as getClobberingMemoryAccess(const Instruction *I), but takes a MemoryAccess inst...
void invalidateInfo(MemoryAccess *MA) override
Given a memory access, invalidate anything this walker knows about that access.
Encapsulates MemorySSA, including all data associated with memory accesses.
LLVM_ABI void dump() const
simple_ilist< MemoryAccess, ilist_tag< MSSAHelpers::DefsOnlyTag > > DefsList
LLVM_ABI void moveTo(MemoryUseOrDef *What, BasicBlock *BB, AccessList::iterator Where)
void renamePass(BasicBlock *BB, MemoryAccess *IncomingVal, SmallPtrSetImpl< BasicBlock * > &Visited)
DefsList * getBlockDefs(const BasicBlock *BB) const
Return the list of MemoryDef's and MemoryPhi's for a given basic block.
LLVM_ABI MemorySSAWalker * getSkipSelfWalker()
LLVM_ABI MemorySSA(Function &, AliasAnalysis *, DominatorTree *)
iplist< MemoryAccess, ilist_tag< MSSAHelpers::AllAccessTag > > AccessList
AccessList * getBlockAccesses(const BasicBlock *BB) const
Return the list of MemoryAccess's for a given basic block.
LLVM_ABI bool dominates(const MemoryAccess *A, const MemoryAccess *B) const
Given two memory accesses in potentially different blocks, determine whether MemoryAccess A dominates...
void verifyOrderingDominationAndDefUses(IterT Blocks, VerificationLevel=VerificationLevel::Fast) const
Verify ordering: the order and existence of MemoryAccesses matches the order and existence of memory ...
LLVM_ABI void verifyMemorySSA(VerificationLevel=VerificationLevel::Fast) const
Verify that MemorySSA is self consistent (IE definitions dominate all uses, uses appear in the right ...
LLVM_ABI void insertIntoListsForBlock(MemoryAccess *, const BasicBlock *, InsertionPlace)
LLVM_ABI MemorySSAWalker * getWalker()
InsertionPlace
Used in various insertion functions to specify whether we are talking about the beginning or end of a...
LLVM_ABI void insertIntoListsBefore(MemoryAccess *, const BasicBlock *, AccessList::iterator)
LLVM_ABI MemoryUseOrDef * createDefinedAccess(Instruction *, MemoryAccess *, const MemoryUseOrDef *Template=nullptr, bool CreationMustSucceed=true)
DominatorTree & getDomTree() const
MemoryUseOrDef * getMemoryAccess(const Instruction *I) const
Given a memory Mod/Ref'ing instruction, get the MemorySSA access associated with it.
MemoryAccess * getLiveOnEntryDef() const
LLVM_ABI void removeFromLookups(MemoryAccess *)
Properly remove MA from all of MemorySSA's lookup tables.
void verifyDominationNumbers(IterT Blocks) const
Verify that all of the blocks we believe to have valid domination numbers actually have valid dominat...
void verifyPrevDefInPhis(IterT Blocks) const
LLVM_ABI bool locallyDominates(const MemoryAccess *A, const MemoryAccess *B) const
Given two memory accesses in the same basic block, determine whether MemoryAccess A dominates MemoryA...
LLVM_ABI void removeFromLists(MemoryAccess *, bool ShouldDelete=true)
Properly remove MA from all of MemorySSA's lists.
bool isLiveOnEntryDef(const MemoryAccess *MA) const
Return true if MA represents the live on entry value.
LLVM_ABI void print(raw_ostream &) const
Class that has the common methods + fields of memory uses/defs.
MemoryAccess * getDefiningAccess() const
Get the access that produces the memory state used by this Use.
void setDefiningAccess(MemoryAccess *DMA, bool Optimized=false)
void setOptimized(MemoryAccess *)
Sets the optimized use for a MemoryDef.
Instruction * getMemoryInst() const
Get the instruction that this MemoryUse represents.
LLVM_ABI void print(raw_ostream &OS) const
A Module instance is used to store all the information related to an LLVM module.
void print(raw_ostream &OS, AssemblyAnnotationWriter *AAW, bool ShouldPreserveUseListOrder=false, bool IsForDebug=false) const
Print the module to an output stream with an optional AssemblyAnnotationWriter.
AnalysisType & getAnalysis() const
getAnalysis<AnalysisType>() - This function is used by subclasses to get to the analysis information ...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
bool erase(PtrType Ptr)
Remove pointer from the set.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
void insert_range(Range &&R)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
LLVM_NO_SANITIZE_CFI_UNRELATED_CAST iterator begin()
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
std::string str() const
Get the contents as an std::string.
constexpr bool empty() const
Check if the string is empty.
size_t count(char C) const
Return the number of occurrences of C in the string.
A Use represents the edge between a Value definition and its users.
User * getUser() const
Returns the User that contains this Use.
void dropAllReferences()
Drop all references to operands.
unsigned getNumOperands() const
LLVM Value Representation.
iterator_range< user_iterator > users()
unsigned getValueID() const
Return an ID for the concrete type of this object.
LLVM_ABI void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
iterator_range< use_iterator > uses()
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
std::pair< iterator, bool > insert(const ValueT &V)
typename base_list_type::iterator iterator
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an std::string.
iterator insert(iterator I, reference Node)
Insert a node by reference; never copies.
void push_back(reference Node)
Insert a node at the back; never copies.
reverse_iterator rbegin()
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Abstract Attribute helper functions.
@ BasicBlock
Various leaf nodes.
LocationClass< Ty > location(Ty &L)
@ Init
Initialization function, sets up the coroutine frame.
NodeAddr< DefNode * > Def
NodeAddr< PhiNode * > Phi
NodeAddr< UseNode * > Use
NodeAddr< NodeBase * > Node
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
APInt operator*(APInt a, uint64_t RHS)
auto successors(const MachineBasicBlock *BB)
const Value * getLoadStorePointerOperand(const Value *V)
A helper function that returns the pointer operand of a load or store instruction.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
auto pred_size(const MachineBasicBlock *BB)
raw_ostream & WriteGraph(raw_ostream &O, const GraphType &G, bool ShortNames=false, const Twine &Title="")
bool operator==(const AddressRangeValuePair &LHS, const AddressRangeValuePair &RHS)
auto map_range(ContainerTy &&C, FuncTy F)
Return a range that applies F to the elements of C.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
DomTreeNodeBase< BasicBlock > DomTreeNode
const AnalysisOptions & getAnalysisOptions(const LLVMContext &C)
auto dyn_cast_or_null(const Y &Val)
iterator_range< def_chain_iterator< T > > def_chain(T MA, MemoryAccess *UpTo=nullptr)
bool isModSet(const ModRefInfo MRI)
auto find_if_not(R &&Range, UnaryPredicate P)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isAtLeastOrStrongerThan(AtomicOrdering AO, AtomicOrdering Other)
LLVM_ABI bool VerifyMemorySSA
Enables verification of MemorySSA.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
IDFCalculator< false > ForwardIDFCalculator
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
iterator_range(Container &&) -> iterator_range< llvm::detail::IterOfRange< Container > >
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
@ ModRef
The access may reference and may modify the value stored in memory.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
upward_defs_iterator upward_defs_end()
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
auto predecessors(const MachineBasicBlock *BB)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Instruction::const_succ_iterator const_succ_iterator
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
AAResults AliasAnalysis
Temporary typedef for legacy code that uses a generic AliasAnalysis pointer or reference.
upward_defs_iterator upward_defs_begin(const UpwardDefsElem &Pair, DominatorTree &DT)
bool isRefSet(const ModRefInfo MRI)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
A special type used by analysis passes to provide an address that identifies that particular analysis...
std::string getEdgeAttributes(const BasicBlock *Node, const_succ_iterator I, DOTFuncMSSAInfo *CFGInfo)
Display the raw branch weights from PGO.
std::string getNodeAttributes(const BasicBlock *Node, DOTFuncMSSAInfo *CFGInfo)
static std::string getEdgeSourceLabel(const BasicBlock *Node, const_succ_iterator I)
std::string getNodeLabel(const BasicBlock *Node, DOTFuncMSSAInfo *CFGInfo)
static std::string getGraphName(DOTFuncMSSAInfo *CFGInfo)
DOTGraphTraits(bool IsSimple=false)
DefaultDOTGraphTraits(bool simple=false)
static std::string getEdgeSourceLabel(const void *, EdgeIter)
getEdgeSourceLabel - If you want to label the edge source itself, implement this method.
pointer_iterator< Function::const_iterator > nodes_iterator
static size_t size(DOTFuncMSSAInfo *CFGInfo)
static NodeRef getEntryNode(DOTFuncMSSAInfo *CFGInfo)
static nodes_iterator nodes_begin(DOTFuncMSSAInfo *CFGInfo)
static nodes_iterator nodes_end(DOTFuncMSSAInfo *CFGInfo)
typename DOTFuncMSSAInfo *::UnknownGraphTypeError NodeRef
LLVM_ABI bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &Inv)
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Compile-time customization of User operands.