class LazyCallGraph::RefSCC
Declaration
class LazyCallGraph::RefSCC { /* full declaration omitted */ };
Description
A RefSCC of the call graph. This models a Strongly Connected Component of function reference edges in the call graph. As opposed to actual SCCs, these can be used to scope subgraphs of the module which are independent from other subgraphs of the module because they do not reference it in any way. This is also the unit where we do mutation of the graph in order to restrict mutations to those which don't violate this independence. A RefSCC contains a DAG of actual SCCs. All the nodes within the RefSCC are necessarily within some actual SCC that nests within it. Since a direct call *is* a reference, there will always be at least one RefSCC around any SCC.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:547
Method Overview
- public llvm::LazyCallGraph::RefSCC::iterator begin() const
- public llvm::LazyCallGraph::RefSCC::iterator end() const
- public llvm::LazyCallGraph::RefSCC::iterator find(llvm::LazyCallGraph::SCC & C) const
- public std::string getName() const
- public SmallVector<llvm::LazyCallGraph::RefSCC *, 1> insertIncomingRefEdge(llvm::LazyCallGraph::Node & SourceN, llvm::LazyCallGraph::Node & TargetN)
- public void insertInternalRefEdge(llvm::LazyCallGraph::Node & SourceN, llvm::LazyCallGraph::Node & TargetN)
- public void insertOutgoingEdge(llvm::LazyCallGraph::Node & SourceN, llvm::LazyCallGraph::Node & TargetN, Edge::Kind EK)
- public void insertTrivialCallEdge(llvm::LazyCallGraph::Node & SourceN, llvm::LazyCallGraph::Node & TargetN)
- public void insertTrivialRefEdge(llvm::LazyCallGraph::Node & SourceN, llvm::LazyCallGraph::Node & TargetN)
- public bool isAncestorOf(const llvm::LazyCallGraph::RefSCC & RC) const
- public bool isChildOf(const llvm::LazyCallGraph::RefSCC & RC) const
- public bool isDescendantOf(const llvm::LazyCallGraph::RefSCC & RC) const
- public bool isParentOf(const llvm::LazyCallGraph::RefSCC & RC) const
- public SmallVector<llvm::LazyCallGraph::RefSCC *, 1> removeInternalRefEdge(llvm::LazyCallGraph::Node & SourceN, ArrayRef<llvm::LazyCallGraph::Node *> TargetNs)
- public void removeOutgoingEdge(llvm::LazyCallGraph::Node & SourceN, llvm::LazyCallGraph::Node & TargetN)
- public void replaceNodeFunction(llvm::LazyCallGraph::Node & N, llvm::Function & NewF)
- public ssize_t size() const
- public bool switchInternalEdgeToCall(llvm::LazyCallGraph::Node & SourceN, llvm::LazyCallGraph::Node & TargetN, function_ref<void (ArrayRef<llvm::LazyCallGraph::SCC *>)> MergeCB = {})
- public iterator_range<llvm::LazyCallGraph::RefSCC::iterator> switchInternalEdgeToRef(llvm::LazyCallGraph::Node & SourceN, llvm::LazyCallGraph::Node & TargetN)
- public void switchOutgoingEdgeToCall(llvm::LazyCallGraph::Node & SourceN, llvm::LazyCallGraph::Node & TargetN)
- public void switchOutgoingEdgeToRef(llvm::LazyCallGraph::Node & SourceN, llvm::LazyCallGraph::Node & TargetN)
- public void switchTrivialInternalEdgeToRef(llvm::LazyCallGraph::Node & SourceN, llvm::LazyCallGraph::Node & TargetN)
Methods
¶llvm::LazyCallGraph::RefSCC::iterator begin()
const
llvm::LazyCallGraph::RefSCC::iterator begin()
const
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:619
¶llvm::LazyCallGraph::RefSCC::iterator end() const
llvm::LazyCallGraph::RefSCC::iterator end() const
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:620
¶llvm::LazyCallGraph::RefSCC::iterator find(
llvm::LazyCallGraph::SCC& C) const
llvm::LazyCallGraph::RefSCC::iterator find(
llvm::LazyCallGraph::SCC& C) const
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:626
Parameters
¶std::string getName() const
std::string getName() const
Description
Provide a short name by printing this RefSCC to a std::string. This copes with the fact that we don't have a name per-se for an RefSCC while still making the use of this in debugging and logging useful.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:662
¶SmallVector<llvm::LazyCallGraph::RefSCC*, 1>
insertIncomingRefEdge(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
SmallVector<llvm::LazyCallGraph::RefSCC*, 1>
insertIncomingRefEdge(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
Description
Insert an edge whose source is in a descendant RefSCC and target is in this RefSCC. There must be an existing path from the target to the source in this case. NB! This is has the potential to be a very expensive function. It inherently forms a cycle in the prior RefSCC DAG and we have to merge RefSCCs to resolve that cycle. But finding all of the RefSCCs which participate in the cycle can in the worst case require traversing every RefSCC in the graph. Every attempt is made to avoid that, but passes must still exercise caution calling this routine repeatedly. Also note that this can only insert ref edges. In order to insert a call edge, first insert a ref edge and then switch it to a call edge. These are intentionally kept as separate interfaces because each step of the operation invalidates a different set of data structures. This returns all the RefSCCs which were merged into the this RefSCC (the target's). This allows callers to invalidate any cached information. FIXME: We could possibly optimize this quite a bit for cases where the caller and callee are very nearby in the graph. See comments in the implementation for details, but that use case might impact users.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:788
Parameters
- llvm::LazyCallGraph::Node& SourceN
- llvm::LazyCallGraph::Node& TargetN
¶void insertInternalRefEdge(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
void insertInternalRefEdge(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
Description
Insert a ref edge from one node in this RefSCC to another in this RefSCC. This is always a trivial operation as it doesn't change any part of the graph structure besides connecting the two nodes. Note that we don't support directly inserting internal *call* edges because that could change the graph structure and requires returning information about what became invalid. As a consequence, the pattern should be to first insert the necessary ref edge, and then to switch it to a call edge if needed and handle any invalidation that results. See the \c switchInternalEdgeToCall routine for details.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:753
Parameters
- llvm::LazyCallGraph::Node& SourceN
- llvm::LazyCallGraph::Node& TargetN
¶void insertOutgoingEdge(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN,
Edge::Kind EK)
void insertOutgoingEdge(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN,
Edge::Kind EK)
Description
Insert an edge whose parent is in this RefSCC and child is in some child RefSCC. There must be an existing path from the \p SourceN to the \p TargetN. This operation is inexpensive and does not change the set of SCCs and RefSCCs in the graph.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:761
Parameters
- llvm::LazyCallGraph::Node& SourceN
- llvm::LazyCallGraph::Node& TargetN
- Edge::Kind EK
¶void insertTrivialCallEdge(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
void insertTrivialCallEdge(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
Description
A convenience wrapper around the above to handle trivial cases of inserting a new call edge. This is trivial whenever the target is in the same SCC as the source or the edge is an outgoing edge to some descendant SCC. In these cases there is no change to the cyclic structure of SCCs or RefSCCs. To further make calling this convenient, it also handles inserting already existing edges.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:853
Parameters
- llvm::LazyCallGraph::Node& SourceN
- llvm::LazyCallGraph::Node& TargetN
¶void insertTrivialRefEdge(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
void insertTrivialRefEdge(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
Description
A convenience wrapper around the above to handle trivial cases of inserting a new ref edge. This is trivial whenever the target is in the same RefSCC as the source or the edge is an outgoing edge to some descendant RefSCC. In these cases there is no change to the cyclic structure of the RefSCCs. To further make calling this convenient, it also handles inserting already existing edges.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:864
Parameters
- llvm::LazyCallGraph::Node& SourceN
- llvm::LazyCallGraph::Node& TargetN
¶bool isAncestorOf(
const llvm::LazyCallGraph::RefSCC& RC) const
bool isAncestorOf(
const llvm::LazyCallGraph::RefSCC& RC) const
Description
Test if this RefSCC is an ancestor of \a RC. CAUTION: This method walks the directed graph of edges as far as necessary to find a possible path to the argument. In the worst case this may walk the entire graph and can be extremely expensive.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:641
Parameters
- const llvm::LazyCallGraph::RefSCC& RC
¶bool isChildOf(
const llvm::LazyCallGraph::RefSCC& RC) const
bool isChildOf(
const llvm::LazyCallGraph::RefSCC& RC) const
Description
Test if this RefSCC is a child of \a RC. CAUTION: This method walks every edge in the argument \c RefSCC, it can be very expensive.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:647
Parameters
- const llvm::LazyCallGraph::RefSCC& RC
¶bool isDescendantOf(
const llvm::LazyCallGraph::RefSCC& RC) const
bool isDescendantOf(
const llvm::LazyCallGraph::RefSCC& RC) const
Description
Test if this RefSCC is a descendant of \a RC. CAUTION: This method walks the directed graph of edges as far as necessary to find a possible path from the argument. In the worst case this may walk the entire graph and can be extremely expensive.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:654
Parameters
- const llvm::LazyCallGraph::RefSCC& RC
¶bool isParentOf(
const llvm::LazyCallGraph::RefSCC& RC) const
bool isParentOf(
const llvm::LazyCallGraph::RefSCC& RC) const
Description
Test if this RefSCC is a parent of \a RC. CAUTION: This method walks every edge in the \c RefSCC, it can be very expensive.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:634
Parameters
- const llvm::LazyCallGraph::RefSCC& RC
¶SmallVector<llvm::LazyCallGraph::RefSCC*, 1>
removeInternalRefEdge(
llvm::LazyCallGraph::Node& SourceN,
ArrayRef<llvm::LazyCallGraph::Node*> TargetNs)
SmallVector<llvm::LazyCallGraph::RefSCC*, 1>
removeInternalRefEdge(
llvm::LazyCallGraph::Node& SourceN,
ArrayRef<llvm::LazyCallGraph::Node*> TargetNs)
Description
Remove a list of ref edges which are entirely within this RefSCC. Both the \a SourceN and all of the \a TargetNs must be within this RefSCC. Removing these edges may break cycles that form this RefSCC and thus this operation may change the RefSCC graph significantly. In particular, this operation will re-form new RefSCCs based on the remaining connectivity of the graph. The following invariants are guaranteed to hold after calling this method: 1) If a ref-cycle remains after removal, it leaves this RefSCC intact and in the graph. No new RefSCCs are built. 2) Otherwise, this RefSCC will be dead after this call and no longer in the graph or the postorder traversal of the call graph. Any iterator pointing at this RefSCC will become invalid. 3) All newly formed RefSCCs will be returned and the order of the RefSCCs returned will be a valid postorder traversal of the new RefSCCs. 4) No RefSCC other than this RefSCC has its member set changed (this is inherent in the definition of removing such an edge). These invariants are very important to ensure that we can build optimization pipelines on top of the CGSCC pass manager which intelligently update the RefSCC graph without invalidating other parts of the RefSCC graph. Note that we provide no routine to remove a *call* edge. Instead, you must first switch it to a ref edge using \c switchInternalEdgeToRef. This split API is intentional as each of these two steps can invalidate a different aspect of the graph structure and needs to have the invalidation handled independently. The runtime complexity of this method is, in the worst case, O(V+E) where V is the number of nodes in this RefSCC and E is the number of edges leaving the nodes in this RefSCC. Note that E includes both edges within this RefSCC and edges from this RefSCC to child RefSCCs. Some effort has been made to minimize the overhead of common cases such as self-edges and edge removals which result in a spanning tree with no more cycles.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:841
Parameters
- llvm::LazyCallGraph::Node& SourceN
- ArrayRef<llvm::LazyCallGraph::Node*> TargetNs
¶void removeOutgoingEdge(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
void removeOutgoingEdge(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
Description
Remove an edge whose source is in this RefSCC and target is *not*. This removes an inter-RefSCC edge. All inter-RefSCC edges originating from this SCC have been fully explored by any in-flight DFS graph formation, so this is always safe to call once you have the source RefSCC. This operation does not change the cyclic structure of the graph and so is very inexpensive. It may change the connectivity graph of the SCCs though, so be careful calling this while iterating over them.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:801
Parameters
- llvm::LazyCallGraph::Node& SourceN
- llvm::LazyCallGraph::Node& TargetN
¶void replaceNodeFunction(
llvm::LazyCallGraph::Node& N,
llvm::Function& NewF)
void replaceNodeFunction(
llvm::LazyCallGraph::Node& N,
llvm::Function& NewF)
Description
Directly replace a node's function with a new function. This should be used when moving the body and users of a function to a new formal function object but not otherwise changing the call graph structure in any way. It requires that the old function in the provided node have zero uses and the new function must have calls and references to it establishing an equivalent graph.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:875
Parameters
¶ssize_t size() const
ssize_t size() const
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:622
¶bool switchInternalEdgeToCall(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN,
function_ref<
void(ArrayRef<llvm::LazyCallGraph::SCC*>)>
MergeCB = {})
bool switchInternalEdgeToCall(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN,
function_ref<
void(ArrayRef<llvm::LazyCallGraph::SCC*>)>
MergeCB = {})
Description
Make an existing internal ref edge into a call edge. This may form a larger cycle and thus collapse SCCs into TargetN's SCC. If that happens, the optional callback \p MergedCB will be invoked (if provided) on the SCCs being merged away prior to actually performing the merge. Note that this will never include the target SCC as that will be the SCC functions are merged into to resolve the cycle. Once this function returns, these merged SCCs are not in a valid state but the pointers will remain valid until destruction of the parent graph instance for the purpose of clearing cached information. This function also returns 'true' if a cycle was formed and some SCCs merged away as a convenience. After this operation, both SourceN's SCC and TargetN's SCC may move position within this RefSCC's postorder list. Any SCCs merged are merged into the TargetN's SCC in order to preserve reachability analyses which took place on that SCC.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:696
Parameters
- llvm::LazyCallGraph::Node& SourceN
- llvm::LazyCallGraph::Node& TargetN
- function_ref<void( ArrayRef<llvm::LazyCallGraph::SCC*>)> MergeCB = {}
¶iterator_range<
llvm::LazyCallGraph::RefSCC::iterator>
switchInternalEdgeToRef(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
iterator_range<
llvm::LazyCallGraph::RefSCC::iterator>
switchInternalEdgeToRef(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
Description
Make an existing internal call edge within a single SCC into a ref edge. Since SourceN and TargetN are part of a single SCC, this SCC may be split up due to breaking a cycle in the call edges that formed it. If that happens, then this routine will insert new SCCs into the postorder list *before* the SCC of TargetN (previously the SCC of both). This preserves postorder as the TargetN can reach all of the other nodes by definition of previously being in a single SCC formed by the cycle from SourceN to TargetN. The newly added SCCs are added *immediately* and contiguously prior to the TargetN SCC and return the range covering the new SCCs in the RefSCC's postorder sequence. You can directly iterate the returned range to observe all of the new SCCs in postorder. Note that if SourceN and TargetN are in separate SCCs, the simpler routine `switchTrivialInternalEdgeToRef` should be used instead.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:726
Parameters
- llvm::LazyCallGraph::Node& SourceN
- llvm::LazyCallGraph::Node& TargetN
¶void switchOutgoingEdgeToCall(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
void switchOutgoingEdgeToCall(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
Description
Make an existing outgoing ref edge into a call edge. Note that this is trivial as there are no cyclic impacts and there remains a reference edge.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:733
Parameters
- llvm::LazyCallGraph::Node& SourceN
- llvm::LazyCallGraph::Node& TargetN
¶void switchOutgoingEdgeToRef(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
void switchOutgoingEdgeToRef(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
Description
Make an existing outgoing call edge into a ref edge. This is trivial as there are no cyclic impacts and there remains a reference edge.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:739
Parameters
- llvm::LazyCallGraph::Node& SourceN
- llvm::LazyCallGraph::Node& TargetN
¶void switchTrivialInternalEdgeToRef(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
void switchTrivialInternalEdgeToRef(
llvm::LazyCallGraph::Node& SourceN,
llvm::LazyCallGraph::Node& TargetN)
Description
Make an existing internal call edge between separate SCCs into a ref edge. If SourceN and TargetN in separate SCCs within this RefSCC, changing the call edge between them to a ref edge is a trivial operation that does not require any structural changes to the call graph.
Declared at: llvm/include/llvm/Analysis/LazyCallGraph.h:706
Parameters
- llvm::LazyCallGraph::Node& SourceN
- llvm::LazyCallGraph::Node& TargetN