GCC builds a “call graph”, recording which functions call which other functions, and it uses this for various optimizations.
It is constructed by the “*build_cgraph_edges” pass.
In case it’s of interest, it is available via the following Python API:
Get a list of all gcc.CallgraphNode instances
Return the GraphViz source for a rendering of the current callgraph, as a string.
Here’s an example of such a rendering:
The gcc.FunctionDecl for this node within the callgraph
The function calls made by this function, as a list of gcc.CallgraphEdge instances
The places that call this function, as a list of gcc.CallgraphEdge instances
Internally, this wraps a struct cgraph_node *
The function that makes this call, as a gcc.CallgraphNode
The function that is called here, as a gcc.CallgraphNode
The gcc.GimpleCall statememt for the function call
Internally, this wraps a struct cgraph_edge *