A lazily constructed view of the call graph of a module.
Declared in <llvm/Analysis/LazyCallGraph.h>
class LazyCallGraph;
With the edges of this graph, the motivating constraint that we are attempting to maintain is that function-local optimization, CGSCC-local optimizations, and optimizations transforming a pair of functions connected by an edge in the graph, do not invalidate a bottom-up traversal of the SCC DAG. That is, no optimizations will delete, remove, or add an edge such that functions already visited in a bottom-up order of the SCC DAG are no longer valid to have visited, or such that functions not yet visited in a bottom-up order of the SCC DAG are not required to have already been visited.
Within this constraint, the desire is to minimize the merge points of the SCC DAG. The greater the fanout of the SCC DAG and the fewer merge points in the SCC DAG, the more independence there is in optimizing within it. There is a strong desire to enable parallelization of optimizations over the call graph, and both limited fanout and merge points will (artificially in some cases) limit the scaling of such an effort.
To this end, graph represents both direct and any potential resolution to an indirect call edge. Another way to think about it is that it represents both the direct call edges and any direct call edges that might be formed through static optimizations. Specifically, it considers taking the address of a function to be an edge in the call graph because this might be forwarded to become a direct call by some subsequent function-local optimization. The result is that the graph closely follows the use-def edges for functions. Walking "up" the graph can be done by looking at all of the uses of a function.
The roots of the call graph are the external functions and functions escaped into global variables. Those functions can be called from outside of the module or via unknowable means in the IR -- we may not be able to form even a potential call edge from a function body which may dynamically load the function and call it.
This analysis still requires updates to remain valid after optimizations which could potentially change the set of potential callees. The constraints it operates under only make the traversal order remain valid.
The entire analysis must be re-computed if full interprocedural optimizations run at any point. For example, globalopt completely invalidates the information in this analysis.
FIXME: This class is named LazyCallGraph in a lame attempt to distinguish it from the existing CallGraph. At some point, it is expected that this will be the only call graph and it will be renamed accordingly.
| Name | Description |
|---|---|
Edge | A class used to represent edges in the call graph. |
EdgeSequence | The edge sequence object. |
Node | A node in the call graph. |
RefSCC | A RefSCC of the call graph. |
SCC | An SCC of the call graph. |
postorder_ref_scc_iterator | A post-order depth-first RefSCC iterator over the call graph. |
| Name | Description |
|---|---|
LazyCallGraph [constructor] | Constructors |
operator= | Move-assign this lazy call graph from RHS. |
addSplitFunction | Add a new function split/outlined from an existing function. |
addSplitRefRecursiveFunctions | Add new ref-recursive functions split/outlined from an existing function. |
begin | Return an iterator to the first entry edge into the graph. |
buildRefSCCs | Build the post-order sequence of RefSCCs for this graph. |
end | Return an iterator past the last entry edge into the graph. |
get | Get a graph node for a given function, scanning it to populate the graph data as necessary. |
getLibFunctions | Get the sequence of known and defined library functions. |
insertEdge | Update the call graph after inserting a new edge. |
invalidate | Invalidate cached analyses when the module changes. |
isLibFunction | Test whether a function is a known and defined library function tracked by the call graph. |
lookup | Lookup a function in the graph which has already been scanned and added. |
lookupRefSCC | Lookup a function's RefSCC in the graph. |
lookupSCC | Lookup a function's SCC in the graph. |
markDeadFunction | Mark a function as dead to be removed later by removeDeadFunctions(). |
postorder_ref_scc_begin | Return a post-order iterator to the first RefSCC. |
postorder_ref_scc_end | Return a post-order iterator past the last RefSCC. |
postorder_ref_sccs | Return a range over the RefSCCs in post-order. |
removeDeadFunctions | Remove dead functions from the call graph. |
removeEdge | Update the call graph after deleting an edge. |
verify | Verify that every RefSCC is valid. |
| Name | Description |
|---|---|
visitReferences | Recursively visits the defined functions whose address is reachable from every constant in the Worklist. |
| Name | Description |
|---|---|
updateCGAndAnalysisManagerForCGSCCPass | Helper to update the call graph after running a CGSCC pass. |
updateCGAndAnalysisManagerForFunctionPass | Helper to update the call graph after running a function pass. |