32#ifdef EXPENSIVE_CHECKS
38#define DEBUG_TYPE "lcg"
40void LazyCallGraph::EdgeSequence::insertEdgeInternal(
Node &TargetN,
42 EdgeIndexMap.try_emplace(&TargetN, Edges.
size());
46void LazyCallGraph::EdgeSequence::setEdgeKind(
Node &TargetN, Edge::Kind EK) {
47 Edges[EdgeIndexMap.find(&TargetN)->second].setKind(EK);
50bool LazyCallGraph::EdgeSequence::removeEdgeInternal(
Node &TargetN) {
51 auto IndexMapI = EdgeIndexMap.find(&TargetN);
52 if (IndexMapI == EdgeIndexMap.end())
55 Edges[IndexMapI->second] =
Edge();
56 EdgeIndexMap.erase(IndexMapI);
66 LLVM_DEBUG(
dbgs() <<
" Added callable function: " <<
N.getName() <<
"\n");
70LazyCallGraph::EdgeSequence &LazyCallGraph::Node::populateSlow() {
71 assert(!Edges &&
"Must not have already populated the edges for this node!");
74 <<
"' to the graph.\n");
79 SmallPtrSet<Function *, 4> Callees;
80 SmallPtrSet<Constant *, 16> Visited;
98 for (BasicBlock &BB : *
F)
99 for (Instruction &
I : BB) {
101 if (
Function *Callee = CB->getCalledFunction())
102 if (!
Callee->isDeclaration())
103 if (Callees.
insert(Callee).second) {
105 addEdge(Edges->Edges, Edges->EdgeIndexMap,
G->get(*Callee),
106 LazyCallGraph::Edge::Call);
109 for (
Value *
Op :
I.operand_values())
119 addEdge(Edges->Edges, Edges->EdgeIndexMap,
G->get(
F),
120 LazyCallGraph::Edge::Ref);
125 for (
auto *
F :
G->LibFunctions)
127 addEdge(Edges->Edges, Edges->EdgeIndexMap,
G->get(*
F),
128 LazyCallGraph::Edge::Ref);
133void LazyCallGraph::Node::replaceFunction(
Function &NewF) {
134 assert(
F != &NewF &&
"Must not replace a function with itself!");
138#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
140 dbgs() << *
this <<
'\n';
154 LLVM_DEBUG(
dbgs() <<
"Building CG for module: " << M.getModuleIdentifier()
157 if (
F.isDeclaration())
163 LibFunctions.insert(&
F);
165 if (
F.hasLocalLinkage())
171 <<
"' to entry set of the graph.\n");
172 addEdge(EntryEdges.Edges, EntryEdges.EdgeIndexMap,
get(
F), Edge::Ref);
177 for (
auto &
A : M.aliases()) {
178 if (
A.hasLocalLinkage())
182 <<
"' with alias '" <<
A.getName()
183 <<
"' to entry set of the graph.\n");
184 addEdge(EntryEdges.Edges, EntryEdges.EdgeIndexMap,
get(*
F), Edge::Ref);
192 if (GV.hasInitializer())
193 if (Visited.
insert(GV.getInitializer()).second)
197 dbgs() <<
" Adding functions referenced by global initializers to the "
200 addEdge(EntryEdges.Edges, EntryEdges.EdgeIndexMap,
get(
F),
201 LazyCallGraph::Edge::Ref);
212#if !defined(NDEBUG) || defined(EXPENSIVE_CHECKS)
221 ModuleAnalysisManager::Invalidator &) {
229 BPA = std::move(
G.BPA);
230 NodeMap = std::move(
G.NodeMap);
231 EntryEdges = std::move(
G.EntryEdges);
232 SCCBPA = std::move(
G.SCCBPA);
233 SCCMap = std::move(
G.SCCMap);
234 LibFunctions = std::move(
G.LibFunctions);
239#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
241 dbgs() << *
this <<
'\n';
245#if !defined(NDEBUG) || defined(EXPENSIVE_CHECKS)
246void LazyCallGraph::SCC::verify() {
247 assert(OuterRefSCC &&
"Can't have a null RefSCC!");
248 assert(!Nodes.empty() &&
"Can't have an empty SCC!");
250 for (
Node *
N : Nodes) {
251 assert(
N &&
"Can't have a null node!");
252 assert(OuterRefSCC->G->lookupSCC(*
N) ==
this &&
253 "Node does not map to this SCC!");
255 "Must set DFS numbers to -1 when adding a node to an SCC!");
257 "Must set low link to -1 when adding a node to an SCC!");
259 assert(
E.getNode().isPopulated() &&
"Can't have an unpopulated node!");
261#ifdef EXPENSIVE_CHECKS
266 while (!Worklist.
empty()) {
268 if (!Visited.
insert(VisitingNode).second)
270 for (Edge &
E : (*VisitingNode)->calls())
273 for (
Node *NodeToVisit : Nodes) {
275 "Cannot reach all nodes within SCC");
286 for (
Node &
N : *
this)
287 for (
Edge &E :
N->calls())
288 if (OuterRefSCC->G->lookupSCC(E.getNode()) == &
C)
296 if (
this == &TargetC)
309 for (
Edge &E :
N->calls()) {
310 SCC *CalleeC =
G.lookupSCC(E.getNode());
315 if (CalleeC == &TargetC)
320 if (Visited.
insert(CalleeC).second)
323 }
while (!Worklist.
empty());
331#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
333 dbgs() << *
this <<
'\n';
337#if !defined(NDEBUG) || defined(EXPENSIVE_CHECKS)
338void LazyCallGraph::RefSCC::verify() {
339 assert(
G &&
"Can't have a null graph!");
340 assert(!SCCs.empty() &&
"Can't have an empty SCC!");
344 for (SCC *
C : SCCs) {
345 assert(
C &&
"Can't have a null SCC!");
347 assert(&
C->getOuterRefSCC() ==
this &&
348 "SCC doesn't think it is inside this RefSCC!");
349 bool Inserted = SCCSet.
insert(
C).second;
350 assert(Inserted &&
"Found a duplicate SCC!");
351 auto IndexIt = SCCIndices.find(
C);
352 assert(IndexIt != SCCIndices.end() &&
353 "Found an SCC that doesn't have an index!");
357 for (
auto [
C,
I] : SCCIndices) {
358 assert(
C &&
"Can't have a null SCC in the indices!");
359 assert(SCCSet.
count(
C) &&
"Found an index for an SCC not in the RefSCC!");
360 assert(SCCs[
I] ==
C &&
"Index doesn't point to SCC!");
364 for (
int I = 0,
Size = SCCs.size();
I <
Size; ++
I) {
365 SCC &SourceSCC = *SCCs[
I];
366 for (
Node &
N : SourceSCC)
370 SCC &TargetSCC = *
G->lookupSCC(
E.getNode());
371 if (&TargetSCC.getOuterRefSCC() ==
this) {
372 assert(SCCIndices.find(&TargetSCC)->second <=
I &&
373 "Edge between SCCs violates post-order relationship.");
379#ifdef EXPENSIVE_CHECKS
382 for (
SCC *
C : SCCs) {
386 for (
Node *
N : Nodes) {
388 SmallPtrSet<Node *, 4> Visited;
390 while (!Worklist.
empty()) {
392 if (!Visited.
insert(VisitingNode).second)
394 for (
Edge &
E : **VisitingNode)
397 for (
Node *NodeToVisit : Nodes) {
399 "Cannot reach all nodes within RefSCC");
414 if (G->lookupRefSCC(E.getNode()) == &RC)
433 for (
SCC &
C : DescendantRC)
436 auto *ChildRC = G->lookupRefSCC(E.getNode());
439 if (!ChildRC || !Visited.
insert(ChildRC).second)
443 }
while (!Worklist.
empty());
510template <
typename SCCT,
typename PostorderSequenceT,
typename SCCIndexMapT,
511 typename ComputeSourceConnectedSetCallableT,
512 typename ComputeTargetConnectedSetCallableT>
515 SCCT &SourceSCC, SCCT &TargetSCC, PostorderSequenceT &SCCs,
516 SCCIndexMapT &SCCIndices,
517 ComputeSourceConnectedSetCallableT ComputeSourceConnectedSet,
518 ComputeTargetConnectedSetCallableT ComputeTargetConnectedSet) {
519 int SourceIdx = SCCIndices[&SourceSCC];
520 int TargetIdx = SCCIndices[&TargetSCC];
521 assert(SourceIdx < TargetIdx &&
"Cannot have equal indices here!");
526 ComputeSourceConnectedSet(ConnectedSet);
531 auto SourceI = std::stable_partition(
532 SCCs.begin() + SourceIdx, SCCs.begin() + TargetIdx + 1,
533 [&ConnectedSet](SCCT *
C) { return !ConnectedSet.count(C); });
534 for (
int I = SourceIdx,
E = TargetIdx + 1;
I <
E; ++
I)
535 SCCIndices.find(SCCs[
I])->second =
I;
539 if (!ConnectedSet.
count(&TargetSCC)) {
540 assert(SourceI > (SCCs.begin() + SourceIdx) &&
541 "Must have moved the source to fix the post-order.");
542 assert(*std::prev(SourceI) == &TargetSCC &&
543 "Last SCC to move should have bene the target.");
547 return make_range(std::prev(SourceI), std::prev(SourceI));
550 assert(SCCs[TargetIdx] == &TargetSCC &&
551 "Should not have moved target if connected!");
552 SourceIdx = SourceI - SCCs.begin();
553 assert(SCCs[SourceIdx] == &SourceSCC &&
554 "Bad updated index computation for the source SCC!");
559 if (SourceIdx + 1 < TargetIdx) {
560 ConnectedSet.
clear();
561 ComputeTargetConnectedSet(ConnectedSet);
565 auto TargetI = std::stable_partition(
566 SCCs.begin() + SourceIdx + 1, SCCs.begin() + TargetIdx + 1,
567 [&ConnectedSet](SCCT *
C) { return ConnectedSet.count(C); });
568 for (
int I = SourceIdx + 1,
E = TargetIdx + 1;
I <
E; ++
I)
569 SCCIndices.find(SCCs[
I])->second =
I;
570 TargetIdx = std::prev(TargetI) - SCCs.begin();
571 assert(SCCs[TargetIdx] == &TargetSCC &&
572 "Should always end with the target!");
579 return make_range(SCCs.begin() + SourceIdx, SCCs.begin() + TargetIdx);
585 assert(!(*SourceN)[TargetN].isCall() &&
"Must start with a ref edge!");
588#ifdef EXPENSIVE_CHECKS
593 SCC &SourceSCC = *G->lookupSCC(SourceN);
594 SCC &TargetSCC = *G->lookupSCC(TargetN);
598 if (&SourceSCC == &TargetSCC) {
599 SourceN->setEdgeKind(TargetN, Edge::Call);
609 int SourceIdx = SCCIndices[&SourceSCC];
610 int TargetIdx = SCCIndices[&TargetSCC];
611 if (TargetIdx < SourceIdx) {
612 SourceN->setEdgeKind(TargetN, Edge::Call);
618#ifdef EXPENSIVE_CHECKS
623 ConnectedSet.insert(&SourceSCC);
624 auto IsConnected = [&](
SCC &
C) {
626 for (
Edge &E :
N->calls())
627 if (ConnectedSet.count(G->lookupSCC(E.getNode())))
634 make_range(SCCs.begin() + SourceIdx + 1, SCCs.begin() + TargetIdx + 1))
636 ConnectedSet.insert(
C);
644#ifdef EXPENSIVE_CHECKS
649 ConnectedSet.insert(&TargetSCC);
658 SCC &EdgeC = *G->lookupSCC(E.getNode());
662 if (SCCIndices.find(&EdgeC)->second <= SourceIdx)
666 if (ConnectedSet.insert(&EdgeC).second)
669 }
while (!Worklist.
empty());
677 SourceSCC, TargetSCC, SCCs, SCCIndices, ComputeSourceConnectedSet,
678 ComputeTargetConnectedSet);
682 MergeCB(
ArrayRef(MergeRange.begin(), MergeRange.end()));
686 if (MergeRange.empty()) {
688 SourceN->setEdgeKind(TargetN, Edge::Call);
692#ifdef EXPENSIVE_CHECKS
704 for (
SCC *
C : MergeRange) {
706 "We merge *into* the target and shouldn't process it here!");
708 TargetSCC.Nodes.append(
C->Nodes.begin(),
C->Nodes.end());
710 G->SCCMap[
N] = &TargetSCC;
717 int IndexOffset = MergeRange.end() - MergeRange.begin();
718 auto EraseEnd = SCCs.erase(MergeRange.begin(), MergeRange.end());
720 SCCIndices[
C] -= IndexOffset;
723 SourceN->setEdgeKind(TargetN, Edge::Call);
731 assert((*SourceN)[TargetN].isCall() &&
"Must start with a call edge!");
733#ifdef EXPENSIVE_CHECKS
738 assert(G->lookupRefSCC(SourceN) ==
this &&
"Source must be in this RefSCC.");
739 assert(G->lookupRefSCC(TargetN) ==
this &&
"Target must be in this RefSCC.");
740 assert(G->lookupSCC(SourceN) != G->lookupSCC(TargetN) &&
741 "Source and Target must be in separate SCCs for this to be trivial!");
744 SourceN->setEdgeKind(TargetN, Edge::Ref);
749 assert((*SourceN)[TargetN].isCall() &&
"Must start with a call edge!");
751#ifdef EXPENSIVE_CHECKS
756 assert(G->lookupRefSCC(SourceN) ==
this &&
"Source must be in this RefSCC.");
757 assert(G->lookupRefSCC(TargetN) ==
this &&
"Target must be in this RefSCC.");
759 SCC &TargetSCC = *G->lookupSCC(TargetN);
760 assert(G->lookupSCC(SourceN) == &TargetSCC &&
"Source and Target must be in "
761 "the same SCC to require the "
765 SourceN->setEdgeKind(TargetN, Edge::Ref);
779 SCC &OldSCC = TargetSCC;
786 Worklist.
swap(OldSCC.Nodes);
787 for (
Node *
N : Worklist) {
788 N->DFSNumber =
N->LowLink = 0;
800 TargetN.DFSNumber = TargetN.LowLink = -1;
801 OldSCC.Nodes.push_back(&TargetN);
802 G->SCCMap[&TargetN] = &OldSCC;
807 "Cannot begin a new root with a non-empty DFS stack!");
809 "Cannot begin a new root with pending nodes for an SCC!");
812 if (
RootN->DFSNumber != 0) {
814 "Shouldn't have any mid-DFS root nodes!");
819 int NextDFSNumber = 2;
824 auto E = (*N)->call_end();
826 Node &ChildN =
I->getNode();
827 if (ChildN.DFSNumber == 0) {
832 assert(!G->SCCMap.count(&ChildN) &&
833 "Found a node with 0 DFS number but already in an SCC!");
834 ChildN.DFSNumber = ChildN.LowLink = NextDFSNumber++;
836 I = (*N)->call_begin();
837 E = (*N)->call_end();
842 if (ChildN.DFSNumber == -1) {
843 if (G->lookupSCC(ChildN) == &OldSCC) {
848 int OldSize = OldSCC.
size();
849 OldSCC.Nodes.push_back(
N);
850 OldSCC.Nodes.append(PendingSCCStack.
begin(), PendingSCCStack.
end());
851 PendingSCCStack.
clear();
852 while (!DFSStack.
empty())
855 N.DFSNumber =
N.LowLink = -1;
856 G->SCCMap[&
N] = &OldSCC;
870 assert(ChildN.LowLink > 0 &&
"Must have a positive low-link number!");
871 if (ChildN.LowLink <
N->LowLink)
872 N->LowLink = ChildN.LowLink;
887 if (
N->LowLink !=
N->DFSNumber)
892 int RootDFSNumber =
N->DFSNumber;
898 return N->DFSNumber < RootDFSNumber;
903 NewSCCs.
push_back(G->createSCC(*
this, SCCNodes));
905 N.DFSNumber =
N.LowLink = -1;
906 G->SCCMap[&
N] = NewSCCs.
back();
908 PendingSCCStack.
erase(SCCNodes.end().base(), PendingSCCStack.
end());
909 }
while (!DFSStack.
empty());
916 int OldIdx = SCCIndices[&OldSCC];
917 SCCs.insert(SCCs.begin() + OldIdx, NewSCCs.
begin(), NewSCCs.
end());
921 for (
int Idx = OldIdx,
Size = SCCs.size(); Idx <
Size; ++Idx)
922 SCCIndices[SCCs[Idx]] = Idx;
925 SCCs.begin() + OldIdx + NewSCCs.
size());
930 assert(!(*SourceN)[TargetN].isCall() &&
"Must start with a ref edge!");
932 assert(G->lookupRefSCC(SourceN) ==
this &&
"Source must be in this RefSCC.");
933 assert(G->lookupRefSCC(TargetN) !=
this &&
934 "Target must not be in this RefSCC.");
935#ifdef EXPENSIVE_CHECKS
936 assert(G->lookupRefSCC(TargetN)->isDescendantOf(*
this) &&
937 "Target must be a descendant of the Source.");
942 SourceN->setEdgeKind(TargetN, Edge::Call);
944#ifdef EXPENSIVE_CHECKS
951 assert((*SourceN)[TargetN].isCall() &&
"Must start with a call edge!");
953 assert(G->lookupRefSCC(SourceN) ==
this &&
"Source must be in this RefSCC.");
954 assert(G->lookupRefSCC(TargetN) !=
this &&
955 "Target must not be in this RefSCC.");
956#ifdef EXPENSIVE_CHECKS
957 assert(G->lookupRefSCC(TargetN)->isDescendantOf(*
this) &&
958 "Target must be a descendant of the Source.");
963 SourceN->setEdgeKind(TargetN, Edge::Ref);
965#ifdef EXPENSIVE_CHECKS
972 assert(G->lookupRefSCC(SourceN) ==
this &&
"Source must be in this RefSCC.");
973 assert(G->lookupRefSCC(TargetN) ==
this &&
"Target must be in this RefSCC.");
975 SourceN->insertEdgeInternal(TargetN, Edge::Ref);
977#ifdef EXPENSIVE_CHECKS
985 SourceN->insertEdgeInternal(TargetN, EK);
987 assert(G->lookupRefSCC(SourceN) ==
this &&
"Source must be in this RefSCC.");
989 assert(G->lookupRefSCC(TargetN) !=
this &&
990 "Target must not be in this RefSCC.");
991#ifdef EXPENSIVE_CHECKS
992 assert(G->lookupRefSCC(TargetN)->isDescendantOf(*
this) &&
993 "Target must be a descendant of the Source.");
996#ifdef EXPENSIVE_CHECKS
1003 assert(G->lookupRefSCC(TargetN) ==
this &&
"Target must be in this RefSCC.");
1004 RefSCC &SourceC = *G->lookupRefSCC(SourceN);
1005 assert(&SourceC !=
this &&
"Source must not be in this RefSCC.");
1006#ifdef EXPENSIVE_CHECKS
1008 "Source must be a descendant of the Target.");
1013#ifdef EXPENSIVE_CHECKS
1018 int SourceIdx = G->RefSCCIndices[&SourceC];
1019 int TargetIdx = G->RefSCCIndices[
this];
1020 assert(SourceIdx < TargetIdx &&
1021 "Postorder list doesn't see edge as incoming!");
1031 Set.insert(&SourceC);
1032 auto IsConnected = [&](RefSCC &RC) {
1036 if (Set.count(G->lookupRefSCC(E.getNode())))
1042 for (RefSCC *
C :
make_range(G->PostOrderRefSCCs.begin() + SourceIdx + 1,
1043 G->PostOrderRefSCCs.begin() + TargetIdx + 1))
1044 if (IsConnected(*
C))
1060 for (
Edge &E : *
N) {
1061 RefSCC &EdgeRC = *G->lookupRefSCC(E.getNode());
1062 if (G->getRefSCCIndex(EdgeRC) <= SourceIdx)
1066 if (Set.insert(&EdgeRC).second)
1069 }
while (!Worklist.
empty());
1078 SourceC, *
this, G->PostOrderRefSCCs, G->RefSCCIndices,
1079 ComputeSourceConnectedSet, ComputeTargetConnectedSet);
1092 for (RefSCC *RC : MergeRange) {
1093 assert(RC !=
this &&
"We're merging into the target RefSCC, so it "
1094 "shouldn't be in the range.");
1100 for (
SCC &InnerC : *RC) {
1101 InnerC.OuterRefSCC =
this;
1102 SCCIndices[&InnerC] = SCCIndex++;
1103 for (
Node &
N : InnerC)
1104 G->SCCMap[&
N] = &InnerC;
1109 if (MergedSCCs.
empty())
1110 MergedSCCs = std::move(RC->SCCs);
1112 MergedSCCs.
append(RC->SCCs.begin(), RC->SCCs.end());
1118 for (
SCC &InnerC : *
this)
1119 SCCIndices[&InnerC] = SCCIndex++;
1120 MergedSCCs.
append(SCCs.begin(), SCCs.end());
1121 SCCs = std::move(MergedSCCs);
1124 for (RefSCC *RC : MergeRange)
1125 G->RefSCCIndices.erase(RC);
1126 int IndexOffset = MergeRange.
end() - MergeRange.
begin();
1128 G->PostOrderRefSCCs.erase(MergeRange.
begin(), MergeRange.
end());
1129 for (RefSCC *RC :
make_range(EraseEnd, G->PostOrderRefSCCs.end()))
1130 G->RefSCCIndices[RC] -= IndexOffset;
1134 SourceN->insertEdgeInternal(TargetN, Edge::Ref);
1140 return DeletedRefSCCs;
1144 assert(G->lookupRefSCC(SourceN) ==
this &&
1145 "The source must be a member of this RefSCC.");
1146 assert(G->lookupRefSCC(TargetN) !=
this &&
1147 "The target must not be a member of this RefSCC");
1149#ifdef EXPENSIVE_CHECKS
1155 bool Removed = SourceN->removeEdgeInternal(TargetN);
1157 assert(Removed &&
"Target not in the edge set for this caller?");
1162 ArrayRef<std::pair<Node *, Node *>> Edges) {
1166#ifdef EXPENSIVE_CHECKS
1180 for (
auto [SourceN, TargetN] : Edges) {
1181 assert(!(**SourceN)[*TargetN].isCall() &&
1182 "Cannot remove a call edge, it must first be made a ref edge");
1184 bool Removed = (*SourceN)->removeEdgeInternal(*TargetN);
1186 assert(Removed &&
"Target not in the edge set for this caller?");
1192 if (
llvm::all_of(Edges, [&](std::pair<Node *, Node *> E) {
1193 return E.first == E.second ||
1194 G->lookupSCC(*E.first) == G->lookupSCC(*E.second);
1204 int PostOrderNumber = 0;
1209 for (
SCC *
C : SCCs) {
1211 N.DFSNumber =
N.LowLink = 0;
1213 Worklist.
append(
C->Nodes.begin(),
C->Nodes.end());
1219 const int NumRefSCCNodes = Worklist.
size();
1225 "Cannot begin a new root with a non-empty DFS stack!");
1227 "Cannot begin a new root with pending nodes for an SCC!");
1231 if (
RootN->DFSNumber != 0) {
1233 "Shouldn't have any mid-DFS root nodes!");
1238 int NextDFSNumber = 2;
1243 auto E = (*N)->end();
1245 assert(
N->DFSNumber != 0 &&
"We should always assign a DFS number "
1246 "before processing a node.");
1249 Node &ChildN =
I->getNode();
1250 if (ChildN.DFSNumber == 0) {
1257 ChildN.LowLink = ChildN.DFSNumber = NextDFSNumber++;
1263 if (ChildN.DFSNumber == -1) {
1272 assert(ChildN.LowLink != 0 &&
1273 "Low-link must not be zero with a non-zero DFS number.");
1274 if (ChildN.LowLink >= 0 && ChildN.LowLink <
N->LowLink)
1275 N->LowLink = ChildN.LowLink;
1285 if (
N->LowLink !=
N->DFSNumber) {
1287 "We never found a viable root for a RefSCC to pop off!");
1292 int RefSCCNumber = PostOrderNumber++;
1293 int RootDFSNumber =
N->DFSNumber;
1299 if (
N->DFSNumber < RootDFSNumber)
1307 N->LowLink = RefSCCNumber;
1310 auto RefSCCNodes =
make_range(StackRI.base(), PendingRefSCCStack.
end());
1316 if (
llvm::size(RefSCCNodes) == NumRefSCCNodes) {
1318 for (
Node *
N : RefSCCNodes)
1326 PendingRefSCCStack.
erase(RefSCCNodes.begin(), PendingRefSCCStack.
end());
1327 }
while (!DFSStack.
empty());
1329 assert(DFSStack.
empty() &&
"Didn't flush the entire DFS stack!");
1330 assert(PendingRefSCCStack.
empty() &&
"Didn't flush all pending nodes!");
1331 }
while (!Worklist.
empty());
1333 assert(PostOrderNumber > 1 &&
1334 "Should never finish the DFS when the existing RefSCC remains valid!");
1340 for (
int I = 0;
I < PostOrderNumber; ++
I)
1341 Result.push_back(G->createRefSCC(*G));
1350 int Idx = G->getRefSCCIndex(*
this);
1351 G->PostOrderRefSCCs.erase(G->PostOrderRefSCCs.begin() + Idx);
1352 G->PostOrderRefSCCs.insert(G->PostOrderRefSCCs.begin() + Idx, Result.begin(),
1354 for (
int I :
seq<int>(Idx, G->PostOrderRefSCCs.size()))
1355 G->RefSCCIndices[G->PostOrderRefSCCs[
I]] =
I;
1357 for (
SCC *
C : SCCs) {
1359 int SCCNumber =
C->begin()->LowLink;
1363 assert(
N.LowLink == SCCNumber &&
1364 "Cannot have different numbers for nodes in the same SCC!");
1368 RefSCC &RC = *Result[SCCNumber];
1369 int SCCIndex = RC.SCCs.size();
1370 RC.SCCs.push_back(
C);
1371 RC.SCCIndices[
C] = SCCIndex;
1372 C->OuterRefSCC = &RC;
1381#ifdef EXPENSIVE_CHECKS
1383 for (RefSCC *RC : Result)
1393#ifdef EXPENSIVE_CHECKS
1398 SCC &SourceC = *G->lookupSCC(SourceN);
1399 SCC &TargetC = *G->lookupSCC(TargetN);
1400 if (&SourceC != &TargetC)
1401 assert(SourceC.isAncestorOf(TargetC) &&
1402 "Call edge is not trivial in the SCC graph!");
1406 auto [Iterator, Inserted] =
1407 SourceN->EdgeIndexMap.try_emplace(&TargetN, SourceN->Edges.
size());
1410 Edge &E = SourceN->Edges[Iterator->second];
1413 E.setKind(Edge::Call);
1421#ifdef EXPENSIVE_CHECKS
1425 RefSCC &SourceRC = *G->lookupRefSCC(SourceN);
1426 RefSCC &TargetRC = *G->lookupRefSCC(TargetN);
1427 if (&SourceRC != &TargetRC)
1428 assert(SourceRC.isAncestorOf(TargetRC) &&
1429 "Ref edge is not trivial in the RefSCC graph!");
1433 auto [Iterator, Inserted] =
1434 SourceN->EdgeIndexMap.try_emplace(&TargetN, SourceN->Edges.
size());
1447#ifdef EXPENSIVE_CHECKS
1450 assert(G->lookupRefSCC(
N) ==
this &&
1451 "Cannot replace the function of a node outside this RefSCC.");
1453 assert(G->NodeMap.find(&NewF) == G->NodeMap.end() &&
1454 "Must not have already walked the new function!'");
1462 assert(&OldF != &NewF &&
"Cannot replace a function with itself!");
1464 "Must have moved all uses from the old function to the new!");
1467 N.replaceFunction(NewF);
1470 G->NodeMap.erase(&OldF);
1471 G->NodeMap[&NewF] = &
N;
1474 if (G->isLibFunction(OldF)) {
1475 G->LibFunctions.remove(&OldF);
1476 G->LibFunctions.insert(&NewF);
1482 "This method cannot be called after SCCs have been formed!");
1484 return SourceN->insertEdgeInternal(TargetN, EK);
1489 "This method cannot be called after SCCs have been formed!");
1491 bool Removed = SourceN->removeEdgeInternal(TargetN);
1493 assert(Removed &&
"Target not in the edge set for this caller?");
1500 "This routine should only be called on trivially dead functions!");
1505 "Must not remove lib functions from the call graph!");
1507 auto NI = NodeMap.find(&
F);
1508 assert(NI != NodeMap.end() &&
"Removed function should be known!");
1510 Node &
N = *NI->second;
1515 N->setEdgeKind(E.getNode(), Edge::Ref);
1528 for (
Edge &E : **
N) {
1530 "dead function shouldn't have any outgoing call edges");
1534 RCs[RC].push_back(
N);
1539 for (
auto [RC, DeadNs] : RCs) {
1541 for (
Node *DeadN : DeadNs) {
1542 for (
Edge &E : **DeadN) {
1544 InternalEdgesToRemove.
push_back({DeadN, &E.getNode()});
1546 RC->removeOutgoingEdge(*DeadN, E.getNode());
1551 (void)RC->removeInternalRefEdges(InternalEdgesToRemove);
1552 for (
Node *DeadN : DeadNs) {
1557 DeadRC->G =
nullptr;
1564 EntryEdges.removeEdgeInternal(
N);
1565 SCCMap.erase(SCCMap.find(&
N));
1566 NodeMap.erase(NodeMap.find(DeadF));
1591 if (
Function *Callee = CB->getCalledFunction()) {
1592 if (Callee == &NewFunction)
1593 return LazyCallGraph::Edge::Kind::Call;
1597 for (
Value *
Op :
I.operand_values()) {
1607 bool FoundNewFunction =
false;
1609 if (&
F == &NewFunction)
1610 FoundNewFunction =
true;
1612 assert(FoundNewFunction &&
"No edge from original function to new function");
1615 return LazyCallGraph::Edge::Kind::Ref;
1621 "Original function's node should already exist");
1622 Node &OriginalN =
get(OriginalFunction);
1626#ifdef EXPENSIVE_CHECKS
1627 OriginalRC->verify();
1632 "New function's node should not already exist");
1633 Node &NewN = initNode(NewFunction);
1635 Edge::Kind EK =
getEdgeKind(OriginalFunction, NewFunction);
1637 SCC *NewC =
nullptr;
1638 for (
Edge &E : *NewN) {
1639 Node &EN = E.getNode();
1640 if (EK == Edge::Kind::Call && E.isCall() &&
lookupSCC(EN) == OriginalC) {
1645 NewC->Nodes.push_back(&NewN);
1651 for (
Edge &E : *NewN) {
1652 Node &EN = E.getNode();
1657 RefSCC *NewRC = OriginalRC;
1667 int InsertIndex = EK == Edge::Kind::Call ? NewRC->SCCIndices[OriginalC]
1668 : NewRC->SCCIndices.size();
1669 NewRC->SCCs.insert(NewRC->SCCs.begin() + InsertIndex, NewC);
1670 for (
int I = InsertIndex,
Size = NewRC->SCCs.size();
I <
Size; ++
I)
1671 NewRC->SCCIndices[NewRC->SCCs[
I]] =
I;
1682 RefSCC *NewRC = createRefSCC(*
this);
1684 NewRC->SCCIndices[NewC] = 0;
1685 NewRC->SCCs.push_back(NewC);
1686 auto OriginalRCIndex = RefSCCIndices.find(OriginalRC)->second;
1687 PostOrderRefSCCs.insert(PostOrderRefSCCs.begin() + OriginalRCIndex, NewRC);
1688 for (
int I = OriginalRCIndex,
Size = PostOrderRefSCCs.size();
I <
Size; ++
I)
1689 RefSCCIndices[PostOrderRefSCCs[
I]] =
I;
1692 SCCMap[&NewN] = NewC;
1694 OriginalN->insertEdgeInternal(NewN, EK);
1699 assert(!NewFunctions.
empty() &&
"Can't add zero functions");
1701 "Original function's node should already exist");
1702 Node &OriginalN =
get(OriginalFunction);
1705#ifdef EXPENSIVE_CHECKS
1706 OriginalRC->verify();
1708 OriginalRC->verify();
1709 for (
Function *NewFunction : NewFunctions)
1714 bool ExistsRefToOriginalRefSCC =
false;
1716 for (
Function *NewFunction : NewFunctions) {
1717 Node &NewN = initNode(*NewFunction);
1719 OriginalN->insertEdgeInternal(NewN, Edge::Kind::Ref);
1723 for (
Edge &E : *NewN) {
1725 ExistsRefToOriginalRefSCC =
true;
1732 if (ExistsRefToOriginalRefSCC) {
1739 NewRC = createRefSCC(*
this);
1743 auto OriginalRCIndex = RefSCCIndices.find(OriginalRC)->second;
1744 PostOrderRefSCCs.insert(PostOrderRefSCCs.begin() + OriginalRCIndex, NewRC);
1745 for (
int I = OriginalRCIndex,
Size = PostOrderRefSCCs.size();
I <
Size; ++
I)
1746 RefSCCIndices[PostOrderRefSCCs[
I]] =
I;
1749 for (
Function *NewFunction : NewFunctions) {
1750 Node &NewN =
get(*NewFunction);
1759 auto Index = NewRC->SCCIndices.size();
1760 NewRC->SCCIndices[NewC] = Index;
1761 NewRC->SCCs.push_back(NewC);
1762 SCCMap[&NewN] = NewC;
1766 for (
Function *F1 : NewFunctions) {
1768 "Expected ref edges from original function to every new function");
1770 for (
Function *F2 : NewFunctions) {
1775 "Edges between new functions must be ref edges");
1782 return *
new (MappedN = BPA.Allocate())
Node(*
this,
F);
1785void LazyCallGraph::updateGraphPtrs() {
1788 for (
auto &FunctionNodePair : NodeMap)
1789 FunctionNodePair.second->G =
this;
1791 for (
auto *RC : PostOrderRefSCCs)
1795LazyCallGraph::Node &LazyCallGraph::initNode(
Function &
F) {
1797 N.DFSNumber =
N.LowLink = -1;
1803template <
typename RootsT,
typename GetBeginT,
typename GetEndT,
1804 typename GetNodeT,
typename FormSCCCallbackT>
1805void LazyCallGraph::buildGenericSCCs(RootsT &&Roots, GetBeginT &&GetBegin,
1806 GetEndT &&GetEnd, GetNodeT &&GetNode,
1807 FormSCCCallbackT &&FormSCC) {
1808 using EdgeItT =
decltype(GetBegin(std::declval<Node &>()));
1816 "Cannot begin a new root with a non-empty DFS stack!");
1818 "Cannot begin a new root with pending nodes for an SCC!");
1821 if (
RootN->DFSNumber != 0) {
1823 "Shouldn't have any mid-DFS root nodes!");
1828 int NextDFSNumber = 2;
1833 auto E = GetEnd(*
N);
1835 Node &ChildN = GetNode(
I);
1836 if (ChildN.DFSNumber == 0) {
1841 ChildN.DFSNumber = ChildN.LowLink = NextDFSNumber++;
1851 if (ChildN.DFSNumber == -1) {
1857 assert(ChildN.LowLink > 0 &&
"Must have a positive low-link number!");
1858 if (ChildN.LowLink <
N->LowLink)
1859 N->LowLink = ChildN.LowLink;
1871 if (
N->LowLink !=
N->DFSNumber)
1876 int RootDFSNumber =
N->DFSNumber;
1880 PendingSCCStack.
rbegin(),
1882 return N->DFSNumber < RootDFSNumber;
1887 PendingSCCStack.
erase(SCCNodes.end().base(), PendingSCCStack.
end());
1888 }
while (!DFSStack.
empty());
1897void LazyCallGraph::buildSCCs(
RefSCC &RC, node_stack_range Nodes) {
1898 assert(RC.SCCs.empty() &&
"Already built SCCs!");
1899 assert(RC.SCCIndices.empty() &&
"Already mapped SCC indices!");
1901 for (
Node *
N : Nodes) {
1902 assert(
N->LowLink >= (*Nodes.begin())->LowLink &&
1903 "We cannot have a low link in an SCC lower than its root on the "
1908 N->DFSNumber =
N->LowLink = 0;
1915 Nodes, [](
Node &
N) {
return N->call_begin(); },
1916 [](
Node &
N) {
return N->call_end(); },
1918 [
this, &RC](node_stack_range Nodes) {
1919 RC.SCCs.push_back(createSCC(RC, Nodes));
1920 for (
Node &
N : *RC.SCCs.back()) {
1921 N.DFSNumber =
N.LowLink = -1;
1922 SCCMap[&
N] = RC.SCCs.back();
1927 for (
int I = 0,
Size = RC.SCCs.size();
I <
Size; ++
I)
1928 RC.SCCIndices[RC.SCCs[
I]] =
I;
1932 if (EntryEdges.empty() || !PostOrderRefSCCs.empty())
1936 assert(RefSCCIndices.empty() &&
"Already mapped RefSCC indices!");
1939 for (
Edge &E : *
this)
1950 [](
Node &
N) {
return N->end(); },
1952 [
this](node_stack_range Nodes) {
1953 RefSCC *NewRC = createRefSCC(*
this);
1954 buildSCCs(*NewRC, Nodes);
1959 RefSCCIndices.try_emplace(NewRC, PostOrderRefSCCs.
size()).second;
1961 assert(Inserted &&
"Cannot already have this RefSCC in the index map!");
1962 PostOrderRefSCCs.push_back(NewRC);
1963#ifdef EXPENSIVE_CHECKS
1972 while (!Worklist.
empty()) {
1976 if (!
F->isDeclaration())
1986 for (
Value *
Op :
C->operand_values())
1997 OS <<
" Edges in function: " <<
N.getFunction().getName() <<
"\n";
1999 OS <<
" " << (
E.isCall() ?
"call" :
"ref ") <<
" -> "
2000 <<
E.getFunction().getName() <<
"\n";
2006 OS <<
" SCC with " <<
C.size() <<
" functions:\n";
2009 OS <<
" " <<
N.getFunction().getName() <<
"\n";
2013 OS <<
" RefSCC with " <<
C.size() <<
" call SCCs:\n";
2025 OS <<
"Printing the call graph for module: " << M.getModuleIdentifier()
2046 OS <<
" " << Name <<
" -> \""
2049 OS <<
" [style=dashed,label=\"ref\"]";
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Expand Atomic instructions
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
static void printNode(raw_ostream &OS, LazyCallGraph::Node &N)
static void printRefSCC(raw_ostream &OS, LazyCallGraph::RefSCC &C)
static iterator_range< typename PostorderSequenceT::iterator > updatePostorderSequenceForEdgeInsertion(SCCT &SourceSCC, SCCT &TargetSCC, PostorderSequenceT &SCCs, SCCIndexMapT &SCCIndices, ComputeSourceConnectedSetCallableT ComputeSourceConnectedSet, ComputeTargetConnectedSetCallableT ComputeTargetConnectedSet)
Generic helper that updates a postorder sequence of SCCs for a potentially cycle-introducing edge ins...
static void printNodeDOT(raw_ostream &OS, LazyCallGraph::Node &N)
static LazyCallGraph::Edge::Kind getEdgeKind(Function &OriginalFunction, Function &NewFunction)
static void printSCC(raw_ostream &OS, LazyCallGraph::SCC &C)
static void addEdge(SmallVectorImpl< LazyCallGraph::Edge > &Edges, DenseMap< LazyCallGraph::Node *, int > &EdgeIndexMap, LazyCallGraph::Node &N, LazyCallGraph::Edge::Kind EK)
static bool isKnownLibFunction(Function &F, TargetLibraryInfo &TLI)
Implements a lazy call graph analysis and related passes for the new pass manager.
static StringRef getName(Value *V)
std::pair< BasicBlock *, BasicBlock * > Edge
This file defines the scope_exit class, which executes user-defined cleanup logic at scope exit.
Provides some synthesis utilities to produce sequences of values.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
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 a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
Check if the array is empty.
This is an important base class in LLVM.
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
An analysis pass which computes the call graph for a module.
LLVM_ABI LazyCallGraphDOTPrinterPass(raw_ostream &OS)
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
LLVM_ABI LazyCallGraphPrinterPass(raw_ostream &OS)
An iterator over specifically call edges.
An iterator used for the edges to both entry nodes and child nodes.
The edge sequence object.
A class used to represent edges in the call graph.
bool isCall() const
Test whether the edge represents a direct call to a function.
A node in the call graph.
A RefSCC of the call graph.
LLVM_ABI SmallVector< RefSCC *, 1 > insertIncomingRefEdge(Node &SourceN, Node &TargetN)
Insert an edge whose source is in a descendant RefSCC and target is in this RefSCC.
LLVM_ABI bool switchInternalEdgeToCall(Node &SourceN, Node &TargetN, function_ref< void(ArrayRef< SCC * > MergedSCCs)> MergeCB={})
Make an existing internal ref edge into a call edge.
LLVM_ABI bool isAncestorOf(const RefSCC &RC) const
Test if this RefSCC is an ancestor of RC.
LLVM_ABI void insertTrivialRefEdge(Node &SourceN, Node &TargetN)
A convenience wrapper around the above to handle trivial cases of inserting a new ref edge.
friend class LazyCallGraph::Node
bool isDescendantOf(const RefSCC &RC) const
Test if this RefSCC is a descendant of RC.
LLVM_ABI void switchOutgoingEdgeToCall(Node &SourceN, Node &TargetN)
Make an existing outgoing ref edge into a call edge.
LLVM_ABI void replaceNodeFunction(Node &N, Function &NewF)
Directly replace a node's function with a new function.
LLVM_ABI void insertOutgoingEdge(Node &SourceN, Node &TargetN, Edge::Kind EK)
Insert an edge whose parent is in this RefSCC and child is in some child RefSCC.
LLVM_ABI SmallVector< RefSCC *, 1 > removeInternalRefEdges(ArrayRef< std::pair< Node *, Node * > > Edges)
Remove a list of ref edges which are entirely within this RefSCC.
LLVM_ABI iterator_range< iterator > switchInternalEdgeToRef(Node &SourceN, Node &TargetN)
Make an existing internal call edge within a single SCC into a ref edge.
LLVM_ABI void insertInternalRefEdge(Node &SourceN, Node &TargetN)
Insert a ref edge from one node in this RefSCC to another in this RefSCC.
LLVM_ABI void insertTrivialCallEdge(Node &SourceN, Node &TargetN)
A convenience wrapper around the above to handle trivial cases of inserting a new call edge.
LLVM_ABI void removeOutgoingEdge(Node &SourceN, Node &TargetN)
Remove an edge whose source is in this RefSCC and target is not.
LLVM_ABI void switchOutgoingEdgeToRef(Node &SourceN, Node &TargetN)
Make an existing outgoing call edge into a ref edge.
LLVM_ABI void switchTrivialInternalEdgeToRef(Node &SourceN, Node &TargetN)
Make an existing internal call edge between separate SCCs into a ref edge.
LLVM_ABI bool isParentOf(const RefSCC &RC) const
Test if this RefSCC is a parent of RC.
An SCC of the call graph.
bool isAncestorOf(const SCC &C) const
Test if this SCC is an ancestor of C.
friend class LazyCallGraph::Node
bool isParentOf(const SCC &C) const
Test if this SCC is a parent of C.
friend class LazyCallGraph
RefSCC & getOuterRefSCC() const
A lazily constructed view of the call graph of a module.
bool isLibFunction(Function &F) const
Test whether a function is a known and defined library function tracked by the call graph.
RefSCC * lookupRefSCC(Node &N) const
Lookup a function's RefSCC in the graph.
LLVM_ABI void insertEdge(Node &SourceN, Node &TargetN, Edge::Kind EK)
Update the call graph after inserting a new edge.
LLVM_ABI LazyCallGraph(Module &M, function_ref< TargetLibraryInfo &(Function &)> GetTLI)
Construct a graph for the given module.
LLVM_ABI void buildRefSCCs()
static LLVM_ABI void visitReferences(SmallVectorImpl< Constant * > &Worklist, SmallPtrSetImpl< Constant * > &Visited, function_ref< void(Function &)> Callback)
Recursively visits the defined functions whose address is reachable from every constant in the Workli...
LLVM_ABI void markDeadFunction(Function &F)
Mark a function as dead to be removed later by removeDeadFunctions().
LLVM_ABI void addSplitFunction(Function &OriginalFunction, Function &NewFunction)
Add a new function split/outlined from an existing function.
LLVM_ABI void addSplitRefRecursiveFunctions(Function &OriginalFunction, ArrayRef< Function * > NewFunctions)
Add new ref-recursive functions split/outlined from an existing function.
LLVM_ABI void removeDeadFunctions(ArrayRef< Function * > DeadFs)
Remove dead functions from the call graph.
LLVM_ABI void removeEdge(Node &SourceN, Node &TargetN)
Update the call graph after deleting an edge.
Node & get(Function &F)
Get a graph node for a given function, scanning it to populate the graph data as necessary.
SCC * lookupSCC(Node &N) const
Lookup a function's SCC in the graph.
iterator_range< postorder_ref_scc_iterator > postorder_ref_sccs()
LLVM_ABI LazyCallGraph & operator=(LazyCallGraph &&RHS)
LLVM_ABI bool invalidate(Module &, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &)
void verify()
Verify that every RefSCC is valid.
Node * lookup(const Function &F) const
Lookup a function in the graph which has already been scanned and added.
A Module instance is used to store all the information related to an LLVM module.
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...
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
iterator erase(const_iterator CI)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void swap(SmallVectorImpl &RHS)
void push_back(const T &Elt)
reverse_iterator rbegin()
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Provides information about what library functions are available for the current target.
bool isKnownVectorFunctionInLibrary(StringRef F) const
Check if the function "F" is listed in a library known to LLVM.
LibFunc getLibFunc(StringRef funcName) const
Searches for a particular function name.
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
LLVM_ABI std::string EscapeString(const std::string &Label)
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
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.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
constexpr from_range_t from_range
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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...
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
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<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.
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Implement std::hash so that hash_code can be used in STL containers.
A special type used by analysis passes to provide an address that identifies that particular analysis...